1
0
mirror of https://github.com/wolfSSL/wolfssl.git synced 2026-10-24 04:09:07 +03:00

Merge pull request #11504 from aidangarske/fix-custom-rng-init-cleanup

Fix custom RNG initialization cleanup
This commit is contained in:
David Garske
2026-09-19 08:25:28 -07:00
committed by GitHub
2 changed files with 13 additions and 4 deletions

View File

@@ -321,6 +321,13 @@
{"name": "rng-seed-device-fallback", "minutes": 1.1,
"comment": "Nominated seed device that cannot be opened, so every test runs through the fallback to the default seed sources.",
"configure": ["--with-rng-seed-device=/nonexistent/hwrng"]},
{"name": "rng-custom-block-hashdrbg", "minutes": 1.0,
"comment": "fwTPM defines CUSTOM_RAND_GENERATE_BLOCK while HAVE_HASHDRBG remains enabled. Keep the custom RNG bypass buildable when both macros are present.",
"user_settings": "IDE/m33mu-falcon-verify/user_settings.h",
"configure": ["--enable-usersettings", "--disable-examples",
"--disable-crypttests", "--disable-shared",
"CPPFLAGS=-DWOLFCRYPT_ONLY -DHAVE_HASHDRBG -DWC_RESEED_INTERVAL=1000000 -DWOLFSSL_NO_GETPID"],
"check": false},
{"name": "no-server-no-client-auth", "minutes": 1.0,
"configure": ["CPPFLAGS=-DNO_WOLFSSL_SERVER -DWOLFSSL_NO_CLIENT_AUTH"]},
{"name": "no-wolfssl-client", "minutes": 1.0,

View File

@@ -3107,7 +3107,8 @@ static WARN_UNUSED_RESULT int _InitRng(WC_RNG* rng,
rng->flags &= ~WC_RNG_FLAG_FULL_MUTEX;
}
#endif
#if defined(HAVE_HASHDRBG) && !defined(NO_SHA256)
#if defined(HAVE_HASHDRBG) && !defined(CUSTOM_RAND_GENERATE_BLOCK)
#ifndef NO_SHA256
if (rng->drbgType == WC_DRBG_SHA256) {
if (drbg_instantiated) {
(void)Hash_DRBG_Uninstantiate(
@@ -3128,8 +3129,8 @@ static WARN_UNUSED_RESULT int _InitRng(WC_RNG* rng,
rng->drbg_scratch = NULL;
#endif /* WOLFSSL_SMALL_STACK_CACHE */
}
#endif /* HAVE_HASHDRBG && !NO_SHA256 */
#if defined(HAVE_HASHDRBG) && defined(WOLFSSL_DRBG_SHA512)
#endif /* !NO_SHA256 */
#ifdef WOLFSSL_DRBG_SHA512
if (rng->drbgType == WC_DRBG_SHA512) {
if (drbg_instantiated) {
(void)Hash512_DRBG_Uninstantiate(
@@ -3149,11 +3150,12 @@ static WARN_UNUSED_RESULT int _InitRng(WC_RNG* rng,
rng->drbg512_scratch = NULL;
#endif /* WOLFSSL_SMALL_STACK_CACHE */
}
#endif /* HAVE_HASHDRBG && WOLFSSL_DRBG_SHA512 */
#endif /* WOLFSSL_DRBG_SHA512 */
#ifdef WOLFSSL_SMALL_STACK_CACHE
XFREE(rng->newSeed_buf, rng->heap, DYNAMIC_TYPE_SEED);
rng->newSeed_buf = NULL;
#endif
#endif /* HAVE_HASHDRBG && !CUSTOM_RAND_GENERATE_BLOCK */
}
return ret;