From: Geoff Thorpe Date: Tue, 2 Dec 2003 03:28:24 +0000 (+0000) Subject: Use the BN_is_odd() macro in place of code that (inconsistently) does much X-Git-Tag: BEN_FIPS_TEST_5~13^2~23 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=82b2f57e30e1348edc620855ed0999cbb50f1d52;p=oweals%2Fopenssl.git Use the BN_is_odd() macro in place of code that (inconsistently) does much the same thing. Also, I have some stuff on the back-burner related to some BN_CTX notes from Peter Gutmann about his cryptlib hacks to the bignum code. The BN_CTX comments are there to remind me of some relevant points in the code. --- diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index 462d4dbc43..aef77cb792 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -361,6 +361,7 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, int start=1,ts=0; BIGNUM *d,*r; const BIGNUM *aa; + /* TODO: BN_CTX??? */ BIGNUM val[TABLE_SIZE]; BN_MONT_CTX *mont=NULL; @@ -368,7 +369,7 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, bn_check_top(p); bn_check_top(m); - if (!(m->d[0] & 1)) + if (!BN_is_odd(m)) { BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS); return(0); @@ -524,7 +525,7 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, bn_check_top(p); bn_check_top(m); - if (m->top == 0 || !(m->d[0] & 1)) + if (!BN_is_odd(m)) { BNerr(BN_F_BN_MOD_EXP_MONT_WORD,BN_R_CALLED_WITH_EVEN_MODULUS); return(0); @@ -640,13 +641,13 @@ err: /* The old fallback, simple version :-) */ -int BN_mod_exp_simple(BIGNUM *r, - const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx) +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx) { int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0; int start=1; BIGNUM *d; + /* TODO: BN_CTX?? */ BIGNUM val[TABLE_SIZE]; bits=BN_num_bits(p); diff --git a/crypto/bn/bn_exp2.c b/crypto/bn/bn_exp2.c index 3bf7dafeee..979ceeffce 100644 --- a/crypto/bn/bn_exp2.c +++ b/crypto/bn/bn_exp2.c @@ -123,6 +123,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, int r_is_one=1,ts1=0,ts2=0; BIGNUM *d,*r; const BIGNUM *a_mod_m; + /* TODO: BN_CTX??? */ BIGNUM val1[TABLE_SIZE], val2[TABLE_SIZE]; BN_MONT_CTX *mont=NULL;