summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_convert.c6
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c7
-rw-r--r--src/lib/libcrypto/bn/bn_local.h4
3 files changed, 7 insertions, 10 deletions
diff --git a/src/lib/libcrypto/bn/bn_convert.c b/src/lib/libcrypto/bn/bn_convert.c
index f09c9091e7..60075e53ed 100644
--- a/src/lib/libcrypto/bn/bn_convert.c
+++ b/src/lib/libcrypto/bn/bn_convert.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_convert.c,v 1.15 2023/07/09 18:37:58 tb Exp $ */ 1/* $OpenBSD: bn_convert.c,v 1.16 2024/04/16 13:04:05 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -431,7 +431,7 @@ bn_dec2bn_cbs(BIGNUM **bnp, CBS *cbs)
431 bn = BN_new(); 431 bn = BN_new();
432 if (bn == NULL) 432 if (bn == NULL)
433 goto err; 433 goto err;
434 if (!bn_expand(bn, digits * 4)) 434 if (!bn_expand_bits(bn, digits * 4))
435 goto err; 435 goto err;
436 436
437 if ((d = digits % BN_DEC_NUM) == 0) 437 if ((d = digits % BN_DEC_NUM) == 0)
@@ -628,7 +628,7 @@ bn_hex2bn_cbs(BIGNUM **bnp, CBS *cbs)
628 bn = BN_new(); 628 bn = BN_new();
629 if (bn == NULL) 629 if (bn == NULL)
630 goto err; 630 goto err;
631 if (!bn_expand(bn, digits * 4)) 631 if (!bn_expand_bits(bn, digits * 4))
632 goto err; 632 goto err;
633 633
634 if (!CBS_get_bytes(cbs, cbs, digits)) 634 if (!CBS_get_bytes(cbs, cbs, digits))
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index b59e65a1e1..6988a70f3b 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_lib.c,v 1.91 2024/04/15 14:35:25 jsing Exp $ */ 1/* $OpenBSD: bn_lib.c,v 1.92 2024/04/16 13:04:05 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -219,13 +219,10 @@ bn_expand_internal(BIGNUM *bn, int words)
219} 219}
220 220
221int 221int
222bn_expand(BIGNUM *bn, int bits) 222bn_expand_bits(BIGNUM *bn, size_t bits)
223{ 223{
224 int words; 224 int words;
225 225
226 if (bits < 0)
227 return 0;
228
229 if (bits > (INT_MAX - BN_BITS2 + 1)) 226 if (bits > (INT_MAX - BN_BITS2 + 1))
230 return 0; 227 return 0;
231 228
diff --git a/src/lib/libcrypto/bn/bn_local.h b/src/lib/libcrypto/bn/bn_local.h
index 2c82e323fa..cffc5a2ea1 100644
--- a/src/lib/libcrypto/bn/bn_local.h
+++ b/src/lib/libcrypto/bn/bn_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_local.h,v 1.41 2024/04/10 15:09:03 tb Exp $ */ 1/* $OpenBSD: bn_local.h,v 1.42 2024/04/16 13:04:05 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -259,7 +259,7 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
259 const BN_ULONG *np, const BN_ULONG *n0, int num); 259 const BN_ULONG *np, const BN_ULONG *n0, int num);
260 260
261void bn_correct_top(BIGNUM *a); 261void bn_correct_top(BIGNUM *a);
262int bn_expand(BIGNUM *a, int bits); 262int bn_expand_bits(BIGNUM *a, size_t bits);
263int bn_wexpand(BIGNUM *a, int words); 263int bn_wexpand(BIGNUM *a, int words);
264 264
265BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, 265BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,