text stringlengths 0 357 |
|---|
ret_valid_signatures : NULL; /*if we already have fingerprints, do not add more; this ensures, only the fingerprints from the outer-most part are collected */ |
if (!dc_pgp_pk_decrypt(context, decoded_data, decoded_data_bytes, private_keyring, public_keyring_for_validate, 1, &plain_buf, &plain_bytes, add_signatures) |
|| plain_buf==NULL || plain_bytes<=0) { |
goto cleanup; |
} |
//{char* t1=dc_null_terminate(plain_buf,plain_bytes);printf("\n**********\n%s\n**********\n",t1);free(t1);} |
{ |
size_t index = 0; |
struct mailmime* decrypted_mime = NULL; |
if (mailmime_parse(plain_buf, plain_bytes, &index, &decrypted_mime)!=MAIL_NO_ERROR |
|| decrypted_mime==NULL) { |
if(decrypted_mime) {mailmime_free(decrypted_mime);} |
goto cleanup; |
} |
//mailmime_print(decrypted_mime); |
*ret_decrypted_mime = decrypted_mime; |
sth_decrypted = 1; |
} |
//mailmime_substitute(mime, new_mime); |
//s. mailprivacy_gnupg.c::pgp_decrypt() |
cleanup: |
if (transfer_decoding_buffer) { |
mmap_string_unref(transfer_decoding_buffer); |
} |
return sth_decrypted; |
} |
static int decrypt_recursive(dc_context_t* context, |
struct mailmime* mime, |
const dc_keyring_t* private_keyring, |
const dc_keyring_t* public_keyring_for_validate, |
dc_hash_t* ret_valid_signatures, |
struct mailimf_fields** ret_gossip_headers, |
int* ret_has_unencrypted_parts) |
{ |
struct mailmime_content* ct = NULL; |
clistiter* cur = NULL; |
if (context==NULL || mime==NULL) { |
return 0; |
} |
if (mime->mm_type==MAILMIME_MULTIPLE) |
{ |
ct = mime->mm_content_type; |
if (ct && ct->ct_subtype && strcmp(ct->ct_subtype, "encrypted")==0) { |
/* decrypt "multipart/encrypted" -- child parts are eg. "application/pgp-encrypted" (uninteresting, version only), |
"application/octet-stream" (the interesting data part) and optional, unencrypted help files */ |
for (cur=clist_begin(mime->mm_data.mm_multipart.mm_mp_list); cur!=NULL; cur=clist_next(cur)) { |
struct mailmime* decrypted_mime = NULL; |
if (decrypt_part(context, (struct mailmime*)clist_content(cur), private_keyring, public_keyring_for_validate, ret_valid_signatures, &decrypted_mime)) |
{ |
/* remember the header containing potentially Autocrypt-Gossip */ |
if (*ret_gossip_headers==NULL /* use the outermost decrypted part */ |
&& dc_hash_cnt(ret_valid_signatures) > 0 /* do not trust the gossipped keys when the message cannot be validated eg. due to a bad signature */) |
{ |
size_t dummy = 0; |
struct mailimf_fields* test = NULL; |
if (mailimf_envelope_and_optional_fields_parse(decrypted_mime->mm_mime_start, decrypted_mime->mm_length, &dummy, &test)==MAILIMF_NO_ERROR |
&& test) { |
*ret_gossip_headers = test; |
} |
} |
/* replace encrypted mime structure by decrypted one */ |
mailmime_substitute(mime, decrypted_mime); |
mailmime_free(mime); |
return 1; /* sth. decrypted, start over from root searching for encrypted parts */ |
} |
} |
*ret_has_unencrypted_parts = 1; // there is a part that could not be decrypted |
} |
else { |
for (cur=clist_begin(mime->mm_data.mm_multipart.mm_mp_list); cur!=NULL; cur=clist_next(cur)) { |
if (decrypt_recursive(context, (struct mailmime*)clist_content(cur), private_keyring, public_keyring_for_validate, ret_valid_signatures, ret_gossip_headers, ret_has_unencrypted_parts)) { |
return 1; /* sth. decrypted, start over from root searching for encrypted parts */ |
} |
} |
} |
} |
else if (mime->mm_type==MAILMIME_MESSAGE) |
{ |
if (decrypt_recursive(context, mime->mm_data.mm_message.mm_msg_mime, private_keyring, public_keyring_for_validate, ret_valid_signatures, ret_gossip_headers, ret_has_unencrypted_parts)) { |
return 1; /* sth. decrypted, start over from root searching for encrypted parts */ |
} |
} |
else |
{ |
*ret_has_unencrypted_parts = 1; // there is a part that was not encrypted at all. in combination with otherwise encrypted mails, this is a problem. |
} |
return 0; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.