summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-06-22 18:11:03 +0200
committerRichard Levitte <levitte@openssl.org>2021-06-23 23:00:36 +0200
commit21dfdbef4965d95d65bfc942aafafd342cb61e4c (patch)
tree0109e97fe55d84ca320052636c173d847b2fa134 /crypto
parent006de7670a12dff617e86a55b6db7c6e3b1f8fef (diff)
downloadopenssl-new-21dfdbef4965d95d65bfc942aafafd342cb61e4c.tar.gz
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')
-rw-r--r--crypto/crmf/crmf_pbm.c4
-rw-r--r--crypto/hmac/hmac.c17
2 files changed, 12 insertions, 9 deletions
diff --git a/crypto/crmf/crmf_pbm.c b/crypto/crmf/crmf_pbm.c
index 0c217295d3..aba6b3a16f 100644
--- a/crypto/crmf/crmf_pbm.c
+++ b/crypto/crmf/crmf_pbm.c
@@ -140,7 +140,6 @@ int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq,
unsigned int bklen = EVP_MAX_MD_SIZE;
int64_t iterations;
unsigned char *mac_res = 0;
- unsigned int maclen;
int ok = 0;
if (out == NULL || pbmp == NULL || pbmp->mac == NULL
@@ -207,10 +206,9 @@ int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq,
goto err;
}
if (EVP_Q_mac(libctx, "HMAC", propq, hmac_mdname, NULL, basekey, bklen,
- msg, msglen, mac_res, EVP_MAX_MD_SIZE, &maclen) == NULL)
+ msg, msglen, mac_res, EVP_MAX_MD_SIZE, outlen) == NULL)
goto err;
- *outlen = (size_t)maclen;
ok = 1;
err:
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)