diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 11 | ||||
-rw-r--r-- | mail/mail-crypto.c | 92 | ||||
-rw-r--r-- | mail/mail-crypto.h | 2 | ||||
-rw-r--r-- | mail/mail-format.c | 15 |
4 files changed, 88 insertions, 32 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index e996c29a68..c9465a00af 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2002-06-21 Jeffrey Stedfast <fejj@ximian.com> + + * mail-crypto.c (mail_crypto_pgp_mime_part_verify): If the pgp + type is gpg, then use the gpg context. + (mail_crypto_pgp_mime_part_sign): Same. + (mail_crypto_pgp_mime_part_encrypt): Same. + (mail_crypto_pgp_mime_part_decrypt): Same. + + * mail-format.c (handle_multipart_signed): Use the new gpg cipher + context. + 2002-06-18 Jeffrey Stedfast <fejj@ximian.com> * message-list.c (message_list_change_first_visible_parent): New diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c index 7be3eadf41..fbd2f4bda5 100644 --- a/mail/mail-crypto.c +++ b/mail/mail-crypto.c @@ -46,14 +46,25 @@ void mail_crypto_pgp_mime_part_sign (CamelMimePart **mime_part, const char *userid, CamelCipherHash hash, CamelException *ex) { - CamelPgpContext *context; + CamelCipherContext *cipher; - context = camel_pgp_context_new (session, mail_config_get_pgp_type (), - mail_config_get_pgp_path ()); + switch (mail_config_get_pgp_type ()) { + case CAMEL_PGP_TYPE_GPG: + cipher = camel_gpg_context_new (session, mail_config_get_pgp_path ()); + break; + case CAMEL_PGP_TYPE_PGP5: + case CAMEL_PGP_TYPE_PGP6: + cipher = camel_pgp_context_new (session, mail_config_get_pgp_type (), + mail_config_get_pgp_path ()); + break; + default: + cipher = NULL; + break; + } - if (context) { - camel_pgp_mime_part_sign (context, mime_part, userid, hash, ex); - camel_object_unref (CAMEL_OBJECT (context)); + if (cipher) { + camel_pgp_mime_part_sign (cipher, mime_part, userid, hash, ex); + camel_object_unref (CAMEL_OBJECT (cipher)); } else camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create a PGP signature context.")); @@ -71,14 +82,25 @@ CamelCipherValidity * mail_crypto_pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex) { CamelCipherValidity *valid = NULL; - CamelPgpContext *context; + CamelCipherContext *cipher; - context = camel_pgp_context_new (session, mail_config_get_pgp_type (), - mail_config_get_pgp_path ()); + switch (mail_config_get_pgp_type ()) { + case CAMEL_PGP_TYPE_GPG: + cipher = camel_gpg_context_new (session, mail_config_get_pgp_path ()); + break; + case CAMEL_PGP_TYPE_PGP5: + case CAMEL_PGP_TYPE_PGP6: + cipher = camel_pgp_context_new (session, mail_config_get_pgp_type (), + mail_config_get_pgp_path ()); + break; + default: + cipher = NULL; + break; + } - if (context) { - valid = camel_pgp_mime_part_verify (context, mime_part, ex); - camel_object_unref (CAMEL_OBJECT (context)); + if (cipher) { + valid = camel_pgp_mime_part_verify (cipher, mime_part, ex); + camel_object_unref (CAMEL_OBJECT (cipher)); } else camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create a PGP verification context.")); @@ -100,14 +122,25 @@ mail_crypto_pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex) void mail_crypto_pgp_mime_part_encrypt (CamelMimePart **mime_part, GPtrArray *recipients, CamelException *ex) { - CamelPgpContext *context; + CamelCipherContext *cipher; - context = camel_pgp_context_new (session, mail_config_get_pgp_type (), - mail_config_get_pgp_path ()); + switch (mail_config_get_pgp_type ()) { + case CAMEL_PGP_TYPE_GPG: + cipher = camel_gpg_context_new (session, mail_config_get_pgp_path ()); + break; + case CAMEL_PGP_TYPE_PGP5: + case CAMEL_PGP_TYPE_PGP6: + cipher = camel_pgp_context_new (session, mail_config_get_pgp_type (), + mail_config_get_pgp_path ()); + break; + default: + cipher = NULL; + break; + } - if (context) { - camel_pgp_mime_part_encrypt (context, mime_part, recipients, ex); - camel_object_unref (CAMEL_OBJECT (context)); + if (cipher) { + camel_pgp_mime_part_encrypt (cipher, mime_part, recipients, ex); + camel_object_unref (CAMEL_OBJECT (cipher)); } else camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create a PGP encryption context.")); @@ -124,15 +157,26 @@ mail_crypto_pgp_mime_part_encrypt (CamelMimePart **mime_part, GPtrArray *recipie CamelMimePart * mail_crypto_pgp_mime_part_decrypt (CamelMimePart *mime_part, CamelException *ex) { - CamelPgpContext *context; + CamelCipherContext *cipher; CamelMimePart *part = NULL; - context = camel_pgp_context_new (session, mail_config_get_pgp_type (), - mail_config_get_pgp_path ()); + switch (mail_config_get_pgp_type ()) { + case CAMEL_PGP_TYPE_GPG: + cipher = camel_gpg_context_new (session, mail_config_get_pgp_path ()); + break; + case CAMEL_PGP_TYPE_PGP5: + case CAMEL_PGP_TYPE_PGP6: + cipher = camel_pgp_context_new (session, mail_config_get_pgp_type (), + mail_config_get_pgp_path ()); + break; + default: + cipher = NULL; + break; + } - if (context) { - part = camel_pgp_mime_part_decrypt (context, mime_part, ex); - camel_object_unref (CAMEL_OBJECT (context)); + if (cipher) { + part = camel_pgp_mime_part_decrypt (cipher, mime_part, ex); + camel_object_unref (CAMEL_OBJECT (cipher)); } else camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create a PGP decryption context.")); diff --git a/mail/mail-crypto.h b/mail/mail-crypto.h index 42467613e2..1ed794ceb5 100644 --- a/mail/mail-crypto.h +++ b/mail/mail-crypto.h @@ -31,7 +31,7 @@ #ifdef __cplusplus extern "C" { #pragma } -#endif /* __cplusplus } */ +#endif /* __cplusplus */ /* PGP/MIME convenience wrappers */ void mail_crypto_pgp_mime_part_sign (CamelMimePart **mime_part, diff --git a/mail/mail-format.c b/mail/mail-format.c index c17e614636..4eeca49f44 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -1839,19 +1839,20 @@ handle_multipart_signed (CamelMimePart *part, const char *mime_type, CamelException ex; const char *message = NULL; gboolean good = FALSE; - CamelPgpContext *context; + CamelCipherContext *cipher; /* Write out the verification results */ /* TODO: use the right context for the right message ... */ camel_exception_init (&ex); - context = camel_pgp_context_new(session, mail_config_get_pgp_type(), mail_config_get_pgp_path()); - if (context) { - valid = camel_multipart_signed_verify(mps, (CamelCipherContext *)context, &ex); + cipher = camel_gpg_context_new (session, mail_config_get_pgp_path ()); + if (cipher) { + valid = camel_multipart_signed_verify (mps, cipher, &ex); + camel_object_unref (CAMEL_OBJECT (cipher)); if (valid) { - good = camel_cipher_validity_get_valid(valid); - message = camel_cipher_validity_get_description(valid); + good = camel_cipher_validity_get_valid (valid); + message = camel_cipher_validity_get_description (valid); } else { - message = camel_exception_get_description(&ex); + message = camel_exception_get_description (&ex); } } else { message = U_("Could not create a PGP verfication context"); |