From 365a4de15433428c25152c7b84649c2ac3f8a4ff Mon Sep 17 00:00:00 2001 From: TakayukiMatsuo Date: Wed, 16 Mar 2022 02:12:45 +0900 Subject: [PATCH] Fix settings and removed warnings --- .../RX65N/GR-ROSE/common/wolfssl_dummy.c | 2 +- .../e2studio/RX65N/GR-ROSE/wolfssl/.project | 2 +- .../RX65N/GR-ROSE/wolfssl/wolfssl.rcpc | 2 +- .../e2studio/RX65N/RSK/resource/section.esi | 3 - .../RX65N/RSK/wolfssl_demo/wolfssl_demo.c | 49 ++++++------- .../RX72N/EnvisionKit/resource/section.esi | 3 - .../EnvisionKit/wolfssl_demo/user_settings.h | 2 +- .../EnvisionKit/wolfssl_demo/wolfssl_demo.c | 69 ++++++++++--------- wolfcrypt/src/random.c | 2 +- 9 files changed, 62 insertions(+), 72 deletions(-) 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 6b31d5085..071efddd6 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 2 +#define MON 3 static int tick = 0; diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.project b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.project index 903385898..9642014f8 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.project +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.project @@ -72,7 +72,7 @@ wolfcrypt/port/renesas_common.c 1 - F:/Work/1_Renesas/tsip113_integrate/wolfssl/wolfcrypt/src/port/Renesas/renesas_common.c + PARENT-6-PROJECT_LOC/wolfcrypt/src/port/Renesas/renesas_common.c wolfcrypt/port/renesas_tsip_aes.c diff --git a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc index db2c919a3..eacec0c12 100644 --- a/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc +++ b/IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc @@ -20,7 +20,7 @@ - ..\..\..\..\..\..\..\..\tsip113_integrate\wolfssl\wolfcrypt\src\port\Renesas\renesas_common.c + ..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_common.c ..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_tsip_aes.c ..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_tsip_sha.c ..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_tsip_util.c diff --git a/IDE/Renesas/e2studio/RX65N/RSK/resource/section.esi b/IDE/Renesas/e2studio/RX65N/RSK/resource/section.esi index ca404774e..19ad71371 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/resource/section.esi +++ b/IDE/Renesas/e2studio/RX65N/RSK/resource/section.esi @@ -8,9 +8,6 @@ - - - diff --git a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c index e4348aa9a..198677520 100644 --- a/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c +++ b/IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c @@ -37,42 +37,36 @@ #include "wolfssl/certs_test.h" #include "wolfssl/wolfcrypt/types.h" #include "wolfssl_demo.h" +#include +#include #if defined(BENCHMARK) #include "r_cmt_rx_if.h" #endif +#if defined(TLS_CLIENT) #if defined(WOLFSSL_RENESAS_TSIP_TLS) #include "key_data.h" #include extern const st_key_block_data_t g_key_block_data; - user_PKCbInfo guser_PKCbInfo; -#endif + user_PKCbInfo guser_PKCbInfo; + uint32_t g_encrypted_root_public_key[140]; + static TsipUserCtx userContext; +#endif /* WOLFSSL_RENESAS_TSIP_TLS */ - -#define YEAR 2022 -#define MON 1 -#define FREQ 10000 /* Hz */ + static WOLFSSL_CTX* client_ctx; +#endif /* TLS_CLIENT */ #define TLSSERVER_IP "192.168.1.14" #define TLSSERVER_PORT 11111 - -typedef struct func_args { - int argc; - char** argv; - int return_code; -} func_args; +#define YEAR 2022 +#define MON 3 +#define FREQ 10000 /* Hz */ static long tick; static int tmTick; -static WOLFSSL_CTX* client_ctx; - -#if defined(WOLFSSL_RENESAS_TSIP_TLS) -uint32_t g_encrypted_root_public_key[140]; -static TsipUserCtx userContext; -#endif /* time * returns seconds from EPOCH @@ -86,11 +80,13 @@ time_t time(time_t *t) /* timeTick * called periodically by H/W timer to increase tmTick. */ +#if defined(BENCHMARK) static void timeTick(void* pdata) { (void)pdata; tick++; } +#endif double current_time(int reset) { @@ -98,30 +94,28 @@ double current_time(int reset) return ((double)tick/FREQ) ; } -void wolfcrypt_test(); -void benchmark_test(); - /* --------------------------------------------------------*/ /* Benchmark_demo */ /* --------------------------------------------------------*/ +#if defined(BENCHMARK) static void Benchmark_demo(void) { uint32_t channel; R_CMT_CreatePeriodic(FREQ, &timeTick, &channel); printf("Start wolfCrypt Benchmark\n"); - benchmark_test(); + benchmark_test(NULL); printf("End wolfCrypt Benchmark\n"); } - +#endif /* BENCHMARK */ /* --------------------------------------------------------*/ /* CryptTest_demo */ /* --------------------------------------------------------*/ +#if defined(CRYPT_TEST) static void CryptTest_demo(void) { - func_args args = { 0 }; int ret; if ((ret = wolfCrypt_Init()) != 0) { @@ -129,17 +123,18 @@ static void CryptTest_demo(void) } printf("Start wolfCrypt Test\n"); - wolfcrypt_test(args); + wolfcrypt_test(NULL); printf("End wolfCrypt Test\n"); if ((ret = wolfCrypt_Cleanup()) != 0) { printf("wolfCrypt_Cleanup failed %d\n", ret); } } - +#endif /* CRYPT_TEST */ /* --------------------------------------------------------*/ /* Tls_client_demo */ /* --------------------------------------------------------*/ +#if defined(TLS_CLIENT) static void Tls_client_init(const char* cipherlist) { @@ -392,7 +387,7 @@ static void Tls_client_demo(void) printf("End of TLS_Client demo.\n"); } - +#endif /* TLS_CLIENT */ /* Demo entry function called by iot_demo_runner * To run this entry function as an aws_iot_demo, define this as diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/resource/section.esi b/IDE/Renesas/e2studio/RX72N/EnvisionKit/resource/section.esi index ad826b2f0..719b13033 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/resource/section.esi +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/resource/section.esi @@ -16,9 +16,6 @@ - - - diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h index 699563ef8..369a883e4 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h @@ -105,7 +105,7 @@ * - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA256 * */ - #define USE_ECC_CERT + /*#define USE_ECC_CERT*/ /* In this example application, Root CA cert buffer named * "ca_ecc_cert_der_256" is used under the following macro definition diff --git a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c index bd29b132e..b5c4e1c5e 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_demo.c @@ -37,43 +37,37 @@ #include "wolfssl/certs_test.h" #include "wolfssl/wolfcrypt/types.h" #include "wolfssl_demo.h" +#include +#include #if defined(BENCHMARK) #include "r_cmt_rx_if.h" #endif + +#if defined(TLS_CLIENT) #if defined(WOLFSSL_RENESAS_TSIP_TLS) #include "key_data.h" #include extern const st_key_block_data_t g_key_block_data; - user_PKCbInfo guser_PKCbInfo; -#endif + user_PKCbInfo guser_PKCbInfo; + uint32_t g_encrypted_root_public_key[140]; + static TsipUserCtx userContext; +#endif /* WOLFSSL_RENESAS_TSIP_TLS */ + static WOLFSSL_CTX* client_ctx; +#endif /* TLS_CLIENT */ -#define YEAR 2022 -#define MON 1 -#define FREQ 10000 /* Hz */ - -#define TLSSERVER_IP "192.168.1.14" +#define TLSSERVER_IP "192.168.1.12" #define TLSSERVER_PORT 11111 - -typedef struct func_args { - int argc; - char** argv; - int return_code; -} func_args; +#define YEAR 2022 +#define MON 3 +#define FREQ 10000 /* Hz */ static long tick; static int tmTick; -static WOLFSSL_CTX* client_ctx; - -#if defined(WOLFSSL_RENESAS_TSIP_TLS) -uint32_t g_encrypted_root_public_key[140]; -static TsipUserCtx userContext; -#endif - /* time * returns seconds from EPOCH */ @@ -86,11 +80,13 @@ time_t time(time_t *t) /* timeTick * called periodically by H/W timer to increase tmTick. */ +#if defined(BENCHMARK) static void timeTick(void* pdata) { (void)pdata; tick++; } +#endif double current_time(int reset) { @@ -98,30 +94,30 @@ double current_time(int reset) return ((double)tick/FREQ) ; } -void wolfcrypt_test(); -void benchmark_test(); + /* --------------------------------------------------------*/ /* Benchmark_demo */ /* --------------------------------------------------------*/ +#if defined(BENCHMARK) static void Benchmark_demo(void) { uint32_t channel; R_CMT_CreatePeriodic(FREQ, &timeTick, &channel); printf("Start wolfCrypt Benchmark\n"); - benchmark_test(); + benchmark_test(NULL); printf("End wolfCrypt Benchmark\n"); } - +#endif /* BENCHMARK */ /* --------------------------------------------------------*/ /* CryptTest_demo */ /* --------------------------------------------------------*/ +#if defined(CRYPT_TEST) static void CryptTest_demo(void) { - func_args args = { 0 }; int ret; if ((ret = wolfCrypt_Init()) != 0) { @@ -129,17 +125,18 @@ static void CryptTest_demo(void) } printf("Start wolfCrypt Test\n"); - wolfcrypt_test(args); + wolfcrypt_test(NULL); printf("End wolfCrypt Test\n"); if ((ret = wolfCrypt_Cleanup()) != 0) { printf("wolfCrypt_Cleanup failed %d\n", ret); } } - +#endif /* CRYPT_TEST */ /* --------------------------------------------------------*/ /* Tls_client_demo */ /* --------------------------------------------------------*/ +#if defined(TLS_CLIENT) static void Tls_client_init(const char* cipherlist) { @@ -169,7 +166,8 @@ static void Tls_client_init(const char* cipherlist) #endif /* 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; } @@ -180,7 +178,8 @@ static void Tls_client_init(const char* cipherlist) #if defined(NO_FILESYSTEM) - 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; } @@ -197,7 +196,8 @@ static void Tls_client_init(const char* cipherlist) /* use specific cipher */ if (cipherlist != NULL && - wolfSSL_CTX_set_cipher_list(client_ctx, cipherlist) != WOLFSSL_SUCCESS) { + wolfSSL_CTX_set_cipher_list(client_ctx, cipherlist) != + WOLFSSL_SUCCESS) { wolfSSL_CTX_free(client_ctx); client_ctx = NULL; printf("client can't set cipher list"); } @@ -270,7 +270,8 @@ static void Tls_client() } if (ret == 0) { - if (wolfSSL_write(ssl, sendBuff, strlen(sendBuff)) != strlen(sendBuff)) { + if (wolfSSL_write(ssl, sendBuff, strlen(sendBuff)) != + strlen(sendBuff)) { printf("ERROR wolfSSL_write: %d\n", wolfSSL_get_error(ssl, 0)); ret = -1; } @@ -309,7 +310,7 @@ static void Tls_client() static void Tls_client_demo(void) { - /* setup ciphersuite list to use for TLS handshake */ + /* setup ciphersuite list to use for TLS handshake */ #if defined(WOLFSSL_RENESAS_TSIP_TLS) @@ -344,7 +345,7 @@ static void Tls_client_demo(void) printf("/*------------------------------------------------*/\n"); printf(" TLS_Client demo\n"); printf(" - TLS server address:" TLSSERVER_IP " port: %d\n", - TLSSERVER_PORT ); + TLSSERVER_PORT); #if defined(WOLFSSL_RENESAS_TSIP_TLS) && (WOLFSSL_RENESAS_TSIP_VER >=109) printf(" - with TSIP\n"); @@ -388,7 +389,7 @@ static void Tls_client_demo(void) printf("End of TLS_Client demo.\n"); } - +#endif /* TLS_CLIENT */ /* Demo entry function called by iot_demo_runner * To run this entry function as an aws_iot_demo, define this as diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 330308160..3fdcc8496 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -2500,7 +2500,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) len = sz; } /* return 4 words random number*/ - ret = R_TSIP_GenerateRandomNumber(buffer); + ret = R_TSIP_GenerateRandomNumber((uint32_t*)buffer); if(ret == TSIP_SUCCESS) { XMEMCPY(output, &buffer, len); output += len;