openssl/providers/fips
Karol Brzuskiewicz 42a8ef844e Fix usage of deallocated EVP_RAND_CTX after execution of FIPS on-demand self tests
Once RNG is used, triggering FIPS on-demand self tests (via
OSSL_PROVIDER_self_test() API) crashes the application. This happens because the
RNG context is stored before self tests, and restored after their execution.
In the meantime - before context restoration - RAND_set0_private() function is
called, which decrements the stored RNG context reference counter and frees it.
To resolve the issue, the stored RNG context refcount has been incremented via
the EVP_RAND_CTX_up_ref() API to avoid its deallocation during the RNG context
switch performed by the self test function.
The provider_status_test test has been updated to reproduce the issue as
a regression test.

Signed-off-by: Karol Brzuskiewicz <kabr@arista.com>

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24599)
2024-06-24 19:02:43 +02:00
..
build.info PROV: Relegate most of the FIPS provider code to libfips.a 2021-05-21 12:08:31 +02:00
fips_entry.c PROV: Relegate most of the FIPS provider code to libfips.a 2021-05-21 12:08:31 +02:00
fipsprov.c fips provider: explicitly setup cpuid when initializing 2024-05-20 10:14:39 +02:00
self_test_data.inc Adjust FIPS EC/DSA self test data for different nonce generation 2024-05-02 09:21:30 +02:00
self_test_kats.c Fix usage of deallocated EVP_RAND_CTX after execution of FIPS on-demand self tests 2024-06-24 19:02:43 +02:00
self_test.c fips selftest: avoid relying on a real RNG for self tests 2023-09-27 17:22:54 +01:00
self_test.h Rename OPENSSL_CTX prefix to OSSL_LIB_CTX 2020-10-15 11:59:53 +01:00