summaryrefslogtreecommitdiff
path: root/lib/libcrypto/kdf
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-07-09 17:44:19 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-07-09 17:44:19 +0000
commit7bdc4cf1a7796520aa07b949d70d4bb26a2b0e8b (patch)
tree3d324f608b3fd7f6d4a0385c58f4bf7c9f13c50d /lib/libcrypto/kdf
parent769ccd9b513d5b62200156a47785d216632a26e5 (diff)
Align math with t1_enc.c
suggested by jsing on review
Diffstat (limited to 'lib/libcrypto/kdf')
-rw-r--r--lib/libcrypto/kdf/tls1_prf.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libcrypto/kdf/tls1_prf.c b/lib/libcrypto/kdf/tls1_prf.c
index e28962da2e4..afc629b708f 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.34 2024/07/09 17:35:55 tb Exp $ */
+/* $OpenBSD: tls1_prf.c,v 1.35 2024/07/09 17:44:18 tb Exp $ */
/*
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2016.
@@ -265,23 +265,25 @@ tls1_prf_alg(const EVP_MD *md,
unsigned char *out, size_t out_len)
{
unsigned char *tmp;
+ size_t half_len;
size_t i;
if (EVP_MD_type(md) != NID_md5_sha1)
return tls1_prf_P_hash(md, secret, secret_len, seed, seed_len,
out, out_len);
- if (!tls1_prf_P_hash(EVP_md5(),
- secret, secret_len / 2 + (secret_len & 1),
- seed, seed_len, out, out_len))
+ half_len = secret_len - secret_len / 2;
+ if (!tls1_prf_P_hash(EVP_md5(), secret, half_len, seed, seed_len,
+ out, out_len))
return 0;
if ((tmp = calloc(1, out_len)) == NULL) {
KDFerror(ERR_R_MALLOC_FAILURE);
return 0;
}
- if (!tls1_prf_P_hash(EVP_sha1(), secret + secret_len / 2,
- secret_len / 2 + (secret_len & 1), seed, seed_len, tmp, out_len)) {
+ secret += secret_len - half_len;
+ if (!tls1_prf_P_hash(EVP_sha1(), secret, half_len, seed, seed_len,
+ tmp, out_len)) {
freezero(tmp, out_len);
return 0;
}