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

Merge pull request #11798 from aidangarske/remove/whitewood-netrandom

Remove Whitewood netRandom support
This commit is contained in:
Chris Conlon
2026-10-22 16:01:19 -06:00
committed by GitHub
21 changed files with 18 additions and 516 deletions

View File

@@ -399,6 +399,7 @@ HAVE_TM_TYPE
HAVE_VALIDATE_DATE
HAVE_VA_COPY
HAVE_WC_FIPS_OPTEST_CONTESTFAILURE_EXPORT
HAVE_WNR
HAVE_X448
HONOR_MATH_USED_LENGTH
HSM_KEY_TYPE_HMAC_224

View File

@@ -2781,7 +2781,6 @@ endif()
# TODO:
# - CRL monitor
# - User crypto
# - Whitewood netRandom client library
# - Max fragment length
# - ALPN
# - Trusted CA indication

View File

@@ -383,7 +383,6 @@ function(generate_build_flags)
set(BUILD_CRL_MONITOR "yes" PARENT_SCOPE)
endif()
set(BUILD_QUIC ${WOLFSSL_QUIC} PARENT_SCOPE)
set(BUILD_WNR ${WOLFSSL_WNR} PARENT_SCOPE)
if(WOLFSSL_SRP OR WOLFSSL_USER_SETTINGS)
set(BUILD_SRP "yes" PARENT_SCOPE)
endif()

View File

