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 | |
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
-rw-r--r-- | composer/e-msg-composer.c | 29 | ||||
-rw-r--r-- | mail/em-account-editor.c | 61 | ||||
-rw-r--r-- | mail/mail-config.ui | 138 | ||||
-rw-r--r-- | smime/lib/e-cert.c | 9 |
4 files changed, 216 insertions, 21 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)) { diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index e253770562..55b7399e7f 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -2775,6 +2775,65 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget return w; } +static void +emae_account_hash_algo_combo_changed_cb (GtkComboBox *combobox, EMAccountEditor *emae) +{ + EAccount *account; + gpointer data; + const gchar *text = NULL; + + account = em_account_editor_get_modified_account (emae); + data = g_object_get_data (G_OBJECT (combobox), "account-item"); + + switch (gtk_combo_box_get_active (combobox)) { + case 1: text = "sha1"; + break; + case 2: text = "sha256"; + break; + case 3: + text = "sha384"; + break; + case 4: + text = "sha512"; + break; + } + + e_account_set_string (account, GPOINTER_TO_INT (data), text); +} + +static GtkComboBox * +emae_account_hash_algo_combo (EMAccountEditor *emae, const gchar *name, gint item, GtkBuilder *builder) +{ + EAccount *account; + GtkComboBox *combobox; + const gchar *text; + gint index = 0; + + account = em_account_editor_get_modified_account (emae); + combobox = GTK_COMBO_BOX (e_builder_get_widget (builder, name)); + g_return_val_if_fail (combobox != NULL, NULL); + + text = e_account_get_string (account, item); + if (text) { + if (g_ascii_strcasecmp (text, "sha1") == 0) + index = 1; + else if (g_ascii_strcasecmp (text, "sha256") == 0) + index = 2; + else if (g_ascii_strcasecmp (text, "sha384") == 0) + index = 3; + else if (g_ascii_strcasecmp (text, "sha512") == 0) + index = 4; + } + + gtk_combo_box_set_active (combobox, index); + + g_object_set_data (G_OBJECT (combobox), "account-item", GINT_TO_POINTER (item)); + g_signal_connect (combobox, "changed", G_CALLBACK (emae_account_hash_algo_combo_changed_cb), emae); + gtk_widget_set_sensitive (GTK_WIDGET (combobox), e_account_writable (account, item)); + + return combobox; +} + static GtkWidget * emae_security_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *old, gpointer data) { @@ -2793,6 +2852,7 @@ emae_security_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget /* Security */ emae_account_entry (emae, "pgp_key", E_ACCOUNT_PGP_KEY, builder); + emae_account_hash_algo_combo (emae, "pgp_hash_algo", E_ACCOUNT_PGP_HASH_ALGORITHM, builder); emae_account_toggle (emae, "pgp_encrypt_to_self", E_ACCOUNT_PGP_ENCRYPT_TO_SELF, builder); emae_account_toggle (emae, "pgp_always_sign", E_ACCOUNT_PGP_ALWAYS_SIGN, builder); emae_account_toggle (emae, "pgp_no_imip_sign", E_ACCOUNT_PGP_NO_IMIP_SIGN, builder); @@ -2806,6 +2866,7 @@ emae_security_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget g_signal_connect (priv->smime_sign_key_select, "clicked", G_CALLBACK(smime_sign_key_select), emae); g_signal_connect (priv->smime_sign_key_clear, "clicked", G_CALLBACK(smime_sign_key_clear), emae); + emae_account_hash_algo_combo (emae, "smime_hash_algo", E_ACCOUNT_SMIME_HASH_ALGORITHM, builder); priv->smime_sign_default = emae_account_toggle (emae, "smime_sign_default", E_ACCOUNT_SMIME_SIGN_DEFAULT, builder); priv->smime_encrypt_key = emae_account_entry (emae, "smime_encrypt_key", E_ACCOUNT_SMIME_ENCRYPT_KEY, builder); diff --git a/mail/mail-config.ui b/mail/mail-config.ui index e264cfa3d6..d1489becf8 100644 --- a/mail/mail-config.ui +++ b/mail/mail-config.ui @@ -95,6 +95,29 @@ </row> </data> </object> + <object class="GtkListStore" id="hash_algo_model"> + <columns> + <!-- column-name Hash Algo Name --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Default</col> + </row> + <row> + <col id="0" translatable="yes">SHA1</col> + </row> + <row> + <col id="0" translatable="yes">SHA256</col> + </row> + <row> + <col id="0" translatable="yes">SHA384</col> + </row> + <row> + <col id="0" translatable="yes">SHA512</col> + </row> + </data> + </object> <object class="GtkVBox" id="vboxIdentityBorder"> <property name="visible">True</property> <property name="border_width">12</property> @@ -2174,6 +2197,46 @@ For example: "Work" or "Personal"</property> <property name="position">0</property> </packing> </child> + <child> + <object class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="pgp_hash_algo_label"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Si_gning algorithm:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">pgp_hash_algo</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="pgp_hash_algo"> + <property name="visible">True</property> + <property name="model">hash_algo_model</property> + <child> + <object class="GtkCellRendererText" id="pgp_hash_algo_renderer"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> <child> <object class="GtkCheckButton" id="pgp_always_sign"> <property name="label" translatable="yes">Al_ways sign outgoing messages when using this account</property> @@ -2186,7 +2249,7 @@ For example: "Work" or "Personal"</property> <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -2202,7 +2265,7 @@ For example: "Work" or "Personal"</property> <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> <child> @@ -2217,7 +2280,7 @@ For example: "Work" or "Personal"</property> <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> </object> @@ -2276,7 +2339,7 @@ For example: "Work" or "Personal"</property> <child> <object class="GtkTable" id="smime_table"> <property name="visible">True</property> - <property name="n_rows">6</property> + <property name="n_rows">7</property> <property name="n_columns">3</property> <property name="column_spacing">12</property> <property name="row_spacing">6</property> @@ -2301,8 +2364,8 @@ For example: "Work" or "Personal"</property> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> <property name="y_options"></property> </packing> </child> @@ -2317,8 +2380,8 @@ For example: "Work" or "Personal"</property> </object> <packing> <property name="right_attach">3</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> @@ -2334,8 +2397,8 @@ For example: "Work" or "Personal"</property> </object> <packing> <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> @@ -2361,8 +2424,8 @@ For example: "Work" or "Personal"</property> </object> <packing> <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> <property name="y_padding">6</property> @@ -2377,8 +2440,8 @@ For example: "Work" or "Personal"</property> <property name="mnemonic_widget">smime_encrypt_key</property> </object> <packing> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> @@ -2502,8 +2565,8 @@ For example: "Work" or "Personal"</property> <packing> <property name="left_attach">2</property> <property name="right_attach">3</property> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> @@ -2618,6 +2681,49 @@ For example: "Work" or "Personal"</property> <property name="y_options">GTK_FILL</property> </packing> </child> + <child> + <object class="GtkLabel" id="smime_hash_algo_label"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Signing _algorithm:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">smime_hash_algo</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="smime_hash_algo_alignment"> + <property name="visible">True</property> + <property name="left_padding">0</property> + <property name="xalign">0.0</property> + <property name="xscale">0.0</property> + <child> + <object class="GtkComboBox" id="smime_hash_algo"> + <property name="visible">True</property> + <property name="model">hash_algo_model</property> + <child> + <object class="GtkCellRendererText" id="smime_hash_algo_renderer"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + </packing> + </child> </object> <packing> <property name="position">1</property> diff --git a/smime/lib/e-cert.c b/smime/lib/e-cert.c index 86f8c5dced..1dee4d4a65 100644 --- a/smime/lib/e-cert.c +++ b/smime/lib/e-cert.c @@ -635,6 +635,15 @@ get_oid_text (SECItem *oid, gchar **text) case SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION: *text = g_strdup (_("PKCS #1 SHA-1 With RSA Encryption")); break; + case SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION: + *text = g_strdup (_("PKCS #1 SHA-256 With RSA Encryption")); + break; + case SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION: + *text = g_strdup (_("PKCS #1 SHA-384 With RSA Encryption")); + break; + case SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION: + *text = g_strdup (_("PKCS #1 SHA-512 With RSA Encryption")); + break; case SEC_OID_AVA_COUNTRY_NAME: *text = g_strdup ("C"); break; |