[git] GCRYPT - branch, master, updated. libgcrypt-1.7.1-9-g4d634a0

by Werner Koch cvs at cvs.gnupg.org
Mon Jun 27 17:26:32 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, master has been updated
       via  4d634a098742ff425b324e9f2a67b9f62de09744 (commit)
       via  ae26edf4b60359bfa5fe3a27b2c24b336e7ec35c (commit)
      from  7a7f7c147f888367dfee6093d26bfeaf750efc3a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4d634a098742ff425b324e9f2a67b9f62de09744
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jun 27 17:22:18 2016 +0200

    tests: Do not test SHAKE128 et al with gcry_md_hash_buffer.
    
    * tests/benchmark.c (md_bench): Do not test variable lengths algos
    with the gcry_md_hash_buffer.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/tests/benchmark.c b/tests/benchmark.c
index 53b83b1..d387c56 100644
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -572,21 +572,24 @@ md_bench ( const char *algoname )
   if (gcry_md_get_algo_dlen (algo) > sizeof digest)
     die ("digest buffer too short\n");
 
-  largebuf_base = malloc (10000+15);
-  if (!largebuf_base)
-    die ("out of core\n");
-  largebuf = (largebuf_base
-              + ((16 - ((size_t)largebuf_base & 0x0f)) % buffer_alignment));
-
-  for (i=0; i < 10000; i++)
-    largebuf[i] = i;
-  start_timer ();
-  for (repcount=0; repcount < hash_repetitions; repcount++)
-    for (i=0; i < 100; i++)
-      gcry_md_hash_buffer (algo, digest, largebuf, 10000);
-  stop_timer ();
-  printf (" %s", elapsed_time (1));
-  free (largebuf_base);
+  if (gcry_md_get_algo_dlen (algo))
+    {
+      largebuf_base = malloc (10000+15);
+      if (!largebuf_base)
+        die ("out of core\n");
+      largebuf = (largebuf_base
+                  + ((16 - ((size_t)largebuf_base & 0x0f)) % buffer_alignment));
+
+      for (i=0; i < 10000; i++)
+        largebuf[i] = i;
+      start_timer ();
+      for (repcount=0; repcount < hash_repetitions; repcount++)
+        for (i=0; i < 100; i++)
+          gcry_md_hash_buffer (algo, digest, largebuf, 10000);
+      stop_timer ();
+      printf (" %s", elapsed_time (1));
+      free (largebuf_base);
+    }
 
   putchar ('\n');
   fflush (stdout);

commit ae26edf4b60359bfa5fe3a27b2c24b336e7ec35c
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jun 27 17:11:23 2016 +0200

    md: Improve diagnostic when using SHAKE128 with gcry_md_hash_buffer.
    
    * cipher/md.c (md_read): Detect missing read function.
    (_gcry_md_hash_buffers): Return an error.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/cipher/md.c b/cipher/md.c
index a39e18a..27a0efb 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -831,9 +831,8 @@ md_read( gcry_md_hd_t a, int algo )
         {
           if (r->next)
             log_debug ("more than one algorithm in md_read(0)\n");
-          if (r->spec->read == NULL)
-            return NULL;
-          return r->spec->read (&r->context.c);
+          if (r->spec->read)
+            return r->spec->read (&r->context.c);
         }
     }
   else
@@ -841,12 +840,17 @@ md_read( gcry_md_hd_t a, int algo )
       for (r = a->ctx->list; r; r = r->next)
 	if (r->spec->algo == algo)
 	  {
-	    if (r->spec->read == NULL)
-	      return NULL;
-	    return r->spec->read (&r->context.c);
+	    if (r->spec->read)
+              return r->spec->read (&r->context.c);
+            break;
 	  }
     }
-  _gcry_fatal_error (GPG_ERR_DIGEST_ALGO, "request algo not in md context");
+
+  if (r && !r->spec->read)
+    _gcry_fatal_error (GPG_ERR_DIGEST_ALGO,
+                       "requested algo has no fixed digest length");
+  else
+    _gcry_fatal_error (GPG_ERR_DIGEST_ALGO, "requested algo not in md context");
   return NULL;
 }
 
@@ -1010,6 +1014,7 @@ _gcry_md_hash_buffers (int algo, unsigned int flags, void *digest,
 	 normal functions. */
       gcry_md_hd_t h;
       gpg_err_code_t rc;
+      int dlen;
 
       if (algo == GCRY_MD_MD5 && fips_mode ())
         {
@@ -1022,6 +1027,12 @@ _gcry_md_hash_buffers (int algo, unsigned int flags, void *digest,
             }
         }
 
+      /* Detect SHAKE128 like algorithms which we can't use because
+       * our API does not allow for a variable length digest.  */
+      dlen = md_digest_length (algo);
+      if (!dlen)
+        return GPG_ERR_DIGEST_ALGO;
+
       rc = md_open (&h, algo, (hmac? GCRY_MD_FLAG_HMAC:0));
       if (rc)
         return rc;
@@ -1041,7 +1052,7 @@ _gcry_md_hash_buffers (int algo, unsigned int flags, void *digest,
       for (;iovcnt; iov++, iovcnt--)
         md_write (h, (const char*)iov[0].data + iov[0].off, iov[0].len);
       md_final (h);
-      memcpy (digest, md_read (h, algo), md_digest_length (algo));
+      memcpy (digest, md_read (h, algo), dlen);
       md_close (h);
     }
 

-----------------------------------------------------------------------

Summary of changes:
 cipher/md.c       | 27 +++++++++++++++++++--------
 tests/benchmark.c | 33 ++++++++++++++++++---------------
 2 files changed, 37 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org


_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits




More information about the Gcrypt-devel mailing list