text stringlengths 0 357 |
|---|
struct mailimf_field* field = (struct mailimf_field*)clist_content(cur); |
if (field) { |
if (field->fld_type==MAILIMF_FIELD_SUBJECT) { |
move_to_encrypted = 1; |
} |
else if (field->fld_type==MAILIMF_FIELD_OPTIONAL_FIELD) { |
struct mailimf_optional_field* opt_field = field->fld_data.fld_optional_field; |
if (opt_field && opt_field->fld_name) { |
if ( strncmp(opt_field->fld_name, "Secure-Join", 11)==0 |
|| (strncmp(opt_field->fld_name, "Chat-", 5)==0 && strcmp(opt_field->fld_name, "Chat-Version")!=0)/*Chat-Version may be used for filtering and is not added to the encrypted part, however, this is subject to change*/) { |
move_to_encrypted = 1; |
} |
} |
} |
} |
if (move_to_encrypted) { |
mailimf_fields_add(imffields_encrypted, field); |
cur = clist_delete(imffields_unprotected->fld_list, cur); |
} |
else { |
cur = clist_next(cur); |
} |
} |
struct mailimf_subject* subject = mailimf_subject_new(dc_strdup("...")); |
mailimf_fields_add(imffields_unprotected, mailimf_field_new(MAILIMF_FIELD_SUBJECT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, subject, NULL, NULL, NULL)); |
clist_append(part_to_encrypt->mm_content_type->ct_parameters, mailmime_param_new_with_data("protected-headers", "v1")); |
/* convert part to encrypt to plain text */ |
mailmime_write_mem(plain, &col, message_to_encrypt); |
if (plain->str==NULL || plain->len<=0) { |
goto cleanup; |
} |
//char* t1=dc_null_terminate(plain->str,plain->len);printf("PLAIN:\n%s\n",t1);free(t1); // DEBUG OUTPUT |
if (!dc_pgp_pk_encrypt(context, plain->str, plain->len, keyring, sign_key, 1/*use_armor*/, (void**)&ctext, &ctext_bytes)) { |
goto cleanup; |
} |
helper->cdata_to_free = ctext; |
//char* t2=dc_null_terminate(ctext,ctext_bytes);printf("ENCRYPTED:\n%s\n",t2);free(t2); // DEBUG OUTPUT |
/* create MIME-structure that will contain the encrypted text */ |
struct mailmime* encrypted_part = new_data_part(NULL, 0, "multipart/encrypted", -1); |
struct mailmime_content* content = encrypted_part->mm_content_type; |
clist_append(content->ct_parameters, mailmime_param_new_with_data("protocol", "application/pgp-encrypted")); |
static char version_content[] = "Version: 1\r\n"; |
struct mailmime* version_mime = new_data_part(version_content, strlen(version_content), "application/pgp-encrypted", MAILMIME_MECHANISM_7BIT); |
mailmime_smart_add_part(encrypted_part, version_mime); |
struct mailmime* ctext_part = new_data_part(ctext, ctext_bytes, "application/octet-stream", MAILMIME_MECHANISM_7BIT); |
mailmime_smart_add_part(encrypted_part, ctext_part); |
/* replace the original MIME-structure by the encrypted MIME-structure */ |
in_out_message->mm_data.mm_message.mm_msg_mime = encrypted_part; |
encrypted_part->mm_parent = in_out_message; |
mailmime_free(message_to_encrypt); |
//MMAPString* t3=mmap_string_new("");mailmime_write_mem(t3,&col,in_out_message);char* t4=dc_null_terminate(t3->str,t3->len); printf("ENCRYPTED+MIME_ENCODED:\n%s\n",t4);free(t4);mmap_string_free(t3); // DEBUG OUTPUT |
helper->encryption_successfull = 1; |
} |
char* p = dc_aheader_render(autocryptheader); |
if (p==NULL) { |
goto cleanup; |
} |
mailimf_fields_add(imffields_unprotected, mailimf_field_new_custom(strdup("Autocrypt"), p/*takes ownership of pointer*/)); |
cleanup: |
dc_aheader_unref(autocryptheader); |
dc_keyring_unref(keyring); |
dc_key_unref(sign_key); |
if (plain) { mmap_string_free(plain); } |
for (int i=dc_array_get_cnt(peerstates)-1; i>=0; i--) { dc_apeerstate_unref((dc_apeerstate_t*)dc_array_get_ptr(peerstates, i)); } |
dc_array_unref(peerstates); |
} |
void dc_e2ee_thanks(dc_e2ee_helper_t* helper) |
{ |
if (helper==NULL) { |
return; |
} |
free(helper->cdata_to_free); |
helper->cdata_to_free = NULL; |
if (helper->gossipped_addr) |
{ |
dc_hash_clear(helper->gossipped_addr); |
free(helper->gossipped_addr); |
helper->gossipped_addr = NULL; |
} |
if (helper->signatures) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.