From aecb37c032be6a5f1a027ed58f6b918b5b128fc2 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 3 Mar 2023 22:00:24 -0600 Subject: [PATCH] linuxkm/module_hooks.c: wc_SetSeed_Cb(wc_GenerateSeed) in wolfssl_init() #ifdef WC_RNG_SEED, regardless of whether wolfcrypt_test() will be called. --- linuxkm/module_hooks.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/linuxkm/module_hooks.c b/linuxkm/module_hooks.c index 3f703add0..783307527 100644 --- a/linuxkm/module_hooks.c +++ b/linuxkm/module_hooks.c @@ -234,6 +234,16 @@ static int wolfssl_init(void) "] POST succeeded.\n"); #endif /* HAVE_FIPS */ +#ifdef WC_RNG_SEED_CB + ret = wc_SetSeed_Cb(wc_GenerateSeed); + if (ret < 0) { + pr_err("wc_SetSeed_Cb() failed with return code %d.\n", ret); + (void)libwolfssl_cleanup(); + msleep(10); + return -ECANCELED; + } +#endif + #ifdef WOLFCRYPT_ONLY ret = wolfCrypt_Init(); if (ret != 0) { @@ -249,14 +259,7 @@ static int wolfssl_init(void) #endif #ifndef NO_CRYPT_TEST - -#ifdef WC_RNG_SEED_CB - ret = wc_SetSeed_Cb(wc_GenerateSeed); - if (ret == 0) -#endif - { - ret = wolfcrypt_test(NULL); - } + ret = wolfcrypt_test(NULL); if (ret < 0) { pr_err("wolfcrypt self-test failed with return code %d.\n", ret); (void)libwolfssl_cleanup();