mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-26 17:52:23 +01:00
tweaks from PRBs results:
tests/api.c: * remove inapt SSL_library_init() in test_wolfSSL_EVP_Cipher_extra(); * move TEST_X509_DECLS to follow TEST_DECL(test_wolfSSL_Init); tests/api/test_random.c: enlarge seed buffer in test_wc_RNG_TestSeed() to accommodate amdrand block size; tests/quic.c: wrap exercises in wolfSSL_Init()...wolfSSL_Cleanup(); tests/unit.c: in unit_test(), add several more fflush(stdout)s, report error from wolfSSL_Cleanup(), and fix line length; wolfcrypt/test/test.c: omit reseed test in _rng_test() if HAVE_INTEL_RDRAND or old FIPS, and use simplified random_test() if HAVE_INTEL_RDRAND; wolfssl/wolfcrypt/mem_track.h: add memList pointer in struct memoryStats, and set it in InitMemoryTracker(); wolfssl/wolfcrypt/settings.h: undefine WOLFSSL_SMALL_STACK_CACHE if WOLFSSL_SMALL_STACK is undefined; .github/workflows/trackmemory.yml: add --enable-intelrdseed scenario.
This commit is contained in:
1
.github/workflows/trackmemory.yml
vendored
1
.github/workflows/trackmemory.yml
vendored
@@ -27,6 +27,7 @@ jobs:
|
||||
#
|
||||
# Note, don't combine wolfEntropy with the full TLS cipher suite test -- the implicit wc_InitRng()s in each suite have an enormous CPU footprint.
|
||||
'--enable-wolfEntropy --enable-smallstackcache --enable-smallstack --enable-all CFLAGS="-DWC_RNG_SEED_CB -DWOLFSSL_TRACK_MEMORY -DWOLFSSL_DEBUG_MEMORY -DNO_WOLFSSL_CIPHER_SUITE_TEST"',
|
||||
'--enable-intelrdseed --enable-smallstackcache --enable-smallstack --enable-all CFLAGS="-DWC_RNG_SEED_CB -DWOLFSSL_TRACK_MEMORY -DWOLFSSL_DEBUG_MEMORY -DNO_WOLFSSL_CIPHER_SUITE_TEST"',
|
||||
'--enable-amdrand --enable-smallstackcache --enable-smallstack --enable-all CFLAGS="-DWC_RNG_SEED_CB -DWOLFSSL_TRACK_MEMORY -DWOLFSSL_DEBUG_MEMORY -DNO_WOLFSSL_CIPHER_SUITE_TEST"',
|
||||
'--disable-asm --enable-wolfEntropy --enable-smallstackcache --enable-smallstack --enable-all CFLAGS="-DWC_RNG_SEED_CB -DWOLFSSL_TRACK_MEMORY -DWOLFSSL_DEBUG_MEMORY -DNO_WOLFSSL_CIPHER_SUITE_TEST"'
|
||||
]
|
||||
|
||||
@@ -22832,8 +22832,6 @@ static int test_wolfSSL_EVP_Cipher_extra(void)
|
||||
|
||||
set_plain(plain, BUFFSZ * RECORDS);
|
||||
|
||||
SSL_library_init();
|
||||
|
||||
ExpectNotNull(evp = EVP_CIPHER_CTX_new());
|
||||
ExpectIntNE((ret = EVP_CipherInit(evp, type, NULL, iv, 0)), 0);
|
||||
|
||||
@@ -41503,8 +41501,6 @@ TEST_CASE testCases[] = {
|
||||
TEST_MLDSA_DECLS,
|
||||
/* Signature API */
|
||||
TEST_SIGNATURE_DECLS,
|
||||
/* x509 */
|
||||
TEST_X509_DECLS,
|
||||
|
||||
/* ASN */
|
||||
TEST_ASN_DECLS,
|
||||
@@ -41562,6 +41558,9 @@ TEST_CASE testCases[] = {
|
||||
|
||||
TEST_DECL(test_wolfSSL_Init),
|
||||
|
||||
/* x509 -- must appear after test_wolfSSL_Init(). */
|
||||
TEST_X509_DECLS,
|
||||
|
||||
TEST_DECL(test_dual_alg_support),
|
||||
TEST_DECL(test_dual_alg_crit_ext_support),
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ int test_wc_RNG_TestSeed(void)
|
||||
#if defined(HAVE_HASHDRBG) && \
|
||||
(!(defined(HAVE_FIPS) || defined(HAVE_SELFTEST)) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)))
|
||||
byte seed[16];
|
||||
byte seed[32];
|
||||
byte i;
|
||||
|
||||
#ifdef TEST_WC_RNG_TESTSEED_BAD_PARAMS
|
||||
|
||||
@@ -1892,6 +1892,12 @@ int QuicTest(void)
|
||||
int ret = 0;
|
||||
#ifdef WOLFSSL_QUIC
|
||||
int verbose = 0;
|
||||
|
||||
if (wolfSSL_Init() != WOLFSSL_SUCCESS) {
|
||||
printf("wolfSSL_Init() failed in QuicTest().");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf(" Begin QUIC Tests\n");
|
||||
|
||||
if ((ret = test_set_quic_method()) != TEST_SUCCESS) goto leave;
|
||||
@@ -1917,6 +1923,8 @@ leave:
|
||||
printf(" FAILED: some tests did not pass.\n");
|
||||
}
|
||||
printf(" End QUIC Tests\n");
|
||||
|
||||
(void)wolfSSL_Cleanup();
|
||||
#endif
|
||||
return ret == TEST_SUCCESS ? 0 : -1;
|
||||
}
|
||||
|
||||
23
tests/unit.c
23
tests/unit.c
@@ -273,6 +273,7 @@ int unit_test(int argc, char** argv)
|
||||
}
|
||||
|
||||
printf("wolfCrypt unit test completed successfully.\n\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -282,6 +283,7 @@ int unit_test(int argc, char** argv)
|
||||
{
|
||||
if (apiTesting) {
|
||||
ret = ApiTest();
|
||||
fflush(stdout);
|
||||
if (ret != 0)
|
||||
goto exit;
|
||||
}
|
||||
@@ -291,20 +293,25 @@ int unit_test(int argc, char** argv)
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_W64_WRAPPER
|
||||
if ((ret = w64wrapper_test()) != 0) {
|
||||
ret = w64wrapper_test();
|
||||
fflush(stdout);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "w64wrapper test failed with %d\n", ret);
|
||||
goto exit;
|
||||
}
|
||||
#endif /* WOLFSSL_W64_WRAPPER */
|
||||
|
||||
#ifdef WOLFSSL_QUIC
|
||||
if ((ret = QuicTest()) != 0) {
|
||||
ret = QuicTest();
|
||||
fflush(stdout);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "quic test failed with %d\n", ret);
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
|
||||
SrpTest();
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
#if !defined(NO_WOLFSSL_CIPHER_SUITE_TEST) && \
|
||||
@@ -326,10 +333,18 @@ exit:
|
||||
|
||||
#ifdef WOLFSSL_TRACK_MEMORY
|
||||
if (ret == 0) {
|
||||
(void)wolfSSL_Cleanup();
|
||||
ret = wolfSSL_Cleanup(); /* no-op in a successful full run. */
|
||||
|
||||
if (ret == WOLFSSL_SUCCESS)
|
||||
ret = 0;
|
||||
else
|
||||
fprintf(stderr, "wolfSSL_Cleanup() returned %d\n", ret);
|
||||
|
||||
if (wc_MemStats_Ptr->currentBytes > 0)
|
||||
{
|
||||
fprintf(stderr, "WOLFSSL_TRACK_MEMORY: currentBytes after cleanup is %ld\n", wc_MemStats_Ptr->currentBytes);
|
||||
fprintf(stderr,
|
||||
"WOLFSSL_TRACK_MEMORY: currentBytes after cleanup is %ld\n",
|
||||
wc_MemStats_Ptr->currentBytes);
|
||||
ret = MEMORY_E;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19693,7 +19693,9 @@ static wc_test_ret_t _rng_test(WC_RNG* rng)
|
||||
return WC_TEST_RET_ENC_EC(ret);
|
||||
}
|
||||
|
||||
#if defined(HAVE_HASHDRBG) && !defined(CUSTOM_RAND_GENERATE_BLOCK)
|
||||
#if defined(HAVE_HASHDRBG) && !defined(HAVE_INTEL_RDRAND) && \
|
||||
!defined(CUSTOM_RAND_GENERATE_BLOCK) && \
|
||||
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(5,0,0))
|
||||
/* Test periodic reseed dynamics. */
|
||||
|
||||
((struct DRBG_internal *)rng->drbg)->reseedCtr = WC_RESEED_INTERVAL;
|
||||
@@ -19704,7 +19706,7 @@ static wc_test_ret_t _rng_test(WC_RNG* rng)
|
||||
|
||||
if (((struct DRBG_internal *)rng->drbg)->reseedCtr == WC_RESEED_INTERVAL)
|
||||
return WC_TEST_RET_ENC_NC;
|
||||
#endif /* HAVE_HASHDRBG && !CUSTOM_RAND_GENERATE_BLOCK */
|
||||
#endif /* HAVE_HASHDRBG && !CUSTOM_RAND_GENERATE_BLOCK && !HAVE_SELFTEST */
|
||||
|
||||
#if defined(WOLFSSL_TRACK_MEMORY) && defined(WOLFSSL_SMALL_STACK_CACHE)
|
||||
/* wc_RNG_GenerateBlock() must not allocate any memory in
|
||||
@@ -19797,7 +19799,8 @@ static wc_test_ret_t random_rng_test(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(HAVE_HASHDRBG) && !defined(CUSTOM_RAND_GENERATE_BLOCK)
|
||||
#if defined(HAVE_HASHDRBG) && !defined(CUSTOM_RAND_GENERATE_BLOCK) && \
|
||||
!defined(HAVE_INTEL_RDRAND)
|
||||
|
||||
#if defined(WC_RNG_SEED_CB) && \
|
||||
!(defined(ENTROPY_SCALE_FACTOR) || defined(SEED_BLOCK_SZ))
|
||||
@@ -19940,7 +19943,7 @@ static wc_test_ret_t rng_seed_test(void)
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
#endif /* WC_RNG_SEED_CB) && !(ENTROPY_SCALE_FACTOR || SEED_BLOCK_SZ) */
|
||||
#endif /* WC_RNG_SEED_CB && !(ENTROPY_SCALE_FACTOR || SEED_BLOCK_SZ) */
|
||||
|
||||
|
||||
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t random_test(void)
|
||||
@@ -20060,7 +20063,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t random_test(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
#else /* !HAVE_HASHDRBG || CUSTOM_RAND_GENERATE_BLOCK || HAVE_INTEL_RDRAND */
|
||||
|
||||
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t random_test(void)
|
||||
{
|
||||
@@ -20070,7 +20073,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t random_test(void)
|
||||
return random_rng_test();
|
||||
}
|
||||
|
||||
#endif /* HAVE_HASHDRBG && !CUSTOM_RAND_GENERATE_BLOCK */
|
||||
#endif /* !HAVE_HASHDRBG || CUSTOM_RAND_GENERATE_BLOCK || HAVE_INTEL_RDRAND */
|
||||
#endif /* WC_NO_RNG */
|
||||
|
||||
#ifndef MEM_TEST_SZ
|
||||
|
||||
@@ -83,6 +83,8 @@
|
||||
#define DO_MEM_LIST
|
||||
#endif
|
||||
|
||||
struct memoryList;
|
||||
|
||||
typedef struct memoryStats {
|
||||
long totalAllocs; /* number of allocations */
|
||||
long totalDeallocs; /* number of deallocations */
|
||||
@@ -98,6 +100,9 @@ typedef struct memoryStats {
|
||||
* by wolfCrypt_heap_peak_checkpoint()
|
||||
*/
|
||||
#endif
|
||||
#ifdef DO_MEM_LIST
|
||||
struct memoryList *memList;
|
||||
#endif
|
||||
} memoryStats;
|
||||
|
||||
typedef struct memHint {
|
||||
@@ -380,6 +385,7 @@ static WC_INLINE int InitMemoryTracker(void)
|
||||
|
||||
#ifdef DO_MEM_LIST
|
||||
XMEMSET(&ourMemList, 0, sizeof(ourMemList));
|
||||
ourMemStats.memList = &ourMemList;
|
||||
|
||||
pthread_mutex_unlock(&memLock);
|
||||
#endif
|
||||
|
||||
@@ -4323,6 +4323,13 @@ extern void uITRON4_free(void *p) ;
|
||||
without staticmemory (WOLFSSL_STATIC_MEMORY)
|
||||
#endif
|
||||
|
||||
/* Undefine WOLFSSL_SMALL_STACK_CACHE if WOLFSSL_SMALL_STACK is undefined --
|
||||
* they only work together.
|
||||
*/
|
||||
#if defined(WOLFSSL_SMALL_STACK_CACHE) && !defined(WOLFSSL_SMALL_STACK)
|
||||
#undef WOLFSSL_SMALL_STACK_CACHE
|
||||
#endif
|
||||
|
||||
/* If malloc is disabled make sure it is also disabled in SP math */
|
||||
#if defined(WOLFSSL_NO_MALLOC) && !defined(WOLFSSL_SP_NO_MALLOC) && \
|
||||
(defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL))
|
||||
|
||||
Reference in New Issue
Block a user