232a6be6f1
The extra details in Enhanced Rabin-Miller are only used in RSA_check_key_fips, on the public RSA modulus, which the static linker will drop in most of our consumers anyway. Implement normal Rabin-Miller for RSA keygen and use Montgomery reduction so it runs in constant-time. Note that we only need to avoid leaking information about the input if it's a large prime. If the number ends up composite, or we find it in our table of small primes, we can return immediately. The leaks not addressed by this CL are: - The difficulty of selecting |b| leaks information about |w|. - The distribution of whether step 4.4 runs leaks information about w. - We leak |a| (the largest power of two which divides w) everywhere. - BN_mod_word in the trial division is not constant-time. These will be resolved in follow-up changes. Median of 29 RSA keygens: 0m0.521 -> 0m0.621s (Accuracy beyond 0.1s is questionable.) Bug: 238 Change-Id: I0cf0ff22079732a0a3ababfe352bb4327e95b879 Reviewed-on: https://boringssl-review.googlesource.com/25886 Reviewed-by: Adam Langley <agl@google.com> |
||
---|---|---|
.. | ||
asm | ||
add.c | ||
bn_test_to_fuzzer.go | ||
bn_test.cc | ||
bn_tests.txt | ||
bn.c | ||
bytes.c | ||
check_bn_tests.go | ||
cmp.c | ||
ctx.c | ||
div.c | ||
exponentiation.c | ||
gcd.c | ||
generic.c | ||
internal.h | ||
jacobi.c | ||
montgomery_inv.c | ||
montgomery.c | ||
mul.c | ||
prime.c | ||
random.c | ||
rsaz_exp.c | ||
rsaz_exp.h | ||
shift.c | ||
sqrt.c |