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 <agl@google.com>
This commit is contained in:
David Benjamin 2015-02-28 20:45:54 -05:00 committed by Adam Langley
parent 0d5e080ab9
commit cc239d3903

View File

@ -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;