From 493022b4b443ccd975a0af5771af3af71e5b5035 Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Thu, 8 Aug 2024 18:34:36 +0900 Subject: [PATCH 1/2] revert 2b4acf5027a fix build failure when no using TSIP --- .../RX72N/EnvisionKit/wolfssl_demo/user_settings.h | 3 +++ src/ssl_asn1.c | 3 ++- wolfcrypt/src/random.c | 12 ------------ 3 files changed, 5 insertions(+), 13 deletions(-) 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 5d4c2f341f..e79fe041ab 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h @@ -263,6 +263,9 @@ #else #define OPENSSL_EXTRA #define WOLFSSL_GENSEED_FORTEST /* Warning: define your own seed gen */ + #if !defined(min) + #define min(data1, data2) _builtin_min(data1, data2) + #endif #endif diff --git a/src/ssl_asn1.c b/src/ssl_asn1.c index 74e1381254..e9c4840d10 100644 --- a/src/ssl_asn1.c +++ b/src/ssl_asn1.c @@ -3545,6 +3545,7 @@ WOLFSSL_ASN1_TIME* wolfSSL_ASN1_TIME_to_generalizedtime(WOLFSSL_ASN1_TIME *t, return ret; } +#if !defined(USER_TIME) && !defined(TIME_OVERRIDES) WOLFSSL_ASN1_TIME* wolfSSL_ASN1_UTCTIME_set(WOLFSSL_ASN1_TIME *s, time_t t) { WOLFSSL_ASN1_TIME* ret = s; @@ -3570,7 +3571,7 @@ WOLFSSL_ASN1_TIME* wolfSSL_ASN1_UTCTIME_set(WOLFSSL_ASN1_TIME *s, time_t t) return ret; } - +#endif /* !USER_TIME && !TIME_OVERRIDES */ #endif /* OPENSSL_EXTRA */ #if defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_EXTRA) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 822f069f7f..ef4713de66 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -126,9 +126,6 @@ This library contains implementation for the random number generator. #elif defined(WOLFSSL_PB) #elif defined(WOLFSSL_ZEPHYR) #elif defined(WOLFSSL_TELIT_M2MB) -#elif defined(WOLFSSL_RENESAS_TSIP) - /* for wc_tsip_GenerateRandBlock */ - #include "wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h" #elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG) #elif defined(WOLFSSL_IMXRT1170_CAAM) #elif defined(CY_USING_HAL) && defined(COMPONENT_WOLFSSL) @@ -3655,15 +3652,6 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return 0; } -#elif defined(WOLFSSL_RENESAS_TSIP) - - int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) - { - (void)os; - return wc_tsip_GenerateRandBlock(output, sz); - } - - #elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG) #include "hal_data.h" From debbea384326631fb16053c34ce85a53df348c6a Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Sat, 10 Aug 2024 06:45:18 +0900 Subject: [PATCH 2/2] put back the RNG comment to CUSTOM RAND GENERATE BLOCK --- .../RX72N/EnvisionKit/wolfssl_demo/user_settings.h | 10 ++++++++-- wolfcrypt/src/random.c | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) 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 e79fe041ab..e9199f02b1 100644 --- a/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h +++ b/IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h @@ -259,7 +259,14 @@ # undef WOLFSSL_RENESAS_TSIP_TLS # undef WOLFSSL_RENESAS_TSIP_CRYPT #endif - + /*------------------------------------------------------------------------- + * TSIP generates random numbers using the CRT-DRBG described + * in NIST SP800-90A. Recommend to define the CUSTOM_RAND_GENERATE_BLOCK + * so that wc_RNG_GenerateByte/Block() call TSIP random generatoion API + * directly. Comment out the macro will generate random number by + * wolfSSL Hash DRBG by using a seed which is generated by TSIP API. + *-----------------------------------------------------------------------*/ + #define CUSTOM_RAND_GENERATE_BLOCK wc_tsip_GenerateRandBlock #else #define OPENSSL_EXTRA #define WOLFSSL_GENSEED_FORTEST /* Warning: define your own seed gen */ @@ -279,6 +286,5 @@ /*-- strcasecmp */ #define XSTRCASECMP(s1,s2) strcmp((s1),(s2)) -#define CUSTOM_RAND_GENERATE_BLOCK wc_tsip_GenerateRandBlock /* use original ASN parsing */ #define WOLFSSL_ASN_ORIGINAL diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index ef4713de66..822f069f7f 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -126,6 +126,9 @@ This library contains implementation for the random number generator. #elif defined(WOLFSSL_PB) #elif defined(WOLFSSL_ZEPHYR) #elif defined(WOLFSSL_TELIT_M2MB) +#elif defined(WOLFSSL_RENESAS_TSIP) + /* for wc_tsip_GenerateRandBlock */ + #include "wolfssl/wolfcrypt/port/Renesas/renesas-tsip-crypt.h" #elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG) #elif defined(WOLFSSL_IMXRT1170_CAAM) #elif defined(CY_USING_HAL) && defined(COMPONENT_WOLFSSL) @@ -3652,6 +3655,15 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return 0; } +#elif defined(WOLFSSL_RENESAS_TSIP) + + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + (void)os; + return wc_tsip_GenerateRandBlock(output, sz); + } + + #elif defined(WOLFSSL_SCE) && !defined(WOLFSSL_SCE_NO_TRNG) #include "hal_data.h"