From 980ac10011a1a3721a4fc0924df900d045b817c4 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 29 Mar 2013 20:13:34 +0100 Subject: [PATCH 1/3] Regenerate the Date header after signing Previously the difference to the signature timestamp could be used to estimate the passphrase length for the signing key (if the passphrase wasn't cached). --- src/compose.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/compose.c b/src/compose.c index c3ea943..0865230 100644 --- a/src/compose.c +++ b/src/compose.c @@ -5709,12 +5709,31 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool } /* sign message if sending */ if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing && - privacy_system_can_sign(compose->privacy_system)) - if (!privacy_sign(compose->privacy_system, mimemsg, - compose->account, from_addr)) { + privacy_system_can_sign(compose->privacy_system)) { + gchar *date; + gchar *end; + gboolean message_signed; + gboolean date_found; + + date = mimemsg->data.mem + strlen("Date: "); + end = strchr(date, '\n'); + + message_signed = privacy_sign(compose->privacy_system, mimemsg, + compose->account, from_addr); + date_found = !strncmp(mimemsg->data.mem, "Date: ", strlen("Date: ")); + + if (!message_signed || !date_found || end == NULL) { g_free(from_name); g_free(from_addr); return -2; + } + /* + * Regenerate the Date header so the difference to the + * signature timestamp can't be used to estimate the + * passphrase length for the signing key. + */ + get_rfc822_date(date, strlen(date)); + *end = '\n'; } g_free(from_name); g_free(from_addr); -- 2.1.2 From 63992277bf8c41360eedb33332e53069a67fc522 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 10 Oct 2012 20:14:37 +0200 Subject: [PATCH 2/3] In case of multiple matching encryption keys, use the most recent one without bothering the user --- src/plugins/pgpcore/select-keys.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/plugins/pgpcore/select-keys.c b/src/plugins/pgpcore/select-keys.c index 6559220..8e4a110 100644 --- a/src/plugins/pgpcore/select-keys.c +++ b/src/plugins/pgpcore/select-keys.c @@ -274,6 +274,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot cm_return_val_if_fail (sk, NULL); clist = sk->clist; cm_return_val_if_fail (clist, NULL); + static int use_most_recent_key = 1; debug_print ("select_keys:fill_clist: pattern '%s' proto %d\n", pattern, proto); @@ -302,7 +303,6 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot if (!key->can_encrypt || key->revoked || key->expired || key->disabled) continue; debug_print ("%% %s:%d: insert\n", __FILE__ ,__LINE__ ); - set_row (clist, key, proto ); for (; uid; uid = uid->next) { gchar *raw_mail = NULL; @@ -320,14 +320,37 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot } g_free(raw_mail); } - num_results++; - last_key = key; + if (use_most_recent_key) { + if (last_key == NULL) { + debug_print ("%s:%d: First matching key for %s has fingerprint %s\n", + __FILE__ ,__LINE__, pattern, key->subkeys->fpr); + last_key = key; + } else if (key->subkeys->timestamp > last_key->subkeys->timestamp) { + debug_print ("%s:%d: Ditching key %s in favor of the more recent %s\n", + __FILE__ ,__LINE__, last_key->subkeys->fpr, key->subkeys->fpr); + last_key = key; + } else { + debug_print ("%s:%d: Not chosing key %s as it's older than the current choice\n", + __FILE__ ,__LINE__, key->subkeys->fpr); + } + } else { + set_row (clist, key, proto ); + num_results++; + last_key = key; + } key = NULL; update_progress (sk, ++running, pattern); while (gtk_events_pending ()) gtk_main_iteration (); } - + + if (use_most_recent_key && last_key) { + debug_print ("%s:%d: The final key for %s has fingerprint %s\n", + __FILE__ ,__LINE__, pattern, last_key->subkeys->fpr); + set_row (clist, last_key, proto ); + num_results++; + } + if (exact_match == TRUE && num_results == 1) { if (last_key->uids->validity < GPGME_VALIDITY_FULL && !use_untrusted(last_key, last_uid, proto)) -- 2.1.2 From ecbc0d9419fadc5309ea73f5f80390292ad62eb1 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 4 Sep 2013 21:29:56 +0200 Subject: [PATCH 3/3] Don't advertise the local time through the Message-ID --- src/common/utils.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/common/utils.c b/src/common/utils.c index 2e41793..ea431ee 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -3902,13 +3902,7 @@ gint g_int_compare(gconstpointer a, gconstpointer b) gchar *generate_msgid(gchar *buf, gint len, gchar *user_addr) { - struct tm *lt; - time_t t; gchar *addr; - struct tm buft; - - t = time(NULL); - lt = localtime_r(&t, &buft); if (user_addr != NULL) addr = g_strdup_printf(".%s", user_addr); @@ -3923,10 +3917,7 @@ gchar *generate_msgid(gchar *buf, gint len, gchar *user_addr) while (strchr(addr, '@') != NULL && strchr(addr, '@') != strrchr(addr, '@')) *(strchr(addr, '@')) = '_'; - g_snprintf(buf, len, "%04d%02d%02d%02d%02d%02d.%08x%s", - lt->tm_year + 1900, lt->tm_mon + 1, - lt->tm_mday, lt->tm_hour, - lt->tm_min, lt->tm_sec, + g_snprintf(buf, len, "%08x.%08x%s", (guint) rand(), (guint) rand(), addr); g_free(addr); -- 2.1.2 From c1525f1758d5e2cd8b5ae1320986a5c9473636dc Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 26 Dec 2014 18:23:42 +0100 Subject: [PATCH] sgpgme_sigstat_info_*(): Don't translate GPG_ERR_GENERAL to "signature hasn't been checked" --- src/plugins/pgpcore/sgpgme.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/pgpcore/sgpgme.c b/src/plugins/pgpcore/sgpgme.c index 3de07e2..1cc7e5f 100644 --- a/src/plugins/pgpcore/sgpgme.c +++ b/src/plugins/pgpcore/sgpgme.c @@ -245,6 +245,9 @@ gchar *sgpgme_sigstat_info_short(gpgme_ctx_t ctx, gpgme_verify_result_t status) g_free(id); break; } + case GPG_ERR_GENERAL: + result = g_strdup_printf(_("Verifying the signature from %s failed"), uname); + break; default: result = g_strdup(_("The signature has not been checked.")); break; @@ -332,6 +335,11 @@ gchar *sgpgme_sigstat_info_full(gpgme_ctx_t ctx, gpgme_verify_result_t status) _("BAD signature from \"%s\"\n"), uid); break; + case GPG_ERR_GENERAL: + g_string_append_printf(siginfo, + _("Verifying the signature from \"%s\" failed\n"), + uid); + break; default: break; } -- 2.1.2