The branch master has been updated
via 04e3ab64d58bb43efc4392d12c607bb4b5a2c562 (commit)
from d26b3766a0a35668ee62b839a62acbdcd9ff2a98 (commit)
- Log -----------------------------------------------------------------
commit 04e3ab64d58bb43efc4392d12c607bb4b5a2c562
Author: x2018 <[email protected]>
Date: Mon Nov 29 15:32:47 2021 +0800
check the return value of EVP_MD_fetch in ecdh_exch.c:285 & dh_exch.c:347
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/17153)
-----------------------------------------------------------------------
Summary of changes:
providers/implementations/exchange/dh_exch.c | 5 +++--
providers/implementations/exchange/ecdh_exch.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/providers/implementations/exchange/dh_exch.c
b/providers/implementations/exchange/dh_exch.c
index 6edf57e0ae..4bea7af4ec 100644
--- a/providers/implementations/exchange/dh_exch.c
+++ b/providers/implementations/exchange/dh_exch.c
@@ -345,12 +345,13 @@ static int dh_set_ctx_params(void *vpdhctx, const
OSSL_PARAM params[])
EVP_MD_free(pdhctx->kdf_md);
pdhctx->kdf_md = EVP_MD_fetch(pdhctx->libctx, name, mdprops);
+ if (pdhctx->kdf_md == NULL)
+ return 0;
if (!ossl_digest_is_allowed(pdhctx->libctx, pdhctx->kdf_md)) {
EVP_MD_free(pdhctx->kdf_md);
pdhctx->kdf_md = NULL;
- }
- if (pdhctx->kdf_md == NULL)
return 0;
+ }
}
p = OSSL_PARAM_locate_const(params, OSSL_EXCHANGE_PARAM_KDF_OUTLEN);
diff --git a/providers/implementations/exchange/ecdh_exch.c
b/providers/implementations/exchange/ecdh_exch.c
index 64b163f5e0..bf6f5c2366 100644
--- a/providers/implementations/exchange/ecdh_exch.c
+++ b/providers/implementations/exchange/ecdh_exch.c
@@ -283,12 +283,13 @@ int ecdh_set_ctx_params(void *vpecdhctx, const OSSL_PARAM
params[])
EVP_MD_free(pectx->kdf_md);
pectx->kdf_md = EVP_MD_fetch(pectx->libctx, name, mdprops);
+ if (pectx->kdf_md == NULL)
+ return 0;
if (!ossl_digest_is_allowed(pectx->libctx, pectx->kdf_md)) {
EVP_MD_free(pectx->kdf_md);
pectx->kdf_md = NULL;
- }
- if (pectx->kdf_md == NULL)
return 0;
+ }
}
p = OSSL_PARAM_locate_const(params, OSSL_EXCHANGE_PARAM_KDF_OUTLEN);