summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/kdf/hkdf_evp.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/lib/libcrypto/kdf/hkdf_evp.c b/src/lib/libcrypto/kdf/hkdf_evp.c
index dd79665778..736208ded5 100644
--- a/src/lib/libcrypto/kdf/hkdf_evp.c
+++ b/src/lib/libcrypto/kdf/hkdf_evp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hkdf_evp.c,v 1.17 2022/05/05 19:46:36 tb Exp $ */ 1/* $OpenBSD: hkdf_evp.c,v 1.18 2022/05/05 19:48:06 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2016-2018 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2016-2018 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -120,11 +120,8 @@ pkey_hkdf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
120 if (p1 < 0) 120 if (p1 < 0)
121 return 0; 121 return 0;
122 122
123 if (kctx->salt != NULL) 123 freezero(kctx->salt, kctx->salt_len);
124 freezero(kctx->salt, kctx->salt_len); 124 if ((kctx->salt = malloc(p1)) == NULL)
125
126 kctx->salt = malloc(p1);
127 if (kctx->salt == NULL)
128 return 0; 125 return 0;
129 memcpy(kctx->salt, p2, p1); 126 memcpy(kctx->salt, p2, p1);
130 127
@@ -135,11 +132,8 @@ pkey_hkdf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
135 if (p1 <= 0) 132 if (p1 <= 0)
136 return 0; 133 return 0;
137 134
138 if (kctx->key != NULL) 135 freezero(kctx->key, kctx->key_len);
139 freezero(kctx->key, kctx->key_len); 136 if ((kctx->key = malloc(p1)) == NULL)
140
141 kctx->key = malloc(p1);
142 if (kctx->key == NULL)
143 return 0; 137 return 0;
144 memcpy(kctx->key, p2, p1); 138 memcpy(kctx->key, p2, p1);
145 139