From 4e52135a248adec2dfc132d63c01800f3c7135f5 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 5 Feb 2001 22:23:04 +0000 Subject: New function to handle inline pgp-signatures. 2001-02-05 Jeffrey Stedfast * mail-format.c (try_inline_pgp_sig): New function to handle inline pgp-signatures. svn path=/trunk/; revision=7996 --- mail/ChangeLog | 3 +++ mail/mail-format.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 11c6df36e7..907a295f91 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,8 @@ 2001-02-05 Jeffrey Stedfast + * mail-format.c (try_inline_pgp_sig): New function to handle + inline pgp-signatures. + * mail-config-druid.c (construct): Keep track of the CheckSettings check boxes. (transport_next): Connect if the user says so. diff --git a/mail/mail-format.c b/mail/mail-format.c index faea36f633..5645134ae7 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -45,6 +45,7 @@ static char *get_data_wrapper_text (CamelDataWrapper *data); static char *try_inline_pgp (char *start, MailDisplay *md); +static char *try_inline_pgp_sig (char *start, MailDisplay *md); static char *try_uudecoding (char *start, MailDisplay *md); static char *try_inline_binhex (char *start, MailDisplay *md); @@ -763,6 +764,7 @@ struct { char * (*handler) (char *start, MailDisplay *md); } text_specials[] = { { "-----BEGIN PGP MESSAGE-----\n", try_inline_pgp }, + { "-----BEGIN PGP SIGNED MESSAGE-----\n", try_inline_pgp_sig }, { "begin ", try_uudecoding }, { "(This file must be converted with BinHex 4.0)\n", try_inline_binhex } }; @@ -957,15 +959,13 @@ try_inline_pgp (char *start, MailDisplay *md) { char *end, *ciphertext, *plaintext; int outlen; - - /* FIXME: This should deal with signed data as well. */ - + end = strstr (start, "-----END PGP MESSAGE-----"); if (!end) return start; - + end += strlen ("-----END PGP MESSAGE-----") - 1; - + mail_html_write (md->html, md->stream, "
"); /* FIXME: uhm, pgp decrypted data doesn't have to be plaintext @@ -981,7 +981,57 @@ try_inline_pgp (char *start, MailDisplay *md) mail_html_write (md->html, md->stream, ""); g_free (plaintext); } + + return end; +} +static char * +try_inline_pgp_sig (char *start, MailDisplay *md) +{ + char *end, *ciphertext; + CamelException *ex; + gboolean valid; + + end = strstr (start, "-----END PGP SIGNATURE-----"); + if (!end) + return start; + + end += strlen ("-----END PGP SIGNATURE-----") - 1; + + mail_html_write (md->html, md->stream, "
"); + + ciphertext = g_strndup (start, end - start); + ex = camel_exception_new (); + valid = openpgp_verify (ciphertext, end - start, NULL, 0, ex); + g_free (ciphertext); + + mail_text_write (md->html, md->stream, "%s", start); + + /* Now display the "seal-of-authenticity" or something... */ + if (valid) { + mail_html_write (md->html, md->stream, + "
\n" + "" + "
%s

", + get_url_for_icon ("wax-seal2.png", md), + _("This message is digitally signed and " + "has been found to be authentic.")); + } else { + mail_html_write (md->html, md->stream, + "
\n" + "" + "
%s

", + get_url_for_icon ("wax-seal-broken.png", md), + _("This message is digitally signed but can " + "not be proven to be authentic.")); + mail_error_write (md->html, md->stream, + camel_exception_get_description (ex)); + mail_html_write (md->html, md->stream, + "

"); + } + + camel_exception_free (ex); + return end; } @@ -1339,9 +1389,6 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, /* Now display the "seal-of-authenticity" or something... */ if (valid) { - /* FIXME: maybe the pgp verify func should ALWAYS set - an exception so that we can get more details even - if it did pass the check. */ mail_html_write (md->html, md->stream, "
\n" "" -- cgit v1.2.3