@@ -9711,46 +9711,14 @@ then
esac
fi
# Whitewood netRandom client library
ENABLED_WNR="no"
trywnrdir=""
# Reject the retired option instead of silently ignoring it.
AC_ARG_WITH([wnr],
[AS_HELP_STRING([--with-wnr=PATH],[Path to Whitewood netRandom install (default /usr/local)])],
[
AC_MSG_CHECKING([for Whitewood netRandom])
LIBS="$LIBS -lwnr"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <wnr.h>]], [[ wnr_setup(0, 0); ]])], [ wnr_linked=yes ],[ wnr_linked=no ])
if test "x$wnr_linked" = "xno" ; then
if test "x$withval" != "xno" ; then
trywnrdir=$withval
fi
if test "x$withval" = "xyes" ; then
trywnrdir="/usr/local"
fi
CPPFLAGS="$AM_CPPFLAGS -DHAVE_WNR -I$trywnrdir/include"
LDFLAGS="$AM_LDFLAGS $LDFLAGS -L$trywnrdir/lib"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <wnr.h>]], [[ wnr_setup(0, 0); ]])], [ wnr_linked=yes ],[ wnr_linked=no ])
if test "x$wnr_linked" = "xno" ; then
AC_MSG_ERROR([Whitewood netRandom isn't found.
If it's already installed, specify its path using --with-wnr=/dir/])
fi
AC_MSG_RESULT([yes])
AM_CPPFLAGS="$CPPFLAGS"
AM_LDFLAGS="$AM_LDFLAGS -L$trywnrdir/lib"
else
AC_MSG_RESULT([yes])
fi
AM_CFLAGS="$AM_CFLAGS -DHAVE_WNR"
ENABLED_WNR="yes"
]
)
[AS_HELP_STRING([--with-wnr=PATH],
[Whitewood netRandom support has been removed])],
[if test "x$withval" != "xno"; then
AC_MSG_ERROR([Whitewood netRandom support has been removed])
fi],
[])
# SNI
# enable SNI automatically for x86_64/x86/aarch64/amd64
@@ -14144,10 +14112,10 @@ then
esac
if test "$ENABLED_SELFTEST" = "yes" || test "x$ENABLED_HASHDRBG" != "xyes" || \
test "$ENABLED_ENTROPY_MEMUSE" != "no" || \
test "$ENABLED_RNG_AUTOFORK_FLAGS" = "no" || test "$ENABLED_WNR" = "yes" || \
test "$ENABLED_RNG_AUTOFORK_FLAGS" = "no" || \
{ test "$ENABLED_FIPS" = "yes" && test "${HAVE_FIPS_VERSION_MAJOR:-0}" -lt 7; }
then
RNG_AUTOFORK_NEEDS="${RNG_AUTOFORK_NEEDS:+$RNG_AUTOFORK_NEEDS, and }getpid and the Hash DRBG with a heap, and none of selftest, FIPS before v7, entropy-memuse, static memory, netRandom, memory zero checking or memory tracking"
RNG_AUTOFORK_NEEDS="${RNG_AUTOFORK_NEEDS:+$RNG_AUTOFORK_NEEDS, and }getpid and the Hash DRBG with a heap, and none of selftest, FIPS before v7, entropy-memuse, static memory, memory zero checking or memory tracking"
fi
if test -z "$RNG_AUTOFORK_NEEDS"
then
@@ -14578,7 +14546,6 @@ AM_CONDITIONAL([BUILD_OCSP_STAPLING_MULTI],[test "x$ENABLED_CERTIFICATE_STATUS_R
AM_CONDITIONAL([BUILD_OCSP_STAPLING_V2],[test "x$ENABLED_CERTIFICATE_STATUS_REQUEST_V2" = "xyes"])
AM_CONDITIONAL([BUILD_CRL],[test "x$ENABLED_CRL" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_CRL_MONITOR],[test "x$ENABLED_CRL_MONITOR" = "xyes"])
AM_CONDITIONAL([BUILD_WNR],[test "x$ENABLED_WNR" = "xyes"])
AM_CONDITIONAL([BUILD_SRP],[test "x$ENABLED_SRP" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([USE_VALGRIND],[test "x$ENABLED_VALGRIND" = "xyes"])
AM_CONDITIONAL([BUILD_MD4],[test "x$ENABLED_MD4" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
@@ -15194,7 +15161,6 @@ echo " * Persistent cert cache: $ENABLED_SAVECERT"
echo " * Atomic User Record Layer: $ENABLED_ATOMICUSER"
echo " * Public Key Callbacks: $ENABLED_PKCALLBACKS"
echo " * Falcon: $ENABLED_FALCON"
echo " * Whitewood netRandom: $ENABLED_WNR"
echo " * Server Name Indication: $ENABLED_SNI"
echo " * ALPN: $ENABLED_ALPN"
echo " * Maximum Fragment Length: $ENABLED_MAX_FRAGMENT"

View File

@@ -1,54 +1,3 @@
/*!
\ingroup Random
\brief グローバルWhitewood netRandomコンテキストを初期化します
\return 0 成功
\return BAD_FUNC_ARG configFileがnullまたはtimeoutが負の値の場合。
\return RNG_FAILURE_E rngの初期化に失敗しました。
\param configFile 設定ファイルへのパス
\param hmac_cb HMACコールバックを作成するためのオプション。
\param timeout タイムアウト期間。
_Example_
\code
char* config = "path/to/config/example.conf";
int time = // 十分なタイムアウト値;
if (wc_InitNetRandom(config, NULL, time) != 0)
{
// エラーが発生しました
}
\endcode
\sa wc_FreeNetRandom
*/
int wc_InitNetRandom(const char* configFile, wnr_hmac_key hmac_cb, int timeout);
/*!
\ingroup Random
\brief グローバルWhitewood netRandomコンテキストを解放します。
\return 0 成功
\return BAD_MUTEX_E wnr_mutexのミューテックスロックエラー
\param none 戻り値なし。
_Example_
\code
int ret = wc_FreeNetRandom();
if(ret != 0)
{
// エラーを処理
}
\endcode
\sa wc_InitNetRandom
*/
int wc_FreeNetRandom(void);
/*!
\ingroup Random

View File

@@ -1,54 +1,3 @@
/*!
\ingroup Random
\brief Init global Whitewood netRandom context
\return 0 Success
\return BAD_FUNC_ARG Either configFile is null or timeout is negative.
\return RNG_FAILURE_E There was a failure initializing the rng.
\param configFile Path to configuration file
\param hmac_cb Optional to create HMAC callback.
\param timeout A timeout duration.
_Example_
\code
char* config = "path/to/config/example.conf";
int time = // Some sufficient timeout value;
if (wc_InitNetRandom(config, NULL, time) != 0)
{
// Some error occurred
}
\endcode
\sa wc_FreeNetRandom
*/
int wc_InitNetRandom(const char* configFile, wnr_hmac_key hmac_cb, int timeout);
/*!
\ingroup Random
\brief Free global Whitewood netRandom context.
\return 0 Success
\return BAD_MUTEX_E Error locking mutex on wnr_mutex
\param none No returns.
_Example_
\code
int ret = wc_FreeNetRandom();
if(ret != 0)
{
// Handle the error
}
\endcode
\sa wc_InitNetRandom
*/
int wc_FreeNetRandom(void);
/*!
\ingroup Random

View File

@@ -1450,9 +1450,6 @@ static const char* client_usage_msg[][81] = {
#endif
#ifdef WOLFSSL_TRUST_PEER_CERT
"-E <file> Path to load trusted peer cert\n", /* 48 */
#endif
#ifdef HAVE_WNR
"-q <file> Whitewood config file, defaults\n", /* 49 */
#endif
"-H <arg> Internal tests"
" [defCipherList, exitWithRet, verifyFail, useSupCurve,\n"
@@ -1722,9 +1719,6 @@ static const char* client_usage_msg[][81] = {
#endif
#ifdef WOLFSSL_TRUST_PEER_CERT
"-E <file> 信頼出来るピアの証明書ロードの為のパス\n", /* 48 */
#endif
#ifdef HAVE_WNR
"-q <file> Whitewood コンフィグファイル, 既定値\n", /* 49 */
#endif
"-H <arg> 内部テスト"
" [defCipherList, exitWithRet, verifyFail, useSupCurve,\n"
@@ -2009,9 +2003,6 @@ static void Usage(void)
#endif
#ifdef WOLFSSL_TRUST_PEER_CERT
printf("%s", msg[++msgid]); /* -E */
#endif
#ifdef HAVE_WNR
printf("%s %s\n", msg[++msgid], wnrConfig); /* -q */
#endif
printf("%s", msg[++msgid]); /* -H */
printf("%s", msg[++msgid]); /* more -H options */
@@ -2413,9 +2404,6 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
int disallowETM = 0;
#endif
#ifdef HAVE_WNR
const char* wnrConfigFile = wnrConfig;
#endif
#if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
(defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
!defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
@@ -2557,7 +2545,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#ifndef WOLFSSL_VXWORKS
/* Not used: All used */
while ((ch = mygetopt_long(argc, argv, "?:"
"ab:c:defgh:i;jk:l:mnop:q:rstu;v:wxyz"
"ab:c:defgh:i;jk:l:mnop:rstu;v:wxyz"
"A:B:CDE:F:GH:IJKL:M:NO:PQRS:TUVW:XYZ:"
"01:23:4567:89"
"@#", long_options, 0)) != -1) {
@@ -2960,12 +2948,6 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
break;
case 'q' :
#ifdef HAVE_WNR
wnrConfigFile = myoptarg;
#endif
break;
case 'J' :
#ifdef WOLFSSL_TLS13
helloRetry = 1;
@@ -3348,11 +3330,6 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
}
#endif
#ifdef HAVE_WNR
if (wc_InitNetRandom(wnrConfigFile, NULL, 5000) != 0)
err_sys("can't load whitewood net random config file");
#endif
#ifdef WOLFSSL_HAVE_MLKEM
if (usePqc) {
if (version == CLIENT_DOWNGRADE_VERSION ||
@@ -5228,11 +5205,6 @@ exit:
#endif
wolfSSL_Cleanup();
#ifdef HAVE_WNR
if (wc_FreeNetRandom() < 0)
err_sys("Failed to free netRandom context");
#endif /* HAVE_WNR */
return args.return_code;
}

View File

@@ -453,7 +453,7 @@ extern "C" {
* not Android); the pin needs dladdr and dlopen,
* -ldl on glibc before 2.34, and keeps the library mapped, since the
* handlers cannot be removed. Left out with SINGLE_THREADED,
* entropy-memuse, the RNG bank, netRandom, selftest, FIPS before v7,
* entropy-memuse, the RNG bank, selftest, FIPS before v7,
* memory zero checking, memory tracking or failure counting */
#undef WC_RNG_AUTOFORK
#define WC_RNG_AUTOFORK

View File

@@ -316,11 +316,6 @@ void echoclient_test(void* args)
{
func_args args;
#ifdef HAVE_WNR
if (wc_InitNetRandom(wnrConfig, NULL, 5000) != 0)
err_sys("Whitewood netRandom global config failed");
#endif
StartTCP();
args.argc = argc;
@@ -340,11 +335,6 @@ void echoclient_test(void* args)
wolfSSL_Cleanup();
#ifdef HAVE_WNR
if (wc_FreeNetRandom() < 0)
err_sys("Failed to free netRandom context");
#endif /* HAVE_WNR */
return args.return_code;
}

View File

@@ -493,11 +493,6 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args)
{
func_args args;
#ifdef HAVE_WNR
if (wc_InitNetRandom(wnrConfig, NULL, 5000) != 0)
err_sys("Whitewood netRandom global config failed");
#endif
StartTCP();
args.argc = argc;
@@ -514,11 +509,6 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args)
#endif
wolfSSL_Cleanup();
#ifdef HAVE_WNR
if (wc_FreeNetRandom() < 0)
err_sys("Failed to free netRandom context");
#endif /* HAVE_WNR */
return args.return_code;
}

View File

@@ -1135,12 +1135,6 @@ int main(int argc, char** argv)
StartTCP();
#ifdef HAVE_WNR
if (wc_InitNetRandom(wnrConfigFile, NULL, 5000) != 0) {
err_sys("Whitewood netRandom global config failed");
}
#endif
ret = wolfSSL_Init();
if (ret != WOLFSSL_SUCCESS) {
err_sys("wolfSSL_Init failed");
@@ -1155,11 +1149,6 @@ int main(int argc, char** argv)
wolfSSL_Cleanup();
#ifdef HAVE_WNR
if (wc_FreeNetRandom() < 0)
err_sys("Failed to free netRandom context");
#endif
return args.return_code;
}
#endif /* !NO_MAIN_DRIVER */

View File

@@ -1007,9 +1007,6 @@ static const char* server_usage_msg[][71] = {
#endif
#ifdef WOLFSSL_TRUST_PEER_CERT
"-E <file> Path to load trusted peer cert\n", /* 33 */
#endif
#ifdef HAVE_WNR
"-q <file> Whitewood config file, default", /* 34 */
#endif
"-g Return basic HTML web page\n", /* 35 */
"-C <num> The number of connections to accept, default: 1\n",/* 36 */
@@ -1232,9 +1229,6 @@ static const char* server_usage_msg[][71] = {
#endif
#ifdef WOLFSSL_TRUST_PEER_CERT
"-E <file> 信頼出来るピアの証明書ロードの為のパス\n\n", /* 33 */
#endif
#ifdef HAVE_WNR
"-q <file> Whitewood コンフィグファイル, 既定値", /* 34 */
#endif
"-g 基本的な Web ページを返す\n", /* 35 */
"-C <num> アクセプト可能な接続数を指定する。既定値: 1\n", /* 36 */
@@ -1447,9 +1441,6 @@ static void Usage(void)
#endif
#ifdef WOLFSSL_TRUST_PEER_CERT
printf("%s", msg[++msgId]); /* -E */
#endif
#ifdef HAVE_WNR
printf("%s %s\n", msg[++msgId], wnrConfig); /* -q */
#endif
printf("%s", msg[++msgId]); /* -g */
printf("%s", msg[++msgId]); /* -C */
@@ -1769,9 +1760,6 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
char* ocspUrl = NULL;
#endif
#ifdef HAVE_WNR
const char* wnrConfigFile = wnrConfig;
#endif
char buffer[WOLFSSL_MAX_ERROR_SZ];
#ifdef WOLFSSL_TLS13
int noPskDheKe = 0;
@@ -1958,7 +1946,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
/* Not Used: h, z, W, X */
while ((ch = mygetopt_long(argc, argv, "?:"
"abc:defgijk:l:mop:q:rstu;v:wxy"
"abc:defgijk:l:mop:rstu;v:wxy"
"A:B:C:D:E:FGH:IJ;KL:MNO:PQR:S:T;UVYZ:"
"01:23:4:567:89"
"@#", long_options, 0)) != -1) {
@@ -2250,12 +2238,6 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
break;
#endif
case 'q' :
#ifdef HAVE_WNR
wnrConfigFile = myoptarg;
#endif
break;
case 'g' :
useWebServerMsg = 1;
break;
@@ -2702,12 +2684,6 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
}
#endif
#ifdef HAVE_WNR
if (wc_InitNetRandom(wnrConfigFile, NULL, 5000) != 0)
err_sys_ex(runWithErrors, "can't load whitewood net random config "
"file");
#endif
#ifdef WOLFSSL_HAVE_MLKEM
if (usePqc) {
if (version == SERVER_DOWNGRADE_VERSION ||
@@ -4323,11 +4299,6 @@ exit:
wolfSSL_Cleanup();
FreeTcpReady(&ready);
#ifdef HAVE_WNR
if (wc_FreeNetRandom() < 0)
err_sys_ex(runWithErrors, "Failed to free netRandom context");
#endif /* HAVE_WNR */
return args.return_code;
}

View File

@@ -107,11 +107,6 @@ int unit_test(int argc, char** argv)
#ifdef WC_RNG_SEED_CB
wc_SetSeed_Cb(WC_GENERATE_SEED_DEFAULT);
#endif
#ifdef HAVE_WNR
if (wc_InitNetRandom(wnrConfig, NULL, 5000) != 0)
err_sys("Whitewood netRandom global config failed");
#endif /* HAVE_WNR */
#ifndef WOLFSSL_TIRTOS
ChangeToWolfRoot();
#endif
@@ -367,11 +362,6 @@ int unit_test(int argc, char** argv)
#endif
exit:
#ifdef HAVE_WNR
if (wc_FreeNetRandom() < 0)
err_sys("Failed to free netRandom context");
#endif /* HAVE_WNR */
/* Drop process-global ECC caches before exit. wolfCrypt_Cleanup() only
* runs its cleanup body when initRefCount transitions 2->1 (the body
* itself does the second decrement to 0); the unit driver's single

View File

@@ -168,13 +168,6 @@ int testsuite_test(int argc, char** argv)
tempName_Xnum = 6;
#endif /* !USE_WINDOWS_API */
#ifdef HAVE_WNR
if (wc_InitNetRandom(wnrConfig, NULL, 5000) != 0) {
err_sys("Whitewood netRandom global config failed");
return -1237;
}
#endif /* HAVE_WNR */
StartTCP();
server_args.argc = argc;
@@ -298,11 +291,6 @@ int testsuite_test(int argc, char** argv)
fdCloseSession(Task_self());
#endif
#ifdef HAVE_WNR
if (wc_FreeNetRandom() < 0)
err_sys("Failed to free netRandom context");
#endif /* HAVE_WNR */
printf("\nAll tests passed!\n");
#else

View File

@@ -1,40 +0,0 @@
# Example netRandom client library configuration file
#
# This uses /dev/urandom for the seed, but could also
# be set up to use a network entropy source
version = "1.0";
WnrClient:
{
dir:
{
working = "/var/run/wnrentropy";
socket = "/var/run/wnrentropy";
};
drbg:
{
type = "SHA256";
security_strength = 256;
reseed_interval = 1;
};
source:
{
seed = {
type = "FILEPATH";
path = "/dev/urandom";
};
stream = {
type = "FILEPATH";
path = "/dev/urandom";
};
};
buffer:
{
size = 8192;
threshold = 7168;
};
};

View File

@@ -1521,10 +1521,6 @@ static const bench_pq_alg bench_pq_asym_opt[] = {
#endif
#ifdef HAVE_WNR
const char* wnrConfigFile = "wnr-example.conf";
#endif
#if defined(WOLFSSL_MDK_ARM)
extern XFILE wolfSSL_fopen(const char *fname, const char *mode);
#define fopen wolfSSL_fopen
@@ -5296,14 +5292,6 @@ int benchmark_init(void)
}
#endif
#ifdef HAVE_WNR
ret = wc_InitNetRandom(wnrConfigFile, NULL, 5000);
if (ret != 0) {
printf("%sWhitewood netRandom config init failed %d\n",
err_prefix, ret);
}
#endif /* HAVE_WNR */
return ret;
}
@@ -5339,13 +5327,6 @@ int benchmark_free(void)
wolfAsync_DevClose(&devId);
#endif
#ifdef HAVE_WNR
ret = wc_FreeNetRandom();
if (ret < 0) {
printf("%sFailed to free netRandom context %d\n", err_prefix, ret);
}
#endif
#ifdef WOLFSSL_SECO_CAAM
if (wc_SECO_CloseHSM() != 0) {
printf("%sError closing down the key store\n", err_prefix);

View File

@@ -193,16 +193,6 @@ This library contains implementation for the random number generator.
#include <windows.h>
#include <wincrypt.h>
#undef _WINSOCKAPI_ /* undefine it for MINGW winsock2.h header file */
#elif defined(HAVE_WNR)
#include <wnr.h>
wolfSSL_Mutex wnr_mutex WOLFSSL_MUTEX_INITIALIZER_CLAUSE(wnr_mutex); /* global netRandom mutex */
int wnr_timeout = 0; /* entropy timeout, milliseconds */
#ifndef WOLFSSL_MUTEX_INITIALIZER
/* Elects a single initializer for wnr_mutex. */
wc_MutexOnceFlag wnr_mutex_inited = WOLFSSL_ATOMIC_INITIALIZER(0);
#endif
int wnr_inited = 0; /* flag for whether wc_InitNetRandom() has been called */
wnr_context* wnr_ctx; /* global netRandom context */
#elif defined(FREESCALE_KSDK_2_0_TRNG)
#include "fsl_trng.h"
#elif defined(FREESCALE_KSDK_2_0_RNGA)
@@ -9032,119 +9022,6 @@ exit_sha512_ex2:
#endif /* HAVE_HASHDRBG */
#ifdef HAVE_WNR
/*
* Init global Whitewood netRandom context
* Returns 0 on success, negative on error
*/
int wc_InitNetRandom(const char* configFile, wnr_hmac_key hmac_cb, int timeout)
{
int ret = 0;
if (configFile == NULL || timeout < 0)
return BAD_FUNC_ARG;
#ifndef WOLFSSL_MUTEX_INITIALIZER
ret = wc_local_InitMutexOnce(&wnr_mutex, &wnr_mutex_inited);
if (ret != 0) {
WOLFSSL_MSG("Bad Init Mutex wnr_mutex");
return ret;
}
#endif
if (wnr_inited > 0) {
WOLFSSL_MSG("netRandom context already created, skipping");
return 0;
}
if (wc_LockMutex(&wnr_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex wnr_mutex");
return BAD_MUTEX_E;
}
/* store entropy timeout */
wnr_timeout = timeout;
/* create global wnr_context struct */
if (wnr_create(&wnr_ctx) != WNR_ERROR_NONE) {
WOLFSSL_MSG("Error creating global netRandom context");
ret = RNG_FAILURE_E;
goto out;
}
/* load config file */
if (wnr_config_loadf(wnr_ctx, (char*)configFile) != WNR_ERROR_NONE) {
WOLFSSL_MSG("Error loading config file into netRandom context");
wnr_destroy(wnr_ctx);
wnr_ctx = NULL;
ret = RNG_FAILURE_E;
goto out;
}
/* create/init polling mechanism */
if (wnr_poll_create() != WNR_ERROR_NONE) {
WOLFSSL_MSG("Error initializing netRandom polling mechanism");
wnr_destroy(wnr_ctx);
wnr_ctx = NULL;
ret = RNG_FAILURE_E;
goto out;
}
/* validate config, set HMAC callback (optional) */
if (wnr_setup(wnr_ctx, hmac_cb) != WNR_ERROR_NONE) {
WOLFSSL_MSG("Error setting up netRandom context");
wnr_destroy(wnr_ctx);
wnr_ctx = NULL;
wnr_poll_destroy();
ret = RNG_FAILURE_E;
goto out;
}
wnr_inited = 1;
out:
wc_UnLockMutex(&wnr_mutex);
return ret;
}
/*
* Free global Whitewood netRandom context
* Returns 0 on success, negative on error
*/
int wc_FreeNetRandom(void)
{
if (wnr_inited > 0) {
if (wc_LockMutex(&wnr_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex wnr_mutex");
return BAD_MUTEX_E;
}
if (wnr_ctx != NULL) {
wnr_destroy(wnr_ctx);
wnr_ctx = NULL;
}
wnr_poll_destroy();
wc_UnLockMutex(&wnr_mutex);
#ifndef WOLFSSL_MUTEX_INITIALIZER
wc_FreeMutex(&wnr_mutex);
WOLFSSL_ATOMIC_STORE(wnr_mutex_inited, 0);
#endif
wnr_inited = 0;
}
return 0;
}
#endif /* HAVE_WNR */
#if defined(HAVE_INTEL_RDRAND) || defined(HAVE_INTEL_RDSEED) || \
defined(HAVE_AMD_RDSEED)
@@ -10830,36 +10707,6 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
return (err_code == NRF_SUCCESS) ? 0 : -1;
}
#elif defined(HAVE_WNR)
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
if (os == NULL || output == NULL || wnr_ctx == NULL ||
wnr_timeout < 0) {
return BAD_FUNC_ARG;
}
#ifndef WOLFSSL_MUTEX_INITIALIZER
if (WOLFSSL_ATOMIC_LOAD(wnr_mutex_inited) != 2) {
WOLFSSL_MSG("netRandom context must be created before use");
return RNG_FAILURE_E;
}
#endif
if (wc_LockMutex(&wnr_mutex) != 0) {
WOLFSSL_MSG("Bad Lock Mutex wnr_mutex");
return BAD_MUTEX_E;
}
if (wnr_get_entropy(wnr_ctx, wnr_timeout, output, sz, sz) !=
WNR_ERROR_NONE)
return RNG_FAILURE_E;
wc_UnLockMutex(&wnr_mutex);
return 0;
}
#elif defined(INTIME_RTOS)
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{

View File

@@ -820,10 +820,6 @@ static WC_MAYBE_UNUSED int test_EccInit_Pub(ecc_key* key, int keySize,
}
#endif /* HAVE_ECC */
#ifdef HAVE_WNR
const char* wnrConfigFile = "wnr-example.conf";
#endif
#define TEST_STRING "Everyone gets Friday off."
#define TEST_STRING_SZ 25
@@ -4079,13 +4075,6 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
fatInitDefault();
#endif
#ifdef HAVE_WNR
if ((ret = wc_InitNetRandom(wnrConfigFile, NULL, 5000)) != 0) {
err_sys("Whitewood netRandom global config failed",
WC_TEST_RET_ENC_EC(ret));
return WC_TEST_RET_ENC_EC(ret);
}
#endif
#ifndef WOLFSSL_ESPIDF
args.argc = argc;
args.argv = argv;
@@ -4135,13 +4124,6 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
err_sys("Error with wolfCrypt_Cleanup!\n", args.return_code);
}
#ifdef HAVE_WNR
if ((ret = wc_FreeNetRandom()) < 0) {
args.return_code = WC_TEST_RET_ENC_EC(ret);
err_sys("Failed to free netRandom context",
args.return_code);
}
#endif /* HAVE_WNR */
#ifdef DOLPHIN_EMULATOR
/* Returning from main panics the emulator. Just hang
* and let the user force quit the emulator window. */

View File

@@ -663,10 +663,6 @@ err_sys_with_errno_func(const char* msg, const char *file, int line)
#define noIssuerCertFile "certs/empty-issuer-cert.der"
#endif
#define caCertFolder "certs/"
#ifdef HAVE_WNR
/* Whitewood netRandom default config file */
#define wnrConfig "wnr-example.conf"
#endif
#elif defined(NETOS) && defined(HAVE_FIPS)
/* These defines specify the file system volume and root directory used by
* the FTP server used in the only supported NETOS FIPS solution (at this
@@ -688,10 +684,6 @@ err_sys_with_errno_func(const char* msg, const char *file, int line)
#define cliEccCertFile FS_VOLUME1_DIR "certs/client-ecc-cert.pem"
#define caEccCertFile FS_VOLUME1_DIR "certs/ca-ecc-cert/pem"
#define crlPemDir FS_VOLUME1_DIR "certs/crl"
#ifdef HAVE_WNR
/* Whitewood netRandom default config file */
#define wnrConfig "wnr-example.conf"
#endif
#else
#ifdef WOLFSSL_PEM_TO_DER
#define caCertFile "./certs/ca-cert.pem"
@@ -763,10 +755,6 @@ err_sys_with_errno_func(const char* msg, const char *file, int line)
#define noIssuerCertFile "./certs/empty-issuer-cert.der"
#endif
#define caCertFolder "./certs/"
#ifdef HAVE_WNR
/* Whitewood netRandom default config file */
#define wnrConfig "./wnr-example.conf"
#endif
#endif
/* ML-DSA (FIPS 204) certificate material. The mldsa<N>-cert files are

View File

@@ -71,8 +71,7 @@
defined(HAVE_THREAD_LS) && !defined(NO_THREAD_LS) && \
defined(HAVE_GETPID) && !defined(WOLFSSL_NO_GETPID) && \
!defined(WOLFSSL_NO_MALLOC) && !defined(HAVE_ENTROPY_MEMUSE) && \
!defined(WOLFSSL_STATIC_MEMORY) && \
!defined(HAVE_WNR) && !defined(WOLFSSL_CHECK_MEM_ZERO) && \
!defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_CHECK_MEM_ZERO) && \
!defined(WOLFSSL_TRACK_MEMORY) && !defined(WOLFSSL_MEM_FAIL_COUNT)
#define WC_RNG_LOCK_ATFORK
#else
@@ -272,8 +271,6 @@
#ifdef WOLFSSL_DRBG_SHA512
#include <wolfssl/wolfcrypt/sha512.h>
#endif
#elif defined(HAVE_WNR)
/* allow whitewood as direct RNG source using wc_GenerateSeed directly */
#elif defined(HAVE_INTEL_RDRAND)
/* Intel RDRAND or RDSEED */
#elif defined(WOLF_CRYPTO_CB)
@@ -282,10 +279,6 @@
#error No RNG source defined!
#endif
#ifdef HAVE_WNR
#include <wnr.h>
#endif
#ifdef WOLFSSL_ASYNC_CRYPT
#include <wolfssl/wolfcrypt/async.h>
#endif
@@ -849,12 +842,6 @@ WOLFSSL_API int wc_NoiseSrc_SelfTest(wc_NoiseSrc* src);
#endif /* WOLFSSL_NOISE_SRC */
#ifdef HAVE_WNR
/* Whitewood netRandom client library */
WOLFSSL_API int wc_InitNetRandom(const char*, wnr_hmac_key, int);
WOLFSSL_API int wc_FreeNetRandom(void);
#endif /* HAVE_WNR */
#ifndef WC_NO_RNG
/* Note, wc_rng_new*, wc_InitRng*, wc_InitRng_BankRef, wc_FreeRng and

View File

@@ -402,6 +402,10 @@
#endif
#endif
#ifdef HAVE_WNR
#error "Whitewood netRandom support has been removed"
#endif
#if defined(HAVE_FIPS) && \
(defined(WC_FIPS_LL_CRYPTO) || defined(WOLFSSL_FIPS_DEV_NO_POST)) && \
!defined(FIPS_NO_WRAPPERS)