X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fbn%2Fbn_gf2m.c;h=b2222a06c93f868ce8b1da6f90e170c59cf997af;hp=0bfb56971e3362eadbe248864dea15f30eefd6c6;hb=d3379de5a97e99bf97067a0ae408d7f55fa9bc5c;hpb=e166891e0dee83375ca1d3d6bc5c45207b556839 diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 0bfb56971e..b2222a06c9 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -631,8 +631,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);