diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 15 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_local.h | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 6988a70f3b..72b988650c 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.92 2024/04/16 13:04:05 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.93 2024/04/16 13:07:14 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 | * |
@@ -232,6 +232,19 @@ bn_expand_bits(BIGNUM *bn, size_t bits) | |||
232 | } | 232 | } |
233 | 233 | ||
234 | int | 234 | int |
235 | bn_expand_bytes(BIGNUM *bn, size_t bytes) | ||
236 | { | ||
237 | int words; | ||
238 | |||
239 | if (bytes > (INT_MAX - BN_BYTES + 1)) | ||
240 | return 0; | ||
241 | |||
242 | words = (bytes + BN_BYTES - 1) / BN_BYTES; | ||
243 | |||
244 | return bn_wexpand(bn, words); | ||
245 | } | ||
246 | |||
247 | int | ||
235 | bn_wexpand(BIGNUM *bn, int words) | 248 | bn_wexpand(BIGNUM *bn, int words) |
236 | { | 249 | { |
237 | if (words < 0) | 250 | if (words < 0) |
diff --git a/src/lib/libcrypto/bn/bn_local.h b/src/lib/libcrypto/bn/bn_local.h index cffc5a2ea1..58b5d54903 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.42 2024/04/16 13:04:05 jsing Exp $ */ | 1 | /* $OpenBSD: bn_local.h,v 1.43 2024/04/16 13:07:14 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 | * |
@@ -260,6 +260,7 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, | |||
260 | 260 | ||
261 | void bn_correct_top(BIGNUM *a); | 261 | void bn_correct_top(BIGNUM *a); |
262 | int bn_expand_bits(BIGNUM *a, size_t bits); | 262 | int bn_expand_bits(BIGNUM *a, size_t bits); |
263 | int bn_expand_bytes(BIGNUM *a, size_t bytes); | ||
263 | int bn_wexpand(BIGNUM *a, int words); | 264 | int bn_wexpand(BIGNUM *a, int words); |
264 | 265 | ||
265 | BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, | 266 | BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, |