forked from wolfSSL/wolfssl
Add support for the Infineon/Cypress HAL TRNG.
This commit is contained in:
@@ -37,6 +37,8 @@ extern "C" {
|
|||||||
#define NO_WRITEV
|
#define NO_WRITEV
|
||||||
#define NO_MAIN_DRIVER
|
#define NO_MAIN_DRIVER
|
||||||
#define WOLFSSL_IGNORE_FILE_WARN /* ignore file include warnings */
|
#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) */
|
/* TLS (allow TLS v1.3 or v1.2) */
|
||||||
#define WOLFSSL_TLS13
|
#define WOLFSSL_TLS13
|
||||||
@@ -132,6 +134,13 @@ extern "C" {
|
|||||||
#define HAVE_X963_KDF
|
#define HAVE_X963_KDF
|
||||||
#define WOLFSSL_BASE64_ENCODE
|
#define WOLFSSL_BASE64_ENCODE
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
#define HAVE_SESSION_TICKETS
|
||||||
|
#define SMALL_SESSION_CACHE
|
||||||
|
#else
|
||||||
|
#define NO_SESSION_CACHE
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Disables */
|
/* Disables */
|
||||||
#define NO_PKCS8
|
#define NO_PKCS8
|
||||||
#define NO_PKCS12
|
#define NO_PKCS12
|
||||||
@@ -145,9 +154,12 @@ extern "C" {
|
|||||||
#define WOLFSSL_NO_SHAKE128
|
#define WOLFSSL_NO_SHAKE128
|
||||||
#define WOLFSSL_NO_SHAKE256
|
#define WOLFSSL_NO_SHAKE256
|
||||||
|
|
||||||
/* Low Resource Options */
|
/* Logging */
|
||||||
|
#ifdef ENABLE_SECURE_SOCKETS_LOGS
|
||||||
|
#define DEBUG_WOLFSSL
|
||||||
|
#else
|
||||||
#define NO_ERROR_STRINGS
|
#define NO_ERROR_STRINGS
|
||||||
#define NO_SESSION_CACHE
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -128,6 +128,8 @@ This library contains implementation for the random number generator.
|
|||||||
#elif defined(WOLFSSL_TELIT_M2MB)
|
#elif defined(WOLFSSL_TELIT_M2MB)
|
||||||
#elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG)
|
#elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG)
|
||||||
#elif defined(WOLFSSL_IMXRT1170_CAAM)
|
#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)
|
#elif defined(WOLFSSL_GETRANDOM)
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
@@ -3832,6 +3834,40 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
return ret;
|
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) || \
|
#elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \
|
||||||
defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \
|
defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \
|
||||||
defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \
|
defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \
|
||||||
|
Reference in New Issue
Block a user