From cc239d3903f908fff2933f379577cf8f57482a09 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Sat, 28 Feb 2015 20:45:54 -0500 Subject: [PATCH] Use HMAC_Init_ex, not HMAC_Init, in HMAC. We've already initialized the context, HMAC_Init has questionable behavior around NULL keys, and this avoids a size_t truncation. Change-Id: Iab6bfc24fe22d46ca4c01be6129efe0630d553e6 Reviewed-on: https://boringssl-review.googlesource.com/3732 Reviewed-by: Adam Langley --- crypto/hmac/hmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index f179fede6..21479c2ac 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -76,7 +76,7 @@ uint8_t *HMAC(const EVP_MD *evp_md, const void *key, size_t key_len, } HMAC_CTX_init(&ctx); - if (!HMAC_Init(&ctx, key, key_len, evp_md) || + if (!HMAC_Init_ex(&ctx, key, key_len, evp_md, NULL) || !HMAC_Update(&ctx, data, data_len) || !HMAC_Final(&ctx, out, out_len)) { out = NULL;