From: tb Date: Tue, 9 Jul 2024 17:04:50 +0000 (+0000) Subject: Use better order in EVP_PKEY_CTRL_TLS_SECRET X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=90e978ad7d2a4c582d7124a4990a3c8a53d504a8;p=openbsd Use better order in EVP_PKEY_CTRL_TLS_SECRET Also avoid an unnecessary NULL check. --- diff --git a/lib/libcrypto/kdf/tls1_prf.c b/lib/libcrypto/kdf/tls1_prf.c index cefb3e2cad0..594537ca3f5 100644 --- a/lib/libcrypto/kdf/tls1_prf.c +++ b/lib/libcrypto/kdf/tls1_prf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls1_prf.c,v 1.30 2024/07/09 17:01:40 tb Exp $ */ +/* $OpenBSD: tls1_prf.c,v 1.31 2024/07/09 17:04:50 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project * 2016. @@ -119,15 +119,14 @@ pkey_tls1_prf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) case EVP_PKEY_CTRL_TLS_SECRET: if (p1 < 0) return 0; - if (kctx->secret != NULL) - freezero(kctx->secret, kctx->secret_len); - - explicit_bzero(kctx->seed, kctx->seed_len); - kctx->seed_len = 0; + freezero(kctx->secret, kctx->secret_len); kctx->secret = NULL; kctx->secret_len = 0; + explicit_bzero(kctx->seed, kctx->seed_len); + kctx->seed_len = 0; + if (p1 == 0 || p2 == NULL) return 0;