From: Brendan Cully Date: Sun, 10 Jun 2007 02:58:22 +0000 (-0700) Subject: Make GPGME backend generate a RFC3156-compliant micalg parameter X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94514d793442fb501a323fbe4b76696583240d23;p=neomutt Make GPGME backend generate a RFC3156-compliant micalg parameter (blush). Based on a patch by Stefan Haun. Closes #2901. --- diff --git a/ChangeLog b/ChangeLog index aea6b892b..54c45234e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-06-09 01:03 +0200 Thomas Roessler (53e5e1105fd2) + + * sendlib.c: remove unnecessary dprints + + * sendlib.c: Fix header encoding corner case. + +2007-06-05 13:12 -0700 pywatson (9e90789518ad) + + * ChangeLog, sort.c: Make sort by "To" stable (closes #2515). + compare_to() calls mutt_get_name(), which may return a static + pointer if it in turn calls mutt_addr_for_display(). If this static + pointer is used for a and b, the result is bad. The fix is to make a + copy of the first object. + 2007-05-17 14:40 +0200 Christoph Berg (edefe5e1f2b4) * Muttrc.head: Temporarily set pipe_decode in the \cb urlview macro. diff --git a/ascii.h b/ascii.h index e256c2a81..81c071c39 100644 --- a/ascii.h +++ b/ascii.h @@ -39,4 +39,17 @@ int ascii_strncasecmp (const char *a, const char *b, int n); #define ascii_strcmp(a,b) mutt_strcmp(a,b) #define ascii_strncmp(a,b,c) mutt_strncmp(a,b,c) +static inline char* ascii_strlower (char *s) +{ + char *p = s; + + while (*p) + { + *p = ascii_tolower ((unsigned int) *p); + p++; + } + + return s; +} + #endif diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 1c719a9db..59bc5b03d 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -760,21 +760,23 @@ static int get_micalg (gpgme_ctx_t ctx, char *buf, size_t buflen) { gpgme_sign_result_t result = NULL; const char *algorithm_name = NULL; + char *bp; - if (!buflen) + if (buflen < 5) return -1; *buf = 0; result = gpgme_op_sign_result (ctx); if (result && result->signatures) + { + algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo); + if (algorithm_name) { - algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo); - if (algorithm_name) - { - strncpy (buf, algorithm_name, buflen - 1); - buf[buflen - 1] = 0; - } + /* convert GPGME raw hash name to RFC 3156 format */ + snprintf (buf, buflen, "pgp-%s", algorithm_name); + ascii_strlower (buf + 4); } + } return *buf? 0:-1; } @@ -875,7 +877,7 @@ static BODY *sign_message (BODY *a, int use_smime) if (!get_micalg (ctx, buf, sizeof buf)) mutt_set_parameter ("micalg", buf, &t->parameter); else if (use_smime) - mutt_set_parameter ("micalg", "sha1", &t->parameter); + mutt_set_parameter ("micalg", "pgp-sha1", &t->parameter); gpgme_release (ctx); t->parts = a;