boringssl/crypto/evp
David Benjamin ea52ec98a5 Perform the RSA CRT reductions with Montgomery reduction.
The first step of RSA with the CRT optimization is to reduce our input
modulo p and q. We can do this in constant-time[*] with Montgomery
reduction. When p and q are the same size, Montgomery reduction's bounds
hold. We need two rounds of it because the first round gives us an
unwanted R^-1.

This does not appear to have a measurable impact on performance. Also
add a long TODO describing how to make the rest of the function
constant-time[*] which hopefully we'll get to later. RSA blinding should
protect us from it all, but make this constant-time anyway.

Since this and the follow-up work will special-case weird keys, add a
test that we don't break those unintentionally. (Though I am not above
breaking them intentionally someday...)

Thanks to Andres Erbsen for discussions on how to do this bit properly.

[*] Ignoring the pervasive bn_correct_top problem for the moment.

Change-Id: Ide099a9db8249cb6549be99c5f8791a39692ea81
Reviewed-on: https://boringssl-review.googlesource.com/24204
Reviewed-by: Adam Langley <agl@google.com>
2017-12-18 18:59:18 +00:00
..
CMakeLists.txt Implement scrypt from RFC 7914. 2017-06-12 20:32:21 +00:00
digestsign.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
evp_asn1.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
evp_ctx.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
evp_extra_test.cc EVP_PKEY_cmp does not return a boolean. 2017-06-16 13:45:44 +00:00
evp_test.cc Print errors better in FileTestGTest. 2017-09-05 17:24:15 +00:00
evp_tests.txt Perform the RSA CRT reductions with Montgomery reduction. 2017-12-18 18:59:18 +00:00
evp.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
internal.h Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
p_dsa_asn1.c Use BN_mod_exp_mont_consttime in dsa_priv_decode. 2017-09-29 23:19:22 +00:00
p_ec_asn1.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
p_ec.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
p_ed25519_asn1.c Remove redundant calls to |OPENSSL_cleanse| and |OPENSSL_realloc_clean|. 2017-09-18 19:16:51 +00:00
p_ed25519.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
p_rsa_asn1.c Add some missing OpenSSL 1.1.0 accessors. 2017-11-22 18:43:38 +00:00
p_rsa.c Properly size_t EVP_PKEY_CTX_set0_rsa_oaep_label. 2017-09-05 15:26:45 +00:00
pbkdf_test.cc Convert various tests to GTest. 2017-05-23 22:34:09 +00:00
pbkdf.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
print.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
scrypt_test.cc Implement scrypt from RFC 7914. 2017-06-12 20:32:21 +00:00
scrypt_tests.txt Implement scrypt from RFC 7914. 2017-06-12 20:32:21 +00:00
scrypt.c Run the comment converter on libcrypto. 2017-08-18 21:49:04 +00:00
sign.c