9362ed9e14
Compilers use a variant of Barrett reduction to divide by constants, which conveniently also avoids problematic operations on the secret numerator. Implement the variant as described here: http://ridiculousfish.com/blog/posts/labor-of-division-episode-i.html Repurpose this to implement a constant-time BN_mod_word replacement. It's even much faster! I've gone ahead and replaced the other BN_mod_word calls on the primes table. That should give plenty of budget for the other changes. (I am assuming that a regression is okay, as RSA keygen is not performance-sensitive, but that I should avoid anything too dramatic.) Proof of correctness: https://github.com/davidben/fiat-crypto/blob/barrett/src/Arithmetic/BarrettReduction/RidiculousFish.v Median of 29 RSA keygens: 0m0.621s -> 0m0.123s (Accuracy beyond 0.1s is questionable, though this particular improvement is quite solid.) Bug: 238 Change-Id: I67fa36ffe522365b13feb503c687b20d91e72932 Reviewed-on: https://boringssl-review.googlesource.com/25887 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 |