[PATCH 1/4] md: check hmac flag in prepare_macpads

Jussi Kivilinna jussi.kivilinna at iki.fi
Wed Oct 28 18:55:42 CET 2015


* cipher/md.c (prepare_macpads): Check hmac flag.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 cipher/md.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/cipher/md.c b/cipher/md.c
index c6bf90d..948d269 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -671,6 +671,9 @@ prepare_macpads (gcry_md_hd_t a, const unsigned char *key, size_t keylen)
   if (!a->ctx->list)
     return GPG_ERR_DIGEST_ALGO; /* Might happen if no algo is enabled.  */
 
+  if (!a->ctx->flags.hmac)
+    return GPG_ERR_DIGEST_ALGO; /* Tried setkey for non-HMAC md. */
+
   for (r = a->ctx->list; r; r = r->next)
     {
       const unsigned char *k;




More information about the Gcrypt-devel mailing list