From 6253cdcc8ea7b0116a43ee596ac03e0b04b8b762 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Thu, 14 Jan 2021 15:53:08 +0100 Subject: kdf_exch.c (kdf_derive): Proper handling of NULL secret Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/13869) --- providers/implementations/exchange/kdf_exch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'providers/implementations/exchange') diff --git a/providers/implementations/exchange/kdf_exch.c b/providers/implementations/exchange/kdf_exch.c index c022a35107..43652faf50 100644 --- a/providers/implementations/exchange/kdf_exch.c +++ b/providers/implementations/exchange/kdf_exch.c @@ -95,7 +95,13 @@ static int kdf_derive(void *vpkdfctx, unsigned char *secret, size_t *secretlen, if (!ossl_prov_is_running()) return 0; - return EVP_KDF_derive(pkdfctx->kdfctx, secret, *secretlen); + + if (secret == NULL) { + *secretlen = EVP_KDF_CTX_get_kdf_size(pkdfctx->kdfctx); + return 1; + } + + return EVP_KDF_derive(pkdfctx->kdfctx, secret, outlen); } static void kdf_freectx(void *vpkdfctx) -- cgit v1.2.3