From e0ae249f035b31b270883690522eae0775a8bbd9 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 10 Apr 2018 15:42:23 -0400 Subject: [PATCH] Remove a = 0 special-case in BN_mod_exp_mont. BN_mod_exp_mont is intended to protect the base, but not the exponent. Accordingly, it shouldn't treat a base of zero as special. Change-Id: Ib053e8ce65ab1741973a9f9bfeff8c353567439c Reviewed-on: https://boringssl-review.googlesource.com/27284 Reviewed-by: Adam Langley --- crypto/fipsmodule/bn/exponentiation.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crypto/fipsmodule/bn/exponentiation.c b/crypto/fipsmodule/bn/exponentiation.c index c85c00b1..12bc6e80 100644 --- a/crypto/fipsmodule/bn/exponentiation.c +++ b/crypto/fipsmodule/bn/exponentiation.c @@ -639,12 +639,6 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, aa = a; } - if (BN_is_zero(aa)) { - BN_zero(rr); - ret = 1; - goto err; - } - // We exponentiate by looking at sliding windows of the exponent and // precomputing powers of |aa|. Windows may be shifted so they always end on a // set bit, so only precompute odd powers. We compute val[i] = aa^(2*i + 1)