diff --git a/src/internal.c b/src/internal.c index 989f9dfc5..4d0488f0b 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2816,7 +2816,7 @@ ProtocolVersion MakeDTLSv1_2(void) return (word32) mqxTime.SECONDS; } -#elif defined(FREESCALE_KSDK_BM) +#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) #include "fsl_pit_driver.h" diff --git a/src/keys.c b/src/keys.c index 124f70ade..3545a5e1c 100644 --- a/src/keys.c +++ b/src/keys.c @@ -32,7 +32,7 @@ #include #include #if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST) - #ifdef FREESCALE_MQX + #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) #if MQX_USE_IO_OLD #include #else diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 6488467b7..1f96f0ac5 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -117,7 +117,7 @@ #define XTIME(t1) mqx_time((t1)) #define XGMTIME(c, t) mqx_gmtime((c), (t)) #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t)) -#elif defined(FREESCALE_KSDK_BM) +#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) #include #define XTIME(t1) ksdk_time((t1)) #define XGMTIME(c, t) gmtime((c)) @@ -373,11 +373,7 @@ struct tm* mqx_gmtime(const time_t* clock, struct tm* tmpTime) #endif /* FREESCALE_MQX */ -#ifdef FREESCALE_KSDK_BM - -/* setting for PIT timer */ -#define PIT_INSTANCE 0 -#define PIT_CHANNEL 0 +#if defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) #include "fsl_pit_driver.h" @@ -3010,7 +3006,8 @@ int ValidateDate(const byte* date, byte format, int dateType) int diffHH = 0 ; int diffMM = 0 ; int diffSign = 0 ; -#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME) +#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \ + defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME) struct tm tmpTimeStorage; tmpTime = &tmpTimeStorage; #else @@ -5999,7 +5996,7 @@ static int CopyValidity(byte* output, Cert* cert) /* for systems where mktime() doesn't normalize fully */ static void RebuildTime(time_t* in, struct tm* out) { - #ifdef FREESCALE_MQX + #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) out = localtime_r(in, out); #else (void)in; @@ -6025,7 +6022,8 @@ static int SetValidity(byte* output, int daysValid) struct tm* tmpTime = NULL; struct tm local; -#if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME) +#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \ + defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME) /* for use with gmtime_r */ struct tm tmpTimeStorage; tmpTime = &tmpTimeStorage; diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index a463cbdef..82df54c33 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -46,7 +46,7 @@ #endif #ifdef SHOW_GEN - #ifdef FREESCALE_MQX + #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) #if MQX_USE_IO_OLD #include #else diff --git a/wolfcrypt/src/logging.c b/wolfcrypt/src/logging.c index 2156b1f43..18b8235e8 100644 --- a/wolfcrypt/src/logging.c +++ b/wolfcrypt/src/logging.c @@ -89,7 +89,7 @@ void wolfSSL_Debugging_OFF(void) #ifdef DEBUG_WOLFSSL -#ifdef FREESCALE_MQX +#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) #if MQX_USE_IO_OLD #include #else diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 3571681db..9147c9dc1 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -114,10 +114,6 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b) #ifndef EBSNET #include #endif - #elif defined(FREESCALE_TRNG) - #define TRNG_INSTANCE (0) - #include "fsl_device_registers.h" - #include "fsl_trng_driver.h" #else /* include headers that may be needed to get good seed */ #endif @@ -1188,6 +1184,15 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return 0; } + + #elif defined(FREESCALE_RNGA) + + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + RNGA_DRV_GetRandomData(RNGA_INSTANCE, output, sz); + return 0; + } + #else #warning "write a real random seed!!!!, just for testing now" diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index ac54c3494..09a3c817c 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -138,7 +138,8 @@ int UnLockMutex(wolfSSL_Mutex *m) #else /* MULTI_THREAD */ - #if defined(FREERTOS) || defined(FREERTOS_TCP) + #if defined(FREERTOS) || defined(FREERTOS_TCP) || \ + defined(FREESCALE_FREE_RTOS) int InitMutex(wolfSSL_Mutex* m) { @@ -390,7 +391,7 @@ int UnLockMutex(wolfSSL_Mutex *m) return 0; } - #elif defined(FREESCALE_MQX) + #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) int InitMutex(wolfSSL_Mutex* m) { diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index b30a2c58f..c14ce259e 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -119,7 +119,7 @@ #include "cavium_ioctl.h" #endif -#ifdef FREESCALE_MQX +#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) #include #include #if MQX_USE_IO_OLD diff --git a/wolfssl/internal.h b/wolfssl/internal.h index ad0d9088b..b36af64d8 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -121,6 +121,8 @@ /* do nothing */ #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) /* do nothing */ +#elif defined(FREESCALE_FREE_RTOS) + #include "fsl_os_abstraction.h" #elif defined(WOLFSSL_uITRON4) /* do nothing */ #elif defined(WOLFSSL_uTKERNEL2) diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 7740a41e8..676a43963 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -610,6 +610,10 @@ static char *fgets(char *buff, int sz, FILE *fp) #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s)) #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));} #define XREALLOC(p, n, h, t) _mem_realloc((p), (n)) /* since MQX 4.1.2 */ + + #define MQX_FILE_PTR FILE * + #define IO_SEEK_SET SEEK_SET + #define IO_SEEK_END SEEK_END #endif #ifdef FREESCALE_KSDK_BM @@ -624,9 +628,8 @@ static char *fgets(char *buff, int sz, FILE *fp) #define FREESCALE_COMMON #define NO_FILESYSTEM #define NO_MAIN_DRIVER - #define XMALLOC(s, h, t) OSA_MemAlloc(s); + #define XMALLOC(s, h, t) OSA_MemAlloc(s);(void)h;(void)t; #define XFREE(p, h, t) {void* xp = (p); if((xp)) OSA_MemFree((xp));} - #define XREALLOC(p, n, h, t) ksdk_realloc((p), (n), (h), (t)); #ifdef FREESCALE_KSDK_BM #error Baremetal and FreeRTOS cannot be both enabled at the same time! #endif @@ -638,24 +641,46 @@ static char *fgets(char *buff, int sz, FILE *fp) #ifdef FREESCALE_COMMON #define SIZEOF_LONG_LONG 8 + + /* disable features */ #define NO_WRITEV #define NO_DEV_RANDOM #define NO_RABBIT #define NO_WOLFSSL_DIR + + /* enable features */ #define USE_FAST_MATH + + /* memory reduction */ #define TFM_TIMING_RESISTANT - #if FSL_FEATURE_SOC_ENET_COUNT == 0 - #define WOLFSSL_USER_IO + /* setting for PIT timer */ + #define PIT_INSTANCE 0 + #define PIT_CHANNEL 0 + + /* CW GCC workaround. gmtime() is not available */ + #if defined(__GNUC__) + #define USER_TIME + #endif + + #if defined(FREESCALE_KSDK_MQX) || defined(FREESCALE_KSDK_BM) || \ + defined(FREESCALE_FREE_RTOS) + #include "fsl_device_registers.h" #endif /* random seed */ #define NO_OLD_RNGNAME - #if FSL_FEATURE_SOC_TRNG_COUNT > 0 + #if (FSL_FEATURE_SOC_TRNG_COUNT > 0) #define FREESCALE_TRNG + #define TRNG_INSTANCE (0) + #elif (FSL_FEATURE_SOC_RNG_COUNT > 0) + #include "fsl_rnga_driver.h" + #define FREESCALE_RNGA + #define RNGA_INSTANCE (0) #elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS) - #define FREESCALE_K70_RNGA + /* defaulting to K70 RNGA, user should change if different */ /* #define FREESCALE_K53_RNGB */ + #define FREESCALE_K70_RNGA #endif /* HW crypto */ diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index ded4def53..221108a72 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -198,7 +198,7 @@ WOLFSSL_API int wolfCrypt_Init(void); #define XFCLOSE fs_close #define XSEEK_END 0 #define XBADFILE NULL -#elif defined(FREESCALE_MQX) +#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) #define XFILE MQX_FILE_PTR #define XFOPEN fopen #define XFSEEK fseek