diff options
author | Bodo Möller <bodo@openssl.org> | 2008-06-23 20:46:24 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2008-06-23 20:46:24 +0000 |
commit | 8228fd89fc63ea766529075ac25628c47d4d5546 (patch) | |
tree | d722c78363efaea355a99af41fec28ce563ec18e /crypto/bn/bn_gf2m.c | |
parent | 869eb9e767a4b7902e0e481c2a3f55504be48f56 (diff) | |
download | openssl-new-8228fd89fc63ea766529075ac25628c47d4d5546.tar.gz |
avoid potential infinite loop in final reduction round of BN_GF2m_mod_arr()
Submitted by: Huang Ying
Reviewed by: Douglas Stebila
Diffstat (limited to 'crypto/bn/bn_gf2m.c')
-rw-r--r-- | crypto/bn/bn_gf2m.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index be409e1187..f7551dacd9 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -322,7 +322,11 @@ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]) if (zz == 0) break; d1 = BN_BITS2 - d0; - if (d0) z[dN] = (z[dN] << d1) >> d1; /* clear up the top d1 bits */ + /* clear up the top d1 bits */ + if (d0) + z[dN] = (z[dN] << d1) >> d1; + else + z[dN] = 0; z[0] ^= zz; /* reduction t^0 component */ for (k = 1; p[k] != 0; k++) |