summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index b792250fbc..89e2713a0f 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.75 2023/02/14 18:06:06 jsing Exp $ */ 1/* $OpenBSD: bn_lib.c,v 1.76 2023/02/14 18:22:35 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 *
@@ -252,7 +252,6 @@ BN_num_bits(const BIGNUM *a)
252{ 252{
253 int i = a->top - 1; 253 int i = a->top - 1;
254 254
255
256 if (BN_is_zero(a)) 255 if (BN_is_zero(a))
257 return 0; 256 return 0;
258 return ((i * BN_BITS2) + BN_num_bits_word(a->d[i])); 257 return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
@@ -917,9 +916,15 @@ BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
917} 916}
918 917
919int 918int
920BN_is_zero(const BIGNUM *a) 919BN_is_zero(const BIGNUM *bn)
921{ 920{
922 return a->top == 0; 921 BN_ULONG bits = 0;
922 int i;
923
924 for (i = 0; i < bn->top; i++)
925 bits |= bn->d[i];
926
927 return bits == 0;
923} 928}
924 929
925int 930int