boringssl/crypto/bn
Brian Smith 16bfff7169 Calculate Montgomery RR without division.
Get one step closer to removing the dependency on |BN_div| from most
programs. Also get one step closer to a constant-time implementation of
|BN_MONT_CTX_set|; we now "just" need to create a constant-time variant
of |BN_mod_lshift1_quick|.

Note that this version might actually increase the side channel signal,
since the variance in timing in |BN_div| is probably less than the variance
from the many conditional reductions in the new method.

On one Windows x64 machine, the speed of RSA verification using the new
version is not too different from the speed of the old code. However,
|BN_div| is generally slow on Windows x64 so I expect this isn't faster
on all platforms. Regardless, we generally consider ECDSA/EdDSA
signature verification performance to be adaquate and RSA signature
verification is much, much faster even with this change.

For RSA signing the performance is not a significant factor since
performance-sensitive applications will cache the |RSA| structure and
the |RSA| structure will cache the Montgomery contexts.

Change-Id: Ib14f1a35c99b8da435e190342657f6a839381a1a
Reviewed-on: https://boringssl-review.googlesource.com/10520
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2016-12-16 17:41:01 +00:00
..
asm Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
add.c Switch unrolled loop in BN_usub with memcpy. 2015-12-16 17:38:48 +00:00
bn_asn1.c Rename the BIGNUM ASN.1 functions. 2016-01-27 22:37:44 +00:00
bn_test.cc Test that BN_mod_sqrt detects quadratic non-residues. 2016-11-29 00:24:43 +00:00
bn_tests.txt Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
bn.c Add BN_set_u64. 2016-09-18 20:12:25 +00:00
check_bn_tests.go Fix mixed comment markers. 2016-08-01 14:52:39 +00:00
CMakeLists.txt Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
cmp.c Add BN_rand_range_ex and use internally. 2016-07-29 16:09:26 +00:00
convert.c Use C99 for size_t loops. 2016-09-12 19:44:24 +00:00
ctx.c Remove the func parameter to OPENSSL_PUT_ERROR. 2015-07-16 02:02:37 +00:00
div.c Fix some more negative zeros and add tests for each case. 2016-11-16 19:20:27 +00:00
exponentiation.c Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
gcd.c Don't add ERR_R_INTERNAL_ERROR to BN_R_NO_INVERSE. 2016-08-18 18:14:21 +00:00
generic.c Fix up macros. 2016-10-18 18:28:23 +00:00
internal.h Calculate Montgomery RR without division. 2016-12-16 17:41:01 +00:00
kronecker.c Fix BN_kronecker on unreachable BN_rshift error. 2016-12-12 21:40:20 +00:00
montgomery_inv.c Calculate Montgomery RR without division. 2016-12-16 17:41:01 +00:00
montgomery.c Calculate Montgomery RR without division. 2016-12-16 17:41:01 +00:00
mul.c Make local functions static. 2016-03-20 16:37:58 +00:00
prime.c Add constants for BN_rand and use them. 2016-08-18 18:18:31 +00:00
random.c Add constants for BN_rand and use them. 2016-08-18 18:18:31 +00:00
rsaz_exp.c Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
rsaz_exp.h Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
shift.c Fix some more negative zeros and add tests for each case. 2016-11-16 19:20:27 +00:00
sqrt.c Check for BN_lshift failure in BN_sqrt. 2016-11-29 00:55:56 +00:00