diff options
author | Geoff Thorpe <geoff@openssl.org> | 2003-11-06 23:24:44 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2003-11-06 23:24:44 +0000 |
commit | f75abcefed900d2b729223d87229da09924efd2a (patch) | |
tree | 9affdaf1b68c6cdb8ff1cd9f7bcbab4972bed86d /crypto/bn/bn.h | |
parent | 18f62d4b82cc3101f3e1ae026c5e077193cfca5b (diff) |
This extends the debugging macros to use "pollution" during
bn_correct_top(), previously only bn_check_top() did this.
Diffstat (limited to 'crypto/bn/bn.h')
-rw-r--r-- | crypto/bn/bn.h | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index a46fe842cf..326aeca9f9 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -617,15 +617,6 @@ BIGNUM *bn_dup_expand(const BIGNUM *a, int words); * defined. This not only improves external code, it provides more test * coverage for openssl's own code. */ -#define bn_correct_top(a) \ - { \ - BN_ULONG *ftl; \ - if ((a)->top > 0) \ - { \ - for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ - if (*(ftl--)) break; \ - } \ - } /* #define BN_DEBUG_RAND */ @@ -640,42 +631,54 @@ BIGNUM *bn_dup_expand(const BIGNUM *a, int words); int RAND_pseudo_bytes(unsigned char *buf,int num); #define BN_DEBUG_TRIX #endif -#define bn_check_top(a) \ +#define bn_pollute(a) \ do { \ - const BIGNUM *_tbignum = (a); \ - assert((_tbignum->top == 0) || \ - (_tbignum->d[_tbignum->top - 1] != 0)); \ - if(_tbignum->top < _tbignum->dmax) { \ + const BIGNUM *_bnum1 = (a); \ + if(_bnum1->top < _bnum1->dmax) { \ /* We cast away const without the compiler knowing, any \ * *genuinely* constant variables that aren't mutable \ * wouldn't be constructed with top!=dmax. */ \ BN_ULONG *_not_const; \ - memcpy(&_not_const, &_tbignum->d, sizeof(BN_ULONG*)); \ - RAND_pseudo_bytes((unsigned char *)(_not_const + _tbignum->top), \ - (_tbignum->dmax - _tbignum->top) * sizeof(BN_ULONG)); \ + memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ + RAND_pseudo_bytes((unsigned char *)(_not_const + _bnum1->top), \ + (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ } \ } while(0) #ifdef BN_DEBUG_TRIX #undef RAND_pseudo_bytes #endif -#else /* !BN_DEBUG_RAND */ +#else +#define bn_pollute(a) +#endif #define bn_check_top(a) \ do { \ - const BIGNUM *_tbignum = (a); \ - assert((_tbignum->top == 0) || \ - (_tbignum->d[_tbignum->top - 1] != 0)); \ + const BIGNUM *_bnum2 = (a); \ + assert((_bnum2->top == 0) || \ + (_bnum2->d[_bnum2->top - 1] != 0)); \ + bn_pollute(_bnum2); \ } while(0) -#endif #define bn_fix_top(a) bn_check_top(a) #else /* !BN_DEBUG */ +#define bn_pollute(a) #define bn_check_top(a) #define bn_fix_top(a) bn_correct_top(a) #endif +#define bn_correct_top(a) \ + { \ + BN_ULONG *ftl; \ + if ((a)->top > 0) \ + { \ + for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ + if (*(ftl--)) break; \ + } \ + bn_pollute(a); \ + } + BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); |