boringssl/crypto/fipsmodule/bn
David Benjamin 6bc18a3bd4 Add bn_mul_small and bn_sqr_small.
As part of excising BIGNUM from EC scalars, we will need a "words"
version of BN_mod_mul_montgomery. That, in turn, requires BN_sqr and
BN_mul for cases where we don't have bn_mul_mont.

BN_sqr and BN_mul have a lot of logic in there, with the most complex
cases being not even remotely constant time. Fortunately, those only
apply to RSA-sized numbers, not EC-sized numbers. (With the exception, I
believe, of 32-bit P-521 which just barely exceeds the cutoff.) Imposing
a limit also makes it easier to stack-allocate temporaries (BN_CTX
serves a similar purpose in BIGNUM).

Extract bn_mul_small and bn_sqr_small and test them as part of
bn_tests.txt. Later changes will build on these.

If we end up reusing these functions for RSA in the future (though that
would require tending to the egregiously non-constant-time code in the
no-asm build), we probably want to extract a version where there is an
explicit tmp parameter as in bn_sqr_normal rather than the stack bits.

Change-Id: If414981eefe12d6664ab2f5e991a359534aa7532
Reviewed-on: https://boringssl-review.googlesource.com/23068
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:22:30 +00:00
..
asm Const-correct some of the low-level BIGNUM functions. 2017-11-20 16:20:40 +00:00
add.c Clear no-op BN_MASK2 masks. 2017-10-27 02:38:45 +00:00
bn_test_to_fuzzer.go Generate bn_div and bn_mod_exp corpus from bn_tests.txt. 2017-10-27 18:57:48 +00:00
bn_test.cc Add bn_mul_small and bn_sqr_small. 2017-11-20 16:22:30 +00:00
bn_tests.txt Add bn_mul_small and bn_sqr_small. 2017-11-20 16:22:30 +00:00
bn.c Remove redundant calls to |OPENSSL_cleanse| and |OPENSSL_realloc_clean|. 2017-09-18 19:16:51 +00:00
bytes.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
check_bn_tests.go Move bn/ into crypto/fipsmodule/ 2017-05-01 22:51:25 +00:00
cmp.c Make BN_generate_dsa_nonce internally constant-time. 2017-11-20 16:18:30 +00:00
ctx.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
div.c Align |BN_div| with its documentation. 2017-11-06 22:55:30 +00:00
exponentiation.c Tidy up BN_mod_exp_mont. 2017-11-10 22:43:54 +00:00
gcd.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
generic.c Const-correct some of the low-level BIGNUM functions. 2017-11-20 16:20:40 +00:00
internal.h Add bn_mul_small and bn_sqr_small. 2017-11-20 16:22:30 +00:00
jacobi.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
montgomery_inv.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
montgomery.c Fix timing leak in BN_from_montgomery_word. 2017-11-20 16:18:09 +00:00
mul.c Add bn_mul_small and bn_sqr_small. 2017-11-20 16:22:30 +00:00
prime.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
random.c Make BN_generate_dsa_nonce internally constant-time. 2017-11-20 16:18:30 +00:00
rsaz_exp.c Move bn/ into crypto/fipsmodule/ 2017-05-01 22:51:25 +00:00
rsaz_exp.h Move bn/ into crypto/fipsmodule/ 2017-05-01 22:51:25 +00:00
shift.c Remove BN_TBIT. 2017-11-10 22:43:37 +00:00
sqrt.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00