diff options
author | Geoff Thorpe <geoff@openssl.org> | 2003-11-30 23:02:10 +0100 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2003-11-30 23:02:10 +0100 |
commit | 23fc5ac64685cd972e40475297858f6e68081f5e (patch) | |
tree | 98076968792de1138210943085fabed59f85f6d4 /crypto/bn | |
parent | Make BN_DEBUG_RAND less painfully slow by only consuming one byte of (diff) | |
download | openssl-23fc5ac64685cd972e40475297858f6e68081f5e.tar.xz openssl-23fc5ac64685cd972e40475297858f6e68081f5e.zip |
Improve a couple of the bignum macros. Note, this doesn't eliminate
tolerance of ambiguous zero-representation, it just improves
BN_abs_is_word() and simplifies other macros that depend on it.
Diffstat (limited to '')
-rw-r--r-- | crypto/bn/bn.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index 5f16fbad00..edf9c3ee75 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -341,12 +341,12 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); #define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) -/* Note that BN_abs_is_word does not work reliably for w == 0 */ -#define BN_abs_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) -#define BN_is_zero(a) (((a)->top == 0) || BN_abs_is_word(a,0)) +/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */ +#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \ + (((w) == 0) && ((a)->top == 0))) +#define BN_is_zero(a) BN_abs_is_word(a,0) #define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) -#define BN_is_word(a,w) ((w) ? BN_abs_is_word((a),(w)) && !(a)->neg : \ - BN_is_zero((a))) +#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg)) #define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) #define BN_one(a) (BN_set_word((a),1)) |