diff options
author | Milan Crha <mcrha@redhat.com> | 2010-05-20 05:09:26 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-05-20 05:09:26 +0800 |
commit | 98adb40685d4a454d792b23c6ba23468b95c6216 (patch) | |
tree | b453678fb5cb4e3f9b90084e380fb22f466e974d /composer | |
parent | 0e7a51c8bb58197beb605f8cd2f87d702912d49a (diff) | |
download | gsoc2013-evolution-98adb40685d4a454d792b23c6ba23468b95c6216.tar.gz gsoc2013-evolution-98adb40685d4a454d792b23c6ba23468b95c6216.tar.zst gsoc2013-evolution-98adb40685d4a454d792b23c6ba23468b95c6216.zip |
Bug #304415 - Allow change of signature hash algorithm
Diffstat (limited to 'composer')
-rw-r--r-- | composer/e-msg-composer.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 9d26e50fbb..b588fd0977 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -559,6 +559,25 @@ build_message_headers (EMsgComposer *composer, } } +static CamelCipherHash +account_hash_algo_to_camel_hash (const gchar *hash_algo) +{ + CamelCipherHash res = CAMEL_CIPHER_HASH_DEFAULT; + + if (hash_algo && *hash_algo) { + if (g_ascii_strcasecmp (hash_algo, "sha1") == 0) + res = CAMEL_CIPHER_HASH_SHA1; + else if (g_ascii_strcasecmp (hash_algo, "sha256") == 0) + res = CAMEL_CIPHER_HASH_SHA256; + else if (g_ascii_strcasecmp (hash_algo, "sha384") == 0) + res = CAMEL_CIPHER_HASH_SHA384; + else if (g_ascii_strcasecmp (hash_algo, "sha512") == 0) + res = CAMEL_CIPHER_HASH_SHA512; + } + + return res; +} + static CamelMimeMessage * build_message (EMsgComposer *composer, gboolean html_content, @@ -895,7 +914,6 @@ build_message (EMsgComposer *composer, const gchar *pgp_userid; CamelInternetAddress *from = NULL; CamelCipherContext *cipher; - EAccount *account; part = camel_mime_part_new (); camel_medium_set_content (CAMEL_MEDIUM (part), current); @@ -903,8 +921,6 @@ build_message (EMsgComposer *composer, camel_mime_part_set_encoding (part, plain_encoding); g_object_unref (current); - account = e_composer_header_table_get_account (table); - if (account && account->pgp_key && *account->pgp_key) { pgp_userid = account->pgp_key; } else { @@ -921,7 +937,8 @@ build_message (EMsgComposer *composer, CAMEL_GPG_CONTEXT (cipher), account->pgp_always_trust); camel_cipher_sign ( - cipher, pgp_userid, CAMEL_CIPHER_HASH_SHA1, + cipher, pgp_userid, account_hash_algo_to_camel_hash ( + account ? e_account_get_string (account, E_ACCOUNT_PGP_HASH_ALGORITHM) : NULL), part, npart, &ex); g_object_unref (cipher); @@ -1009,7 +1026,9 @@ build_message (EMsgComposer *composer, camel_smime_context_set_encrypt_key ((CamelSMIMEContext *)cipher, TRUE, account->smime_encrypt_key); } - camel_cipher_sign (cipher, account->smime_sign_key, CAMEL_CIPHER_HASH_SHA1, part, npart, &ex); + camel_cipher_sign (cipher, account->smime_sign_key, + account_hash_algo_to_camel_hash (account ? e_account_get_string (account, E_ACCOUNT_SMIME_HASH_ALGORITHM) : NULL), + part, npart, &ex); g_object_unref (cipher); if (camel_exception_is_set (&ex)) { |