diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h index 36b6a9a94..ac85878e7 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h @@ -124,6 +124,15 @@ *----------------------------------------------------------------------------*/ #define SIZEOF_LONG_LONG 8 + /*#define WOLFSSL_STATIC_MEMORY*/ + + #if defined(WOLFSSL_STATIC_MEMORY) + #define USE_FAST_MATH + #else + #define WOLFSSL_SMALL_STACK + #endif /* WOLFSSL_STATIC_MEMORY */ + + #if !defined(min) #define min(data1, data2) _builtin_min(data1, data2) #endif @@ -145,7 +154,7 @@ #define WOLFSSL_LOG_PRINTF #define WOLFSSL_HAVE_MIN #define WOLFSSL_HAVE_MAX - #define WOLFSSL_SMALL_STACK + #define NO_WRITEV #define WOLFSSL_USER_IO @@ -220,3 +229,6 @@ #define HAVE_HKDF #define WC_RSA_PSS #endif + + +#define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c index 071efddd6..7c51a4afd 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c @@ -22,7 +22,7 @@ typedef unsigned long time_t; #define YEAR 2022 -#define MON 3 +#define MON 5 static int tick = 0; diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/.cproject b/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/.cproject index a973bd1b4..37d0a3623 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/.cproject +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/.cproject @@ -23,13 +23,13 @@ - - - - - - - - - - - - - - - - - - - - @@ -133,6 +134,11 @@ + + @@ -143,4 +149,5 @@ + \ No newline at end of file diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg b/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg index d0df28d6d..393a20ac4 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/smc/smc.scfg @@ -4,13 +4,12 @@ - - @@ -24,13 +24,13 @@ - - - - - - - - - - - - - - - - - - - - - @@ -194,7 +195,11 @@ - + + @@ -218,13 +223,13 @@ - - - - - - - - - - - - - - - - - - - - - @@ -336,6 +342,11 @@ + + diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/.project b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/.project index 567eaad89..67b4f6d77 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/.project +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/.project @@ -32,12 +32,12 @@ src/benchmark.c 1 - $%7BPARENT-6-PROJECT_LOC%7D/wolfcrypt/benchmark/benchmark.c + PARENT-6-PROJECT_LOC/wolfcrypt/benchmark/benchmark.c src/benchmark.h 1 - $%7BPARENT-6-PROJECT_LOC%7D/wolfcrypt/benchmark/benchmark.h + PARENT-6-PROJECT_LOC/wolfcrypt/benchmark/benchmark.h src/test.c diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c index c1b3523c4..7c1450fe4 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/test_main.c @@ -52,6 +52,17 @@ extern "C" { user_PKCbInfo guser_PKCbInfo; #endif +#if defined(TLS_CLIENT) +#if defined(WOLFSSL_RENESAS_TSIP_TLS) && defined(WOLFSSL_STATIC_MEMORY) + #include + WOLFSSL_HEAP_HINT* heapHint = NULL; + + #define BUFFSIZE_GEN (110 * 1024) + unsigned char heapBufGen[BUFFSIZE_GEN]; + +#endif /* WOLFSSL_RENESAS_TSIP_TLS && WOLFSSL_STATIC_MEMORY */ +#endif /* TLS_CLIENT */ + static long tick; static void timeTick(void *pdata) { @@ -243,6 +254,15 @@ void main(void) #elif defined(TLS_CLIENT) #include "r_cmt_rx_if.h" + +#if defined(WOLFSSL_STATIC_MEMORY) + if (wc_LoadStaticMemory(&heapHint, heapBufGen, sizeof(heapBufGen), + WOLFMEM_GENERAL, 1) !=0) { + printf("unable to load static memory.\n"); + return; + } +#endif /* WOLFSSL_STATIC_MEMORY */ + Open_tcp(); #if defined(WOLFSSL_RENESAS_TSIP_TLS) diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c index c1fe033c2..c1491f0c5 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c @@ -29,7 +29,7 @@ #include "wolfssl_demo.h" -#define SIMPLE_TLSSEVER_IP "192.168.11.32" +#define SIMPLE_TLSSEVER_IP "192.168.1.12" #define SIMPLE_TLSSERVER_PORT "11111" ER t4_tcp_callback(ID cepid, FN fncd , VP p_parblk); @@ -41,6 +41,17 @@ uint32_t g_encrypted_root_public_key[140]; static TsipUserCtx userContext; #endif +#if defined(TLS_CLIENT) +#if defined(WOLFSSL_RENESAS_TSIP_TLS) && defined(WOLFSSL_STATIC_MEMORY) + + extern WOLFSSL_HEAP_HINT* heapHint; + + #define BUFFSIZE_IO (16 * 1024) + unsigned char heapBufIO[BUFFSIZE_IO]; + +#endif /* WOLFSSL_RENESAS_TSIP_TLS && WOLFSSL_STATIC_MEMORY */ +#endif /* TLS_CLIENT */ + static int my_IORecv(WOLFSSL* ssl, char* buff, int sz, void* ctx) { int ret; @@ -115,11 +126,29 @@ void wolfSSL_TLS_client_init(const char* cipherlist) wolfSSL_Debugging_ON(); #endif +#if defined(WOLFSSL_STATIC_MEMORY) + + if ((client_ctx = wolfSSL_CTX_new_ex(wolfTLSv1_2_client_method_ex(heapHint), + heapHint)) == NULL) { + printf("ERROR: faild to create WOLFSSL_CTX\n"); + return; + } + + if ((wolfSSL_CTX_load_static_memory(&client_ctx, NULL, heapBufIO, + sizeof(heapBufIO), WOLFMEM_IO_POOL, 10)) != WOLFSSL_SUCCESS) { + printf("ERROR: faild to set static memory for IO\n"); + return; + } + +#else + /* Create and initialize WOLFSSL_CTX */ - if ((client_ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method_ex((void *)NULL))) == NULL) { + if ((client_ctx = + wolfSSL_CTX_new(wolfTLSv1_2_client_method_ex((void *)NULL))) == NULL) { printf("ERROR: failed to create WOLFSSL_CTX\n"); return; } +#endif /* WOLFSSL_STATIC_MEMORY */ #ifdef WOLFSSL_RENESAS_TSIP_TLS tsip_set_callbacks(client_ctx); @@ -128,10 +157,11 @@ void wolfSSL_TLS_client_init(const char* cipherlist) #if !defined(NO_FILESYSTEM) if (wolfSSL_CTX_load_verify_locations(client_ctx, cert, 0) != SSL_SUCCESS) { printf("ERROR: can't load \"%s\"\n", cert); - return NULL; + return; } #else - if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT, SSL_FILETYPE_ASN1) != SSL_SUCCESS){ + if (wolfSSL_CTX_load_verify_buffer(client_ctx, cert, SIZEOF_CERT, + SSL_FILETYPE_ASN1) != SSL_SUCCESS){ printf("ERROR: can't load certificate data\n"); return; } diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test.rcpc b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test.rcpc index d2d924404..733e5b343 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test.rcpc +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test.rcpc @@ -7,6 +7,19 @@ + + generate\dbsct.c + generate\hwsetup.c + generate\intprg.c + generate\iodefine.h + generate\resetprg.c + generate\sbrk.c + generate\sbrk.h + generate\stacksct.h + generate\typedefine.h + generate\vect.h + generate\vecttbl.c + ..\..\..\..\..\..\wolfcrypt\benchmark\benchmark.c ..\..\..\..\..\..\wolfcrypt\benchmark\benchmark.h @@ -243,21 +256,18 @@ src\smc_gen\r_tsip_rx\readme.txt - src\smc_gen\r_tsip_rx\doc\en\r20an0548ej0114-rx-tsip-security.pdf + src\smc_gen\r_tsip_rx\doc\en\r20an0548ej0115-rx-tsip-security.pdf - src\smc_gen\r_tsip_rx\doc\ja\r20an0548jj0114-rx-tsip-security.pdf + src\smc_gen\r_tsip_rx\doc\ja\r20an0548jj0115-rx-tsip-security.pdf - - src\smc_gen\r_tsip_rx\ref\r_tsip_rx_config_reference.h - R5F565NEHxFP - + @@ -281,6 +291,7 @@ + @@ -316,7 +327,7 @@ - + Auto @@ -374,6 +385,12 @@ HardwareDebug\wolfssl_dummy.obj HardwareDebug\test.lib + + + + + + "${ProjDirPath}\..\common" "${ProjDirPath}\..\..\..\..\..\..\" @@ -393,6 +410,7 @@ "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\general" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\r_pincfg" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\Config_TMR0" + "${ProjDirPath}\generate" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\general" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\r_pincfg" DEBUG_CONSOLE @@ -421,6 +439,7 @@ + @@ -511,6 +530,12 @@ Debug\wolfssl_dummy.obj Debug\test.lib + + + + + + "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\r_bsp" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\r_config" @@ -529,6 +554,7 @@ "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\r_sys_time_rx\src" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\general" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\generate" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\general" "${ProjDirPath}\..\..\..\..\..\..\..\${ProjName}\src\smc_gen\r_pincfg" DEBUG_CONSOLE diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test_HardwareDebug.launch b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test_HardwareDebug.launch index ebc09c918..a6d705f80 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test_HardwareDebug.launch +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/test/test_HardwareDebug.launch @@ -20,12 +20,12 @@ - + - + @@ -36,7 +36,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -131,6 +131,6 @@ - + diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.cproject b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.cproject index 84b50cc25..1e04e49da 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.cproject +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.cproject @@ -14,7 +14,7 @@ @@ -24,21 +24,25 @@ - - - - - + + + + + - - + + + - + - + @@ -88,7 +127,11 @@ - + + diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc index eacec0c12..2fa605c3d 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc @@ -87,12 +87,13 @@ - R5F571MLCxFC - + R5F565NEHxFP + + @@ -100,8 +101,10 @@ + + @@ -111,6 +114,8 @@ + + diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c b/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c index bcf047c8f..d6a58de6e 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_sha.c @@ -32,12 +32,16 @@ #if defined(WOLFSSL_RENESAS_TSIP_CRYPT) +#include #include #include + #if !defined(NO_SHA) && !defined(NO_WOLFSSL_RENESAS_TSIP_CRYPT_HASH) #include +extern struct WOLFSSL_HEAP_HINT* tsip_heap_hint; + static void TSIPHashFree(wolfssl_TSIP_Hash* hash) { if (hash == NULL) @@ -59,7 +63,13 @@ static int TSIPHashInit(wolfssl_TSIP_Hash* hash, void* heap, int devId, (void)devId; XMEMSET(hash, 0, sizeof(wolfssl_TSIP_Hash)); - hash->heap = heap; + if (heap == NULL && tsip_heap_hint != NULL) { + hash->heap = (struct wolfSSL_HEAP_HINT*)tsip_heap_hint; + } + else { + hash->heap = heap; + } + hash->len = 0; hash->used = 0; hash->msg = NULL; diff --git a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c index 620ecd91d..443b71497 100644 --- a/wolfcrypt/src/port/Renesas/renesas_tsip_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_tsip_util.c @@ -52,9 +52,10 @@ extern uint32_t s_inst1[R_TSIP_SINST_WORD_SIZE]; wolfSSL_Mutex tsip_mutex; static int tsip_CryptHwMutexInit_ = 0; -static const byte* ca_cert_sig; +static const byte* ca_cert_sig = NULL; static tsip_key_data g_user_key_info; +struct WOLFSSL_HEAP_HINT* tsip_heap_hint = NULL; /* tsip only keep one encrypted ca public key */ #if defined(WOLFSSL_RENESAS_TSIP_TLS) @@ -409,6 +410,12 @@ WOLFSSL_API void tsip_set_callbacks(struct WOLFSSL_CTX* ctx) wolfSSL_CTX_SetRsaEncCb(ctx, Renesas_cmn_RsaEnc); wolfSSL_CTX_SetVerifyMacCb(ctx, (CallbackVerifyMac)Renesas_cmn_VerifyHmac); wolfSSL_CTX_SetEccSharedSecretCb(ctx, NULL); + + /* set heap-hint to tsip_heap_hint so that tsip sha funcs can refer it */ + if (ctx->heap != NULL) { + tsip_heap_hint = ctx->heap; + } + WOLFSSL_LEAVE("tsip_set_callbacks", 0); }