aboutsummaryrefslogtreecommitdiff
path: root/providers/implementations/exchange
diff options
context:
space:
mode:
authorx2018 <xkernel.wang@foxmail.com>2021-11-29 15:32:47 +0800
committerTomas Mraz <tomas@openssl.org>2022-11-09 15:30:08 +0100
commitea578b6553b178e1ae2448eab175fce81da07987 (patch)
tree44476066b207032621b4f6c01c7c7eebff3e178f /providers/implementations/exchange
parent9316125febb5351c1ec791fe173fa42c20aac98a (diff)
downloadopenssl-ea578b6553b178e1ae2448eab175fce81da07987.zip
openssl-ea578b6553b178e1ae2448eab175fce81da07987.tar.gz
openssl-ea578b6553b178e1ae2448eab175fce81da07987.tar.bz2
check the return value of EVP_MD_fetch in ecdh_exch.c:285 & dh_exch.c:347
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17153) (cherry picked from commit 04e3ab64d58bb43efc4392d12c607bb4b5a2c562)
Diffstat (limited to 'providers/implementations/exchange')
-rw-r--r--providers/implementations/exchange/dh_exch.c5
-rw-r--r--providers/implementations/exchange/ecdh_exch.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/providers/implementations/exchange/dh_exch.c b/providers/implementations/exchange/dh_exch.c
index 1d8a2e2..dd5254f 100644
--- a/providers/implementations/exchange/dh_exch.c
+++ b/providers/implementations/exchange/dh_exch.c
@@ -351,12 +351,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 35d665f..030f2e2 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);