]> granicus.if.org Git - neomutt/commitdiff
Make GPGME backend generate a RFC3156-compliant micalg parameter
authorBrendan Cully <brendan@kublai.com>
Sun, 10 Jun 2007 02:58:22 +0000 (19:58 -0700)
committerBrendan Cully <brendan@kublai.com>
Sun, 10 Jun 2007 02:58:22 +0000 (19:58 -0700)
(blush). Based on a patch by Stefan Haun. Closes #2901.

ChangeLog
ascii.h
crypt-gpgme.c

index aea6b892bbf85fac8d7b425aa6b1bf3467d16c20..54c45234e67760898afbc03bbae7cd2d45a26425 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-06-09 01:03 +0200  Thomas Roessler  <roessler@does-not-exist.org>  (53e5e1105fd2)
+
+       * sendlib.c: remove unnecessary dprints
+
+       * sendlib.c: Fix header encoding corner case.
+
+2007-06-05 13:12 -0700  pywatson  <pywatson@gmail.com>  (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  <cb@df7cb.de>  (edefe5e1f2b4)
 
        * Muttrc.head: Temporarily set pipe_decode in the \cb urlview macro.
diff --git a/ascii.h b/ascii.h
index e256c2a813e805c1e3e25f12c66de57b345c9bae..81c071c3982dd3c32f2049ecdab3b55eb66f1418 100644 (file)
--- 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
index 1c719a9dbd208df9be796691f48c964dc6994240..59bc5b03d84d917c5576f67d57b19fb02f05c6df 100644 (file)
@@ -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;