From 6f20275b96e58ece5cf300bd382ba47d04398bd0 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 11 Dec 2000 23:07:01 +0000 Subject: Updated to reflect arguments to the openpgp functions - now also takes an 2000-12-11 Jeffrey Stedfast * mail-format.c (decode_pgp): Updated to reflect arguments to the openpgp functions - now also takes an outlen argument. (try_inline_pgp): Updated. (handle_multipart_encrypted): Updated here too. * mail-crypto.c (crypto_exec_with_passwd): Updated to handle binary streams and such. (mail_crypto_openpgp_encrypt): Always initialize the passwd_fds even if we don't plan on signing. Added an 'inlen' to specify the length of the input data (as it could be binary). Also added a 'userid' argument for cases when we want to sign as well as encrypt. (mail_crypto_openpgp_decrypt): Updated to take an outlen argument in case the ciphertext is encrypted binary data. (mail_crypto_openpgp_clearsign): Added a 'hash' and 'detach' arguments. 'hash' allows the program to specify the preferred hash function (which will come in handy when generating PGP/MIME). 'detach' allows the program to specify whether it wants a detached signature or the entire signed text. svn path=/trunk/; revision=6921 --- mail/mail-format.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'mail/mail-format.c') diff --git a/mail/mail-format.c b/mail/mail-format.c index b53c811068..b7eb7dbea0 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -827,16 +827,16 @@ destroy_part (CamelObject *root, gpointer event_data, gpointer user_data) } static char * -decode_pgp (const char *ciphertext, MailDisplay *md) +decode_pgp (const char *ciphertext, int *outlen, MailDisplay *md) { CamelException ex; char *plaintext; - + camel_exception_init (&ex); #ifdef PGP_PROGRAM /* FIXME: multipart parts */ if (g_datalist_get_data (md->data, "show_pgp")) { - plaintext = mail_crypto_openpgp_decrypt (ciphertext, &ex); + plaintext = mail_crypto_openpgp_decrypt (ciphertext, outlen, &ex); if (plaintext) return plaintext; } @@ -872,6 +872,7 @@ static char * try_inline_pgp (char *start, MailDisplay *md) { char *end, *ciphertext, *plaintext; + int outlen; /* FIXME: This should deal with signed data as well. */ @@ -882,11 +883,12 @@ try_inline_pgp (char *start, MailDisplay *md) end += sizeof ("-----END PGP MESSAGE-----") - 1; mail_html_write (md->html, md->stream, "
"); - + + /* FIXME: uhm, pgp decrypted data doesn't have to be plaintext */ ciphertext = g_strndup (start, end - start); - plaintext = decode_pgp (ciphertext, md); + plaintext = decode_pgp (ciphertext, &outlen, md); g_free (ciphertext); - if (plaintext) { + if (plaintext && outlen > 0) { mail_html_write (md->html, md->stream, "
"); @@ -1233,6 +1235,7 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, camel_medium_get_content_object (CAMEL_MEDIUM (part)); CamelMultipart *mp; char *ciphertext, *plaintext; + int outlen; g_return_val_if_fail (CAMEL_IS_MULTIPART (wrapper), FALSE); mp = CAMEL_MULTIPART (wrapper); @@ -1246,8 +1249,9 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, ciphertext = get_data_wrapper_text (wrapper); if (!ciphertext) return FALSE; - - plaintext = decode_pgp (ciphertext, md); + + /* FIXME: please note that decrypted data does NOT have to be plaintext */ + plaintext = decode_pgp (ciphertext, &outlen, md); if (plaintext) { CamelStream *memstream; -- cgit v1.2.3