From: Andy Polyakov Date: Fri, 30 Mar 2012 17:40:52 +0000 (+0000) Subject: bn/bn_gf2m.c: make new BN_GF2m_mod_inv work with BN_DEBUG_RAND [from HEAD]. X-Git-Tag: OpenSSL_1_0_1a~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a5575f3f6db134589423075fa5a37a1e1353306;p=openssl bn/bn_gf2m.c: make new BN_GF2m_mod_inv work with BN_DEBUG_RAND [from HEAD]. --- diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 08ab9fd227..8a4dc20ad9 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -628,8 +628,11 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) } if (ubits==vbits) { - bn_correct_top(u); - ubits = BN_num_bits(u); + BN_ULONG ul; + int utop = (ubits-1)/BN_BITS2; + + while ((ul=udp[utop])==0 && utop) utop--; + ubits = utop*BN_BITS2 + BN_num_bits_word(ul); } } bn_correct_top(b);