From: Andy Polyakov Date: Fri, 29 Jun 2007 13:15:33 +0000 (+0000) Subject: bn_mont.c fix [from HEAD]. X-Git-Tag: FIPS_098_TEST_1~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=899f528c1afd8ede117245fa6799911d97654120;p=oweals%2Fopenssl.git bn_mont.c fix [from HEAD]. --- diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index bf45fe916d..30bdeabcd5 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -246,32 +246,26 @@ int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont, rp=ret->d; ap=&(r->d[ri]); - nrp=ap; - /* This 'if' denotes violation of 2*MN.d[ri-1]>>(BN_BITS2-2))!=0) - { - size_t m1,m2; - - v=bn_sub_words(rp,ap,mont->N.d,ri); - /* this -----------------------^^ works even in alri) nrp=rp; else nrp=ap; */ - /* in other words if subtraction result is real, then - * trick unconditional memcpy below to perform in-place - * "refresh" instead of actual copy. */ - m1=0-(size_t)(((al-ri)>>(sizeof(al)*8-1))&1); /* al>(sizeof(al)*8-1))&1); /* al>ri */ - m1|=m2; /* (al!=ri) */ - m1|=(0-(size_t)v); /* (al!=ri || v) */ - m1&=~m2; /* (al!=ri || v) && !al>ri */ - nrp=(BN_ULONG *)(((size_t)rp&~m1)|((size_t)ap&m1)); - } + { + size_t m1,m2; + + v=bn_sub_words(rp,ap,np,ri); + /* this ----------------^^ works even in alri) nrp=rp; else nrp=ap; */ + /* in other words if subtraction result is real, then + * trick unconditional memcpy below to perform in-place + * "refresh" instead of actual copy. */ + m1=0-(size_t)(((al-ri)>>(sizeof(al)*8-1))&1); /* al>(sizeof(al)*8-1))&1); /* al>ri */ + m1|=m2; /* (al!=ri) */ + m1|=(0-(size_t)v); /* (al!=ri || v) */ + m1&=~m2; /* (al!=ri || v) && !al>ri */ + nrp=(BN_ULONG *)(((size_t)rp&~m1)|((size_t)ap&m1)); + } /* 'i