Check HMAC_Init_ex() return value

This commit is contained in:
Nicolas Williams
2022-01-12 21:10:45 -06:00
parent 52f3dc6aa4
commit 05e8c0ede6
11 changed files with 125 additions and 65 deletions

View File

@@ -167,7 +167,10 @@ HMAC(const EVP_MD *md,
HMAC_CTX ctx;
HMAC_CTX_init(&ctx);
HMAC_Init_ex(&ctx, key, key_size, md, NULL);
if (HMAC_Init_ex(&ctx, key, key_size, md, NULL) == 0) {
HMAC_CTX_cleanup(&ctx);
return NULL;
}
HMAC_Update(&ctx, data, data_size);
HMAC_Final(&ctx, hash, hash_len);
HMAC_CTX_cleanup(&ctx);