summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2003-11-30 22:02:10 +0000
committerGeoff Thorpe <geoff@openssl.org>2003-11-30 22:02:10 +0000
commit23fc5ac64685cd972e40475297858f6e68081f5e (patch)
tree98076968792de1138210943085fabed59f85f6d4
parent5734bebe05949bf1e7b94dcf225d297389347bb2 (diff)
downloadopenssl-new-23fc5ac64685cd972e40475297858f6e68081f5e.tar.gz
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.
-rw-r--r--crypto/bn/bn.h10
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))