diff --git a/IDE/Infineon/user_settings.h b/IDE/Infineon/user_settings.h index f15c0ebfa..62f89b7c0 100644 --- a/IDE/Infineon/user_settings.h +++ b/IDE/Infineon/user_settings.h @@ -37,6 +37,8 @@ extern "C" { #define NO_WRITEV #define NO_MAIN_DRIVER #define WOLFSSL_IGNORE_FILE_WARN /* ignore file include warnings */ +#define WOLFSSL_SMALL_STACK /* limit stack usage */ +#define BENCH_EMBEDDED /* TLS (allow TLS v1.3 or v1.2) */ #define WOLFSSL_TLS13 @@ -132,6 +134,13 @@ extern "C" { #define HAVE_X963_KDF #define WOLFSSL_BASE64_ENCODE +#if 1 + #define HAVE_SESSION_TICKETS + #define SMALL_SESSION_CACHE +#else + #define NO_SESSION_CACHE +#endif + /* Disables */ #define NO_PKCS8 #define NO_PKCS12 @@ -145,9 +154,12 @@ extern "C" { #define WOLFSSL_NO_SHAKE128 #define WOLFSSL_NO_SHAKE256 -/* Low Resource Options */ -#define NO_ERROR_STRINGS -#define NO_SESSION_CACHE +/* Logging */ +#ifdef ENABLE_SECURE_SOCKETS_LOGS + #define DEBUG_WOLFSSL +#else + #define NO_ERROR_STRINGS +#endif #ifdef __cplusplus } diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index d44f2e2d2..5e97e9104 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -128,6 +128,8 @@ This library contains implementation for the random number generator. #elif defined(WOLFSSL_TELIT_M2MB) #elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG) #elif defined(WOLFSSL_IMXRT1170_CAAM) +#elif defined(CY_USING_HAL) && defined(COMPONENT_WOLFSSL) + #include "cyhal_trng.h" /* Infineon/Cypress HAL RNG implementation */ #elif defined(WOLFSSL_GETRANDOM) #include #include @@ -3832,6 +3834,40 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return ret; } +#elif defined(CY_USING_HAL) && defined(COMPONENT_WOLFSSL) + + /* Infineon/Cypress HAL RNG implementation */ + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + cyhal_trng_t obj; + cy_rslt_t result; + uint32_t val; + word32 i = 0; + + (void)os; + + result = cyhal_trng_init(&obj); + if (result == CY_RSLT_SUCCESS) { + while (i < sz) { + /* If not aligned or there is odd/remainder add single byte */ + if( (i + sizeof(word32)) > sz || + ((wc_ptr_t)&output[i] % sizeof(word32)) != 0 + ) { + val = cyhal_trng_generate(&obj); + output[i++] = (byte)val; + } + else { + /* Use native 32 instruction */ + val = cyhal_trng_generate(&obj); + *((uint32_t*)&output[i]) = val; + i += sizeof(word32); + } + } + cyhal_trng_free(&obj); + } + return 0; + } + #elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \ defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \ defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \