boringssl/crypto/bn
David Benjamin 0a211dfe91 Remove BN_FLG_CONSTTIME.
BN_FLG_CONSTTIME is a ridiculous API and easy to mess up
(CVE-2016-2178). Instead, code that needs a particular algorithm which
preserves secrecy of some arguemnt should call into that algorithm
directly.

This is never set outside the library and is finally unused within the
library! Credit for all this goes almost entirely to Brian Smith. I just
took care of the last bits.

Note there was one BN_FLG_CONSTTIME check that was still reachable, the
BN_mod_inverse in RSA key generation. However, it used the same code in
both cases for even moduli and φ(n) is even if n is not a power of two.
Traditionally, RSA keys are not powers of two, even though it would make
the modular reductions a lot easier.

When reviewing, check that I didn't remove a BN_FLG_CONSTTIME that led
to a BN_mod_exp(_mont) or BN_mod_inverse call (with the exception of the
RSA one mentioned above). They should all go to functions for the
algorithms themselves like BN_mod_exp_mont_consttime.

This CL shows the checks are a no-op for all our tests:
https://boringssl-review.googlesource.com/c/12927/

BUG=125

Change-Id: I19cbb375cc75aac202bd76b51ca098841d84f337
Reviewed-on: https://boringssl-review.googlesource.com/12926
Reviewed-by: Adam Langley <alangley@gmail.com>
2017-01-12 02:00:44 +00:00
..
asm Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
add.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
bn_asn1.c
bn_test.cc Remove BN_FLG_CONSTTIME. 2017-01-12 02:00:44 +00:00
bn_tests.txt Remove RSAZ-512. 2016-12-14 22:12:50 +00:00
bn.c Remove BN_FLG_CONSTTIME. 2017-01-12 02:00:44 +00:00
check_bn_tests.go Fix mixed comment markers. 2016-08-01 14:52:39 +00:00
CMakeLists.txt Remove rsaz-x86_64.pl from CMake inputs. 2016-12-19 08:39:37 -08:00
cmp.c
convert.c Add Little-endian BIGNUM conversions 2017-01-06 18:20:09 +00:00
ctx.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
div.c Remove the non-no_branch branch of BN_div. 2016-12-17 19:11:19 +00:00
exponentiation.c Remove BN_FLG_CONSTTIME. 2017-01-12 02:00:44 +00:00
gcd.c Remove BN_FLG_CONSTTIME. 2017-01-12 02:00:44 +00:00
generic.c Fix up macros. 2016-10-18 18:28:23 +00:00
internal.h Don't use BN_mod_inverse for inverses mod p in RSA keygen. 2017-01-04 13:56:11 +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 Remove BN_FLG_CONSTTIME. 2017-01-12 02:00:44 +00:00
mul.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
prime.c Add constants for BN_rand and use them. 2016-08-18 18:18:31 +00:00
random.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +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 Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
sqrt.c Check for BN_lshift failure in BN_sqrt. 2016-11-29 00:55:56 +00:00