openssl/crypto/bn
Matt Caswell fd7d252060 Tighten up BN_with_flags usage and avoid a reachable assert
The function rsa_ossl_mod_exp uses the function BN_with_flags to create a
temporary copy (local_r1) of a BIGNUM (r1) with modified flags. This
temporary copy shares some state with the original r1. If the state of r1
gets updated then local_r1's state will be stale. This was occurring in the
function so that when local_r1 was freed a call to bn_check_top was made
which failed an assert due to the stale state. To resolve this we must free
local_r1 immediately after we have finished using it and not wait until the
end of the function.

This problem prompted a review of all BN_with_flag usage within the
codebase. All other usage appears to be correct, although often not
obviously so. This commit refactors things to make it much clearer for
these other uses.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-11-26 10:20:36 +00:00
..
asm x86_64 assembly pack: tune clang version detection. 2015-11-23 16:00:06 +01:00
bn_add.c BN_usub: Don't copy when r and a the same 2015-11-20 22:29:53 +01:00
bn_asm.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_blind.c Add and use OPENSSL_zalloc 2015-09-02 22:05:37 -04:00
bn_const.c Run util/openssl-format-source -v -c . 2015-01-22 09:20:09 +00:00
bn_ctx.c Continue standardising malloc style for libcrypto 2015-11-09 22:48:41 +00:00
bn_depr.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_dh.c Fix undeclared variable warnings. 2015-10-24 16:42:51 +01:00
bn_div.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_err.c Rebuild error source files. 2015-11-05 15:48:37 +00:00
bn_exp2.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_exp.c BN_mod_exp_mont_consttime: check for zero modulus. 2015-08-31 19:25:59 +02:00
bn_gcd.c Tighten up BN_with_flags usage and avoid a reachable assert 2015-11-26 10:20:36 +00:00
bn_gf2m.c BN_GF2m_mod_inv(): check bn_wexpand return value 2015-10-29 20:34:24 +01:00
bn_intern.c Continue standardising malloc style for libcrypto 2015-11-09 22:48:41 +00:00
bn_kron.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_lcl.h Replace "SSLeay" in API with OpenSSL 2015-10-30 17:21:42 -04:00
bn_lib.c Tighten up BN_with_flags usage and avoid a reachable assert 2015-11-26 10:20:36 +00:00
bn_mod.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_mont.c Continue standardising malloc style for libcrypto 2015-11-09 22:48:41 +00:00
bn_mpi.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_mul.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_nist.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_prime.c RT3955: Reduce some stack usage 2015-09-05 17:40:48 -04:00
bn_prime.h Replace "SSLeay" in API with OpenSSL 2015-10-30 17:21:42 -04:00
bn_prime.pl Replace "SSLeay" in API with OpenSSL 2015-10-30 17:21:42 -04:00
bn_print.c Fix off-by-one error in BN_bn2hex 2015-06-04 09:23:02 +01:00
bn_rand.c Continue standardising malloc style for libcrypto 2015-11-09 22:48:41 +00:00
bn_recp.c Fix memory leaks and other mistakes on errors 2015-10-23 19:52:08 +02:00
bn_shift.c Reject negative shifts for BN_rshift and BN_lshift 2015-05-22 23:15:02 +01:00
bn_sqr.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_sqrt.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_srp.c Only include SRP headers when OPENSSL_NO_SRP is undefined 2015-10-22 23:45:45 +02:00
bn_word.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00
bn_x931p.c Fix memory leaks and other mistakes on errors 2015-10-23 19:52:08 +02:00
Makefile Fix undeclared variable warnings. 2015-10-24 16:42:51 +01:00
rsaz_exp.c Rearrange rsaz 2015-06-23 02:59:47 +02:00
rsaz_exp.h rsaz_exp.h: align license with the rest of the contribution 2015-07-23 14:20:28 +02:00
vms-helper.c Identify and move common internal libcrypto header files 2015-05-14 17:21:40 +02:00