From 4afcee8b4b9d2837796d4f663086eb5a99bb7204 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bodo=20M=C3=B6ller?= Date: Mon, 23 Jun 2008 20:46:28 +0000 Subject: [PATCH] avoid potential infinite loop in final reduction round of BN_GF2m_mod_arr() Submitted by: Huang Ying Reviewed by: Douglas Stebila --- CHANGES | 6 +++++- crypto/bn/bn_gf2m.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 826a29e666..b78c8d1012 100644 --- a/CHANGES +++ b/CHANGES @@ -4,12 +4,16 @@ Changes between 0.9.8h and 0.9.8i [xx XXX xxxx] + *) Fix BN_GF2m_mod_arr() top-bit cleanup code. + [Huang Ying] + *) Expand ENGINE to support engine supplied SSL client certificate functions. This work was sponsored by Logica. [Steve Henson] - *) Add CryptoAPI ENGINE to support use of RSA and DSA keys held in Windows keystores. Support for SSL/TLS client authentication too. + *) Add CryptoAPI ENGINE to support use of RSA and DSA keys held in Windows + keystores. Support for SSL/TLS client authentication too. Not compiled unless enable-capieng specified to Configure. This work was sponsored by Logica. diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 6a793857e1..306f029f27 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -384,7 +384,11 @@ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned 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++) -- 2.25.1