DKIM: Ed25519 signatures (GnuTLS 3.6.0 and later)
[exim.git] / src / src / dkim.c
index 867d45647d0bedd94136e86fb717e0a5a7505a13..c7bf641527822a7fecc97fe383ca7c548a5ea2f1 100644 (file)
@@ -58,7 +58,6 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
   if (rr->type == T_TXT)
     {
     int rr_offset = 0;
-    int answer_offset = 0;
 
     /* Copy record content to the answer buffer */
 
@@ -74,7 +73,7 @@ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
       }
 
     /* check if this looks like a DKIM record */
-    if (strncmp(g->s, "v=", 2) != 0 || strncasecmp(g->s, "v=dkim", 6) == 0)
+    if (Ustrncmp(g->s, "v=", 2) != 0 || strncasecmp(CS g->s, "v=dkim", 6) == 0)
       {
       store_reset(g->s + g->ptr + 1);
       return string_from_gstring(g);
@@ -269,7 +268,7 @@ dkim_exim_verify_finish(void)
 pdkim_signature * sig;
 int rc;
 gstring * g = NULL;
-const uschar * errstr;
+const uschar * errstr = NULL;
 
 store_pool = POOL_PERM;
 
@@ -292,12 +291,8 @@ dkim_collect_input = FALSE;
 /* Finish DKIM operation and fetch link to signatures chain */
 
 rc = pdkim_feed_finish(dkim_verify_ctx, &dkim_signatures, &errstr);
-if (rc != PDKIM_OK)
-  {
-  log_write(0, LOG_MAIN, "DKIM: validation error: %.100s%s%s", pdkim_errstr(rc),
-           errstr ? ": " : "", errstr ? errstr : US"");
-  goto out;
-  }
+if (rc != PDKIM_OK && errstr)
+  log_write(0, LOG_MAIN, "DKIM: validation error: %s", errstr);
 
 /* Build a colon-separated list of signing domains (and identities, if present) in dkim_signers */
 
@@ -711,6 +706,9 @@ while ((dkim_signing_domain = string_nextinlist(&dkim_domain, &sep, NULL, 0)))
                        pdkim_canon,
                        pdkim_canon, -1, 0, 0);
 
+    if (!pdkim_set_bodyhash(&ctx, sig))
+      goto bad;
+
     if (!ctx.sig)              /* link sig to context chain */
       ctx.sig = sig;
     else
@@ -728,7 +726,7 @@ if (!ctx.sig)
   goto CLEANUP;
   }
 
-if (prefix && (pdkim_feed(&ctx, prefix, Ustrlen(prefix))) != PDKIM_OK)
+if (prefix && (pdkim_rc = pdkim_feed(&ctx, prefix, Ustrlen(prefix))) != PDKIM_OK)
   goto pk_bad;
 
 if (lseek(fd, off, SEEK_SET) < 0)