diff options
author | Geoff Thorpe <geoff@openssl.org> | 2003-11-30 22:23:12 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2003-11-30 22:23:12 +0000 |
commit | 46cb8d368965c07f760662a755b4248afc0087b8 (patch) | |
tree | ec2b6987bc755ca5c9d0d7344ae9333d2a2beeb8 /crypto/bn | |
parent | 23fc5ac64685cd972e40475297858f6e68081f5e (diff) |
If BN_STRICT is defined, don't accept an ambiguous representation of zero
(ie. where top may be zero, or it may be one if the corresponding word is
set to zero). Note, this only affects the macros in bn.h, there are probably
similar corrections required in some c files.
Also, clarify the audit-related macros at the top of the header. Mental
note: I must not forget to clean all this out before 0.9.8 is released ...
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index edf9c3ee75..5346a353ab 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -81,6 +81,22 @@ extern "C" { #endif +/* These preprocessor symbols control various aspects of the bignum headers and + * library code. They're not defined by any "normal" configuration, as they are + * intended for development and testing purposes. NB: defining all three can be + * useful for debugging application code as well as openssl itself. + * + * BN_DEBUG - turn on various debugging alterations to the bignum code + * BN_DEBUG_RAND - uses random poisoning of unused words to trip up + * mismanagement of bignum internals. You must also define BN_DEBUG. + * BN_STRICT - disables anything (not already caught by BN_DEBUG) that uses the + * old ambiguity over zero representation. At some point, this behaviour should + * become standard. + */ +/* #define BN_DEBUG */ +/* #define BN_DEBUG_RAND */ +/* #define BN_STRICT */ + #ifdef OPENSSL_SYS_VMS #undef BN_LLONG /* experimental, so far... */ #endif @@ -344,7 +360,11 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b); /* 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))) +#ifdef BN_STRICT +#define BN_is_zero(a) ((a)->top == 0) +#else #define BN_is_zero(a) BN_abs_is_word(a,0) +#endif #define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) #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)) @@ -618,8 +638,6 @@ BIGNUM *bn_dup_expand(const BIGNUM *a, int words); * coverage for openssl's own code. */ -/* #define BN_DEBUG_RAND */ - #ifdef BN_DEBUG /* We only need assert() when debugging */ |