diff options
author | Richard Levitte <levitte@openssl.org> | 2021-06-22 18:11:03 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-06-23 23:00:36 +0200 |
commit | 21dfdbef4965d95d65bfc942aafafd342cb61e4c (patch) | |
tree | 0109e97fe55d84ca320052636c173d847b2fa134 /crypto/hmac/hmac.c | |
parent | EVP: Change the output size type of EVP_Q_digest() and EVP_Q_mac() (diff) | |
download | openssl-21dfdbef4965d95d65bfc942aafafd342cb61e4c.tar.xz openssl-21dfdbef4965d95d65bfc942aafafd342cb61e4c.zip |
Adapt other parts of the source to the changed EVP_Q_digest() and EVP_Q_mac()
Fixes #15839
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15861)
Diffstat (limited to 'crypto/hmac/hmac.c')
-rw-r--r-- | crypto/hmac/hmac.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index 618b0a6196..940d867ca6 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -224,12 +224,17 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, { static unsigned char static_md[EVP_MAX_MD_SIZE]; int size = EVP_MD_get_size(evp_md); - - if (size < 0) - return NULL; - return EVP_Q_mac(NULL, "HMAC", NULL, EVP_MD_get0_name(evp_md), NULL, - key, key_len, data, data_len, - md == NULL ? static_md : md, size, md_len); + size_t temp_md_len = 0; + unsigned char *ret = NULL; + + if (size >= 0) { + ret = EVP_Q_mac(NULL, "HMAC", NULL, EVP_MD_get0_name(evp_md), NULL, + key, key_len, data, data_len, + md == NULL ? static_md : md, size, &temp_md_len); + if (md_len != NULL) + *md_len = (unsigned int)temp_md_len; + } + return ret; } void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags) |