summaryrefslogtreecommitdiff
path: root/crypto/hmac
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/hmac')
-rw-r--r--crypto/hmac/hmac.c17
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)