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> |
||
---|---|---|
.. | ||
aes | ||
bn | ||
cipher | ||
des | ||
digest | ||
ec | ||
ecdsa | ||
hmac | ||
md4 | ||
md5 | ||
modes | ||
policydocs | ||
rand | ||
rsa | ||
self_check | ||
sha | ||
tls | ||
bcm.c | ||
CMakeLists.txt | ||
delocate.h | ||
FIPS.md | ||
intcheck1.png | ||
intcheck2.png | ||
intcheck3.png | ||
is_fips.c |