diff options
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn.h | 6 | ||||
-rw-r--r-- | crypto/bn/bn_div.c | 9 | ||||
-rw-r--r-- | crypto/bn/bn_gcd.c | 3 | ||||
-rw-r--r-- | crypto/bn/bn_recp.c | 4 | ||||
-rw-r--r-- | crypto/bn/bn_sqr.c | 4 |
5 files changed, 12 insertions, 14 deletions
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index b990ff2b5d..2688684b63 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -699,9 +699,11 @@ int RAND_pseudo_bytes(unsigned char *buf,int num); #define bn_check_top(a) \ do { \ const BIGNUM *_bnum2 = (a); \ - assert((_bnum2->top == 0) || \ + if (_bnum2 != NULL) { \ + assert((_bnum2->top == 0) || \ (_bnum2->d[_bnum2->top - 1] != 0)); \ - bn_pollute(_bnum2); \ + bn_pollute(_bnum2); \ + } \ } while(0) #define bn_fix_top(a) bn_check_top(a) diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index 3b4392955e..2857f44861 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -185,10 +185,8 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, BN_ULONG d0,d1; int num_n,div_n; - if (dv) - bn_check_top(dv); - if (rm) - bn_check_top(rm); + bn_check_top(dv); + bn_check_top(rm); bn_check_top(num); bn_check_top(divisor); @@ -394,8 +392,7 @@ X) -> 0x%08X\n", BN_CTX_end(ctx); return(1); err: - if (rm) - bn_check_top(rm); + bn_check_top(rm); BN_CTX_end(ctx); return(0); } diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index 0248753f6d..f02e6fcdb4 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -488,7 +488,6 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, err: if ((ret == NULL) && (in == NULL)) BN_free(R); BN_CTX_end(ctx); - if (ret) - bn_check_top(ret); + bn_check_top(ret); return(ret); } diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index 10fe869d28..2e8efb8dae 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -204,8 +204,8 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, ret=1; err: BN_CTX_end(ctx); - if(dv) bn_check_top(dv); - if(rem) bn_check_top(rem); + bn_check_top(dv); + bn_check_top(rem); return(ret); } diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c index 3b4b3f0d38..270d0cd348 100644 --- a/crypto/bn/bn_sqr.c +++ b/crypto/bn/bn_sqr.c @@ -148,8 +148,8 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) if (rr != r) BN_copy(r,rr); ret = 1; err: - if(rr) bn_check_top(rr); - if(tmp) bn_check_top(tmp); + bn_check_top(rr); + bn_check_top(tmp); BN_CTX_end(ctx); return(ret); } |