diff options
author | kenjiro <> | 2025-05-21 03:53:20 +0000 |
---|---|---|
committer | kenjiro <> | 2025-05-21 03:53:20 +0000 |
commit | 18e1dba89cc7fe8fb5c145d47d93bef24f4caa35 (patch) | |
tree | 780bf80ce8f6bacfb3f6997c28e6a7d1f82cf725 /src/lib/libcrypto/kdf/tls1_prf.c | |
parent | a2c4e19629c138b7c4c868e4ddecb2717254f869 (diff) | |
download | openbsd-18e1dba89cc7fe8fb5c145d47d93bef24f4caa35.tar.gz openbsd-18e1dba89cc7fe8fb5c145d47d93bef24f4caa35.tar.bz2 openbsd-18e1dba89cc7fe8fb5c145d47d93bef24f4caa35.zip |
Add NULL checks to HKDF and TLS1-PRF EVP_PKEY cleanup functions
Check if ctx->data is NULL before calling freezero(). Also add
HKDF and TLS1-PRF to the EVP_PKEY cleanup regression test, as
they no longer crash with this change.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/kdf/tls1_prf.c')
-rw-r--r-- | src/lib/libcrypto/kdf/tls1_prf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/libcrypto/kdf/tls1_prf.c b/src/lib/libcrypto/kdf/tls1_prf.c index fb7b718339..2b86ff744f 100644 --- a/src/lib/libcrypto/kdf/tls1_prf.c +++ b/src/lib/libcrypto/kdf/tls1_prf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls1_prf.c,v 1.41 2025/05/10 05:54:38 tb Exp $ */ | 1 | /* $OpenBSD: tls1_prf.c,v 1.42 2025/05/21 03:53:20 kenjiro Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project |
4 | * 2016. | 4 | * 2016. |
@@ -96,6 +96,9 @@ pkey_tls1_prf_cleanup(EVP_PKEY_CTX *ctx) | |||
96 | { | 96 | { |
97 | struct tls1_prf_ctx *kctx = ctx->data; | 97 | struct tls1_prf_ctx *kctx = ctx->data; |
98 | 98 | ||
99 | if (kctx == NULL) | ||
100 | return; | ||
101 | |||
99 | freezero(kctx->secret, kctx->secret_len); | 102 | freezero(kctx->secret, kctx->secret_len); |
100 | freezero(kctx, sizeof(*kctx)); | 103 | freezero(kctx, sizeof(*kctx)); |
101 | } | 104 | } |