summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/ecdh/ech_key.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ecdh/ech_key.c b/src/lib/libcrypto/ecdh/ech_key.c
index 1dfb3c0fa9..b364b31c88 100644
--- a/src/lib/libcrypto/ecdh/ech_key.c
+++ b/src/lib/libcrypto/ecdh/ech_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_key.c,v 1.20 2023/07/01 14:39:34 tb Exp $ */ 1/* $OpenBSD: ech_key.c,v 1.21 2023/07/01 14:48:01 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -98,8 +98,8 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
98 const BIGNUM *priv_key; 98 const BIGNUM *priv_key;
99 const EC_GROUP* group; 99 const EC_GROUP* group;
100 int ret = -1; 100 int ret = -1;
101 size_t buflen, len;
102 unsigned char *buf = NULL; 101 unsigned char *buf = NULL;
102 int buflen, len;
103 103
104 if (outlen > INT_MAX) { 104 if (outlen > INT_MAX) {
105 /* Sort of, anyway. */ 105 /* Sort of, anyway. */
@@ -156,9 +156,7 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
156 ECDHerror(ERR_R_MALLOC_FAILURE); 156 ECDHerror(ERR_R_MALLOC_FAILURE);
157 goto err; 157 goto err;
158 } 158 }
159 159 if (BN_bn2binpad(x, buf, buflen) != buflen) {
160 memset(buf, 0, buflen - len);
161 if (len != (size_t)BN_bn2bin(x, buf + buflen - len)) {
162 ECDHerror(ERR_R_BN_LIB); 160 ECDHerror(ERR_R_BN_LIB);
163 goto err; 161 goto err;
164 } 162 }