@@ -92,6 +92,7 @@ extern int tolower(int c);
9292# define NO_ED448_EXPORT
9393# define WOLFSSL_SHA3
9494# define WOLFSSL_SHAKE256
95+ # define WOLFSSL_SHA512
9596#endif
9697
9798/* ECC */
@@ -101,8 +102,8 @@ extern int tolower(int c);
101102 defined(WOLFBOOT_SIGN_SECONDARY_ECC256 ) || \
102103 defined(WOLFBOOT_SIGN_SECONDARY_ECC384 ) || \
103104 defined(WOLFBOOT_SIGN_SECONDARY_ECC521 ) || \
104- defined(WOLFCRYPT_SECURE_MODE )
105-
105+ defined(WOLFCRYPT_SECURE_MODE ) || \
106+ defined( WOLFCRYPT_TEST ) || defined( WOLFCRYPT_BENCHMARK )
106107
107108# define HAVE_ECC
108109# define ECC_TIMING_RESISTANT
@@ -118,6 +119,7 @@ extern int tolower(int c);
118119
119120 /* Some ECC options are disabled to reduce size */
120121# if !defined(WOLFCRYPT_SECURE_MODE ) && \
122+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK ) && \
121123 !defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT ) && \
122124 !defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER )
123125# if !defined(WOLFBOOT_TPM )
@@ -138,6 +140,7 @@ extern int tolower(int c);
138140# endif
139141# else
140142# define HAVE_ECC_SIGN
143+ # define HAVE_ECC_VERIFY
141144#ifndef PKCS11_SMALL
142145# define HAVE_ECC_CDH
143146#endif
@@ -147,6 +150,7 @@ extern int tolower(int c);
147150# define WOLFSSL_HAVE_SP_ECC
148151# define WOLFSSL_KEY_GEN
149152# define HAVE_ECC_KEY_EXPORT
153+ # define HAVE_ECC_KEY_IMPORT
150154# endif
151155
152156 /* SP MATH */
@@ -160,15 +164,18 @@ extern int tolower(int c);
160164
161165 /* Curve */
162166# if defined(WOLFBOOT_SIGN_ECC256 ) || defined(WOLFCRYPT_SECURE_MODE ) || \
163- defined(WOLFBOOT_SIGN_SECONDARY_ECC256 )
167+ defined(WOLFBOOT_SIGN_SECONDARY_ECC256 ) || \
168+ defined(WOLFCRYPT_TEST ) || defined(WOLFCRYPT_BENCHMARK )
164169# define HAVE_ECC256
165170# endif
166171# if defined(WOLFBOOT_SIGN_ECC384 ) || \
167172 defined(WOLFBOOT_SIGN_SECONDARY_ECC384 ) || \
168- defined(WOLFCRYPT_SECURE_MODE )
173+ defined(WOLFCRYPT_SECURE_MODE ) || \
174+ defined(WOLFCRYPT_TEST ) || defined(WOLFCRYPT_BENCHMARK )
169175# define HAVE_ECC384
170176# define WOLFSSL_SP_384
171177# endif
178+ /* ECC521 only enabled if specifically requested (not for tests - too large) */
172179# if defined(WOLFBOOT_SIGN_ECC521 ) || \
173180 defined(WOLFBOOT_SIGN_SECONDARY_ECC521 ) || \
174181 defined(WOLFCRYPT_SECURE_MODE )
@@ -219,6 +226,7 @@ extern int tolower(int c);
219226# define RSA_LOW_MEM
220227# define WC_ASN_HASH_SHA256
221228# if !defined(WOLFBOOT_TPM ) && !defined(WOLFCRYPT_SECURE_MODE ) && \
229+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK ) && \
222230 !defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT ) && \
223231 !defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER )
224232# define WOLFSSL_RSA_VERIFY_INLINE
@@ -305,15 +313,17 @@ extern int tolower(int c);
305313#ifdef WOLFBOOT_HASH_SHA3_384
306314# define WOLFSSL_SHA3
307315# if defined(NO_RSA ) && !defined(WOLFBOOT_TPM ) && \
308- !defined(WOLFCRYPT_SECURE_MODE )
316+ !defined(WOLFCRYPT_SECURE_MODE ) && \
317+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
309318# define NO_SHA256
310319# endif
311320#endif
312321
313322#ifdef WOLFBOOT_HASH_SHA384
314323# define WOLFSSL_SHA384
315324# if defined(NO_RSA ) && !defined(WOLFBOOT_TPM ) && \
316- !defined(WOLFCRYPT_SECURE_MODE )
325+ !defined(WOLFCRYPT_SECURE_MODE ) && \
326+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
317327# define NO_SHA256
318328# endif
319329#ifndef WOLFSSL_SHA512
@@ -410,7 +420,8 @@ extern int tolower(int c);
410420
411421#if (defined(WOLFBOOT_TPM_SEAL ) && defined(WOLFBOOT_ATA_DISK_LOCK )) || \
412422 defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT ) || \
413- defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER )
423+ defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER ) || \
424+ defined(WOLFCRYPT_TEST ) || defined(WOLFCRYPT_BENCHMARK )
414425# define WOLFSSL_BASE64_ENCODE
415426#else
416427# define NO_CODING
@@ -464,7 +475,8 @@ extern int tolower(int c);
464475 #endif
465476#endif
466477
467- #if !defined(WOLFCRYPT_SECURE_MODE ) && !defined(WOLFBOOT_TPM_PARMENC )
478+ #if !defined(WOLFCRYPT_SECURE_MODE ) && !defined(WOLFBOOT_TPM_PARMENC ) && \
479+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
468480#if !(defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT ) && \
469481 defined(WOLFBOOT_SIGN_ML_DSA )) && \
470482 !defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER )
@@ -473,23 +485,40 @@ extern int tolower(int c);
473485 #define WC_NO_HASHDRBG
474486 #define NO_AES_CBC
475487#else
476- #define HAVE_HASHDRBG
477- #define WOLFSSL_AES_CFB
488+ #if defined(WOLFCRYPT_TEST ) || defined(WOLFCRYPT_BENCHMARK )
489+ /* Use custom RNG for tests/benchmarks (saves ~7KB vs HASHDRBG).
490+ * WARNING: my_rng_seed_gen is NOT cryptographically secure.
491+ * Only used in test-app builds, not in production wolfBoot. */
492+ #define WC_NO_HASHDRBG
493+ #define CUSTOM_RAND_GENERATE_SEED my_rng_seed_gen
494+ #define CUSTOM_RAND_GENERATE_BLOCK my_rng_seed_gen
495+ extern int my_rng_seed_gen (unsigned char * output , unsigned int sz );
496+ #else
497+ #define HAVE_HASHDRBG
498+ #define WOLFSSL_AES_CFB
499+ #endif
478500#endif
479501
480502
481503#if !defined(ENCRYPT_WITH_AES128 ) && !defined(ENCRYPT_WITH_AES256 ) && \
482- !defined(WOLFBOOT_TPM_PARMENC ) && !defined(WOLFCRYPT_SECURE_MODE )
504+ !defined(WOLFBOOT_TPM_PARMENC ) && !defined(WOLFCRYPT_SECURE_MODE ) && \
505+ !defined(SECURE_PKCS11 ) && !defined(WOLFCRYPT_TZ_PSA ) && \
506+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
483507 #define NO_AES
484508#endif
485509
486- #if !defined(WOLFBOOT_TPM ) && !defined(WOLFCRYPT_SECURE_MODE )
510+ #if !defined(WOLFBOOT_TPM ) && !defined(WOLFCRYPT_SECURE_MODE ) && \
511+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
487512# define NO_HMAC
488- #if !(defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT ) && \
489- defined(WOLFBOOT_SIGN_ML_DSA )) && \
490- !defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER )
491- #define WC_NO_RNG
492513#endif
514+
515+ #if !defined(WOLFBOOT_TPM ) && !defined(WOLFCRYPT_SECURE_MODE ) && \
516+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
517+ # if !(defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT ) && \
518+ defined(WOLFBOOT_SIGN_ML_DSA )) && \
519+ !defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER )
520+ # define WC_NO_RNG
521+ # endif
493522# define WC_NO_HASHDRBG
494523# define NO_DEV_RANDOM
495524# if !defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT ) && \
@@ -534,9 +563,55 @@ extern int tolower(int c);
534563#define NO_CHECK_PRIVATE_KEY
535564#define NO_KDF
536565
537- #define BENCH_EMBEDDED
538- #define NO_CRYPT_TEST
539- #define NO_CRYPT_BENCHMARK
566+ /* wolfCrypt Test/Benchmark Configuration */
567+ #ifdef WOLFCRYPT_TEST
568+ /* Skip extended tests to save memory */
569+ #define NO_CRYPT_TEST_EXTENDED
570+ /* Use smaller certificate buffers */
571+ #define USE_CERT_BUFFERS_256
572+ /* Override default NO_CRYPT_TEST */
573+ #undef NO_CRYPT_TEST
574+ #else
575+ #define NO_CRYPT_TEST
576+ #endif
577+
578+ #ifdef WOLFCRYPT_BENCHMARK
579+ /* Embedded benchmark mode */
580+ #ifndef BENCH_EMBEDDED
581+ #define BENCH_EMBEDDED
582+ #endif
583+ /* Override default NO_CRYPT_BENCHMARK */
584+ #undef NO_CRYPT_BENCHMARK
585+ #else
586+ #define NO_CRYPT_BENCHMARK
587+ #endif
588+
589+ /* Common optimizations when test/benchmark enabled */
590+ #if defined(WOLFCRYPT_TEST ) || defined(WOLFCRYPT_BENCHMARK )
591+ #define NO_WRITE_TEMP_FILES
592+
593+ /* Use static memory pool to avoid system malloc dependency.
594+ * benchmark.c provides gBenchMemory static buffer.
595+ * Default is 50KB with BENCH_EMBEDDED, override for smaller targets */
596+ #ifndef WOLFSSL_STATIC_MEMORY
597+ #define WOLFSSL_STATIC_MEMORY
598+ #endif
599+ #ifndef WOLFSSL_STATIC_MEMORY_TEST_SZ
600+ #define WOLFSSL_STATIC_MEMORY_TEST_SZ (10 * 1024)
601+ #endif
602+
603+ /* Enable SP math digit operations */
604+ #define WOLFSSL_SP_MUL_D
605+
606+ /* User time functions provided */
607+ #define WOLFSSL_USER_CURRTIME
608+ #define XTIME my_time
609+ extern unsigned long my_time (unsigned long * timer );
610+ #endif
611+
612+ #if !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
613+ #define BENCH_EMBEDDED
614+ #endif
540615
541616#if defined(WOLFCRYPT_TZ_PSA )
542617#undef NO_CMAC
@@ -566,7 +641,8 @@ extern int tolower(int c);
566641# define WOLFSSL_SP_NO_DYN_STACK
567642# endif
568643# if !defined(SECURE_PKCS11 ) && !defined(WOLFCRYPT_TZ_PSA ) && \
569- !defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER )
644+ !defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER ) && \
645+ !defined(WOLFCRYPT_TEST ) && !defined(WOLFCRYPT_BENCHMARK )
570646# define NO_WOLFSSL_MEMORY
571647# define WOLFSSL_NO_MALLOC
572648# endif
0 commit comments