summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/kdf/tls1_prf.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/libcrypto/kdf/tls1_prf.c b/src/lib/libcrypto/kdf/tls1_prf.c
index e28962da2e..afc629b708 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.34 2024/07/09 17:35:55 tb Exp $ */ 1/* $OpenBSD: tls1_prf.c,v 1.35 2024/07/09 17:44:18 tb 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.
@@ -265,23 +265,25 @@ tls1_prf_alg(const EVP_MD *md,
265 unsigned char *out, size_t out_len) 265 unsigned char *out, size_t out_len)
266{ 266{
267 unsigned char *tmp; 267 unsigned char *tmp;
268 size_t half_len;
268 size_t i; 269 size_t i;
269 270
270 if (EVP_MD_type(md) != NID_md5_sha1) 271 if (EVP_MD_type(md) != NID_md5_sha1)
271 return tls1_prf_P_hash(md, secret, secret_len, seed, seed_len, 272 return tls1_prf_P_hash(md, secret, secret_len, seed, seed_len,
272 out, out_len); 273 out, out_len);
273 274
274 if (!tls1_prf_P_hash(EVP_md5(), 275 half_len = secret_len - secret_len / 2;
275 secret, secret_len / 2 + (secret_len & 1), 276 if (!tls1_prf_P_hash(EVP_md5(), secret, half_len, seed, seed_len,
276 seed, seed_len, out, out_len)) 277 out, out_len))
277 return 0; 278 return 0;
278 279
279 if ((tmp = calloc(1, out_len)) == NULL) { 280 if ((tmp = calloc(1, out_len)) == NULL) {
280 KDFerror(ERR_R_MALLOC_FAILURE); 281 KDFerror(ERR_R_MALLOC_FAILURE);
281 return 0; 282 return 0;
282 } 283 }
283 if (!tls1_prf_P_hash(EVP_sha1(), secret + secret_len / 2, 284 secret += secret_len - half_len;
284 secret_len / 2 + (secret_len & 1), seed, seed_len, tmp, out_len)) { 285 if (!tls1_prf_P_hash(EVP_sha1(), secret, half_len, seed, seed_len,
286 tmp, out_len)) {
285 freezero(tmp, out_len); 287 freezero(tmp, out_len);
286 return 0; 288 return 0;
287 } 289 }