Remove zero special-case in BN_mod_exp_mont.
authorDavid Benjamin <davidben@google.com>
Tue, 17 Jul 2018 17:20:28 +0000 (13:20 -0400)
committerDavid Benjamin <davidben@google.com>
Tue, 24 Jul 2018 15:48:48 +0000 (11:48 -0400)
A number intended to treat the base as secret should not be branching on
whether it is zero. Test-wise, this is covered by existing tests in bnmod.txt.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6733)

crypto/bn/bn_exp.c

index 4e24c94ad38d6722a285225fa32fcf6aad3a5472..2c92d7eac9d51257b6a82b74157d31862c3dfe7a 100644 (file)
@@ -356,11 +356,6 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
         aa = val[0];
     } else
         aa = a;
-    if (BN_is_zero(aa)) {
-        BN_zero(rr);
-        ret = 1;
-        goto err;
-    }
     if (!bn_to_mont_fixed_top(val[0], aa, mont, ctx))
         goto err;               /* 1 */