Skip to content

Commit 27a5976

Browse files
authored
Merge pull request #6520 from miyazakh/tsip_cryptonly
Support TSIP crypt only
2 parents 1468d77 + 02ec92a commit 27a5976

40 files changed

Lines changed: 1373 additions & 506 deletions

IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,28 @@
220220

221221
#if defined(WOLFSSL_RENESAS_TSIP)
222222

223+
/*-- TSIP TLS and/or CRYPTONLY Definition --------------------------------*/
224+
/* Enable TSIP TLS (default)
225+
* TSIP CRYPTONLY is also enabled.
226+
* Disable TSIP TLS
227+
* TSIP CRYPTONLY is only enabled.
228+
*/
229+
#define WOLFSSL_RENESAS_TSIP_TLS
230+
223231
#if !defined(NO_RENESAS_TSIP_CRYPT)
224-
#define WOLFSSL_RENESAS_TSIP_CRYPT
225-
#define WOLFSSL_RENESAS_TSIP_TLS
226-
#define WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT
232+
#define WOLFSSL_RENESAS_TSIP_CRYPTONLY
227233
#define HAVE_PK_CALLBACKS
228234
#define WOLF_CRYPTO_CB
229-
#define WOLF_PRIVATE_KEY_ID
235+
#if defined(WOLFSSL_RENESAS_TSIP_TLS)
236+
#define WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT
237+
#define WOLF_PRIVATE_KEY_ID
238+
#endif
239+
#endif
240+
241+
#if !defined(WOLFSSL_RENESAS_TSIP_TLS) && \
242+
defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY)
243+
# undef WOLFSSL_RENESAS_TSIP_TLS
244+
# undef WOLFSSL_RENESAS_TSIP_CRYPT
230245
#endif
231246

232247
#else
@@ -244,3 +259,8 @@
244259

245260

246261
#define XSTRCASECMP(s1,s2) strcmp((s1),(s2))
262+
263+
#if !defined(WOLFSSL_RENESAS_TSIP_TLS)
264+
#define min(x,y) ((x)<(y)?(x):(y))
265+
#endif
266+

IDE/Renesas/e2studio/RX65N/GR-ROSE/common/wolfssl_dummy.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <wolfssl/wolfcrypt/wc_port.h>
2323

24-
#define YEAR 2022
24+
#define YEAR 2023
2525
#define MON 6
2626

2727
static int tick = 0;
@@ -40,3 +40,12 @@ int strncasecmp(const char *s1, const char * s2, unsigned int sz)
4040
return 1;
4141
return 0;
4242
}
43+
44+
#if !defined(WOLFSSL_RENESAS_TSIP)
45+
/* dummy return true when char is alphanumeric character */
46+
int isascii(const char *s)
47+
{
48+
return isalnum(s);
49+
}
50+
#endif
51+

IDE/Renesas/e2studio/RX65N/GR-ROSE/test/src/wolf_client.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,18 @@ void wolfSSL_TLS_client( )
285285
#ifdef WOLFSSL_RENESAS_TSIP_TLS
286286

287287
/* TSIP specific ECC private key */
288-
if (tsip_use_PrivateKey_buffer(ssl,
288+
if (tsip_use_PrivateKey_buffer_TLS(ssl,
289289
(const char*)g_key_block_data.encrypted_user_ecc256_private_key,
290290
sizeof(g_key_block_data.encrypted_user_ecc256_private_key),
291291
TSIP_ECCP256) != 0) {
292-
printf("ERROR tsip_use_PrivateKey_buffer\n");
292+
printf("ERROR tsip_use_PrivateKey_buffer_TLS\n");
293293
goto out;
294294
}
295295

296296
#else
297297

298298
/* DER format ECC private key */
299-
if (wolfSSL_use_PrivateKey_buffer(ssl,
299+
if (wolfSSL_use_PrivateKey_buffer(ssl,
300300
ecc_clikey_der_256,
301301
sizeof_ecc_clikey_der_256,
302302
WOLFSSL_FILETYPE_ASN1) != SSL_SUCCESS) {
@@ -314,20 +314,20 @@ void wolfSSL_TLS_client( )
314314
/* Note: TSIP asks client key pair for client authentication. */
315315

316316
/* TSIP specific RSA private key */
317-
if (tsip_use_PrivateKey_buffer(ssl,
317+
if (tsip_use_PrivateKey_buffer_TLS(ssl,
318318
(const char*)g_key_block_data.encrypted_user_rsa2048_private_key,
319319
sizeof(g_key_block_data.encrypted_user_rsa2048_private_key),
320320
TSIP_RSA2048) != 0) {
321-
printf("ERROR tsip_use_PrivateKey_buffer\n");
321+
printf("ERROR tsip_use_PrivateKey_buffer_TLS\n");
322322
goto out;
323323
}
324324

325325
/* TSIP specific RSA public key */
326-
if (tsip_use_PublicKey_buffer(ssl,
326+
if (tsip_use_PublicKey_buffer_TLS(ssl,
327327
(const char*)g_key_block_data.encrypted_user_rsa2048_public_key,
328328
sizeof(g_key_block_data.encrypted_user_rsa2048_public_key),
329329
TSIP_RSA2048) != 0) {
330-
printf("ERROR tsip_use_PublicKey_buffer\n");
330+
printf("ERROR tsip_use_PublicKey_buffer_TLS\n");
331331
goto out;
332332
}
333333

IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/.project

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
<type>1</type>
8080
<locationURI>PARENT-6-PROJECT_LOC/wolfcrypt/src/port/Renesas/renesas_tsip_aes.c</locationURI>
8181
</link>
82+
<link>
83+
<name>wolfcrypt/port/renesas_tsip_rsa.c</name>
84+
<type>1</type>
85+
<locationURI>PARENT-6-PROJECT_LOC/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c</locationURI>
86+
</link>
8287
<link>
8388
<name>wolfcrypt/port/renesas_tsip_sha.c</name>
8489
<type>1</type>

IDE/Renesas/e2studio/RX65N/GR-ROSE/wolfssl/wolfssl.rcpc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<Category Name="port">
2323
<Path>..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_common.c</Path>
2424
<Path>..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_tsip_aes.c</Path>
25+
<Path>..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_tsip_rsa.c</Path>
2526
<Path>..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_tsip_sha.c</Path>
2627
<Path>..\..\..\..\..\..\wolfcrypt\src\port\Renesas\renesas_tsip_util.c</Path>
2728
</Category>
@@ -143,6 +144,7 @@
143144
<Path>Debug\wolfio.obj</Path>
144145
<Path>Debug\renesas_common.obj</Path>
145146
<Path>Debug\renesas_tsip_aes.obj</Path>
147+
<Path>Debug\renesas_tsip_rsa.obj</Path>
146148
<Path>Debug\renesas_tsip_sha.obj</Path>
147149
<Path>Debug\renesas_tsip_util.obj</Path>
148150
<Path>Debug\aes.obj</Path>

IDE/Renesas/e2studio/RX65N/RSK/resource/section.esi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@
88
<sections name="R_2"/>
99
<sections name="R"/>
1010
<sections name="RPFRAM2"/>
11+
<sections name="B_ETHERNET_BUFFERS_1">
12+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="65536"/>
13+
</sections>
14+
<sections name="B_RX_DESC_1"/>
15+
<sections name="B_TX_DESC_1"/>
16+
<sections name="C_FIRMWARE_UPDATE_CONTROL_BLOCK">
17+
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="1048576"/>
18+
</sections>
19+
<sections name="C_FIRMWARE_UPDATE_CONTROL_BLOCK_MIRROR"/>
1120
<sections name="C_PKCS11_STORAGE*">
1221
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="1050624"/>
1322
</sections>
1423
<sections name="C_SYSTEM_CONFIG*">
1524
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="1067008"/>
1625
</sections>
17-
<sections name="B_ETHERNET_BUFFERS_1">
26+
<sections name="B">
1827
<sectionAddress xsi:type="com.renesas.linkersection.model:FixedAddress" fixedAddress="8388608"/>
1928
</sections>
20-
<sections name="B_RX_DESC_1"/>
21-
<sections name="B_TX_DESC_1"/>
22-
<sections name="B"/>
2329
<sections name="B_1"/>
2430
<sections name="B_2"/>
2531
<sections name="C_1">

IDE/Renesas/e2studio/RX65N/RSK/wolfssl/.project

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
<type>1</type>
8080
<locationURI>PARENT-6-PROJECT_LOC/wolfcrypt/src/port/Renesas/renesas_tsip_aes.c</locationURI>
8181
</link>
82+
<link>
83+
<name>wolfcrypt/port/renesas_tsip_rsa.c</name>
84+
<type>1</type>
85+
<locationURI>PARENT-6-PROJECT_LOC/wolfcrypt/src/port/Renesas/renesas_tsip_rsa.c</locationURI>
86+
</link>
8287
<link>
8388
<name>wolfcrypt/port/renesas_tsip_sha.c</name>
8489
<type>1</type>

IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/key_data.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,4 @@ const unsigned char client_cert_der_sign[] =
267267
};
268268
const int sizeof_client_cert_der_sign = sizeof(client_cert_der_sign);
269269

270-
uint32_t s_inst1[R_TSIP_SINST_WORD_SIZE] = { 0 };
271-
uint32_t s_inst2[R_TSIP_SINST2_WORD_SIZE]= { 0 };
272270
#endif

IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,28 @@
224224

225225
#if defined(WOLFSSL_RENESAS_TSIP)
226226

227+
/*-- TSIP TLS and/or CRYPTONLY Definition --------------------------------*/
228+
/* Enable TSIP TLS (default)
229+
* TSIP CRYPTONLY is also enabled.
230+
* Disable TSIP TLS
231+
* TSIP CRYPTONLY is only enabled.
232+
*/
233+
#define WOLFSSL_RENESAS_TSIP_TLS
234+
227235
#if !defined(NO_RENESAS_TSIP_CRYPT)
228-
#define WOLFSSL_RENESAS_TSIP_CRYPT
229-
#define WOLFSSL_RENESAS_TSIP_TLS
230-
#define WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT
236+
#define WOLFSSL_RENESAS_TSIP_CRYPTONLY
231237
#define HAVE_PK_CALLBACKS
232238
#define WOLF_CRYPTO_CB
233-
#define WOLF_PRIVATE_KEY_ID
239+
#if defined(WOLFSSL_RENESAS_TSIP_TLS)
240+
#define WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT
241+
#define WOLF_PRIVATE_KEY_ID
242+
#endif
243+
#endif
244+
245+
#if !defined(WOLFSSL_RENESAS_TSIP_TLS) && \
246+
defined(WOLFSSL_RENESAS_TSIP_CRYPTONLY)
247+
# undef WOLFSSL_RENESAS_TSIP_TLS
248+
# undef WOLFSSL_RENESAS_TSIP_CRYPT
234249
#endif
235250

236251
#else

IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/wolfssl_demo.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,22 +294,22 @@ static void Tls_client()
294294

295295
/* TSIP specific ECC private key */
296296
if (ret == 0){
297-
ret = tsip_use_PrivateKey_buffer(ssl,
297+
ret = tsip_use_PrivateKey_buffer_TLS(ssl,
298298
(const char*)g_key_block_data.encrypted_user_ecc256_private_key,
299299
sizeof(g_key_block_data.encrypted_user_ecc256_private_key),
300300
TSIP_ECCP256);
301301
if (ret != 0) {
302-
printf("ERROR tsip_use_PrivateKey_buffer\n");
302+
printf("ERROR tsip_use_PrivateKey_buffer_TLS\n");
303303
}
304304
}
305305
# if defined(WOLFSSL_CHECK_SIG_FAULTS)
306306
if (ret == 0){
307-
ret = tsip_use_PublicKey_buffer(ssl,
307+
ret = tsip_use_PublicKey_buffer_TLS(ssl,
308308
(const char*)g_key_block_data.encrypted_user_ecc256_public_key,
309309
sizeof(g_key_block_data.encrypted_user_ecc256_public_key),
310310
TSIP_ECCP256);
311311
if (ret != 0) {
312-
printf("ERROR tsip_use_PublicKey_buffer\n");
312+
printf("ERROR tsip_use_PublicKey_buffer_TLS\n");
313313
}
314314
}
315315
#endif /* WOLFSSL_CHECK_SIG_FAULTS */
@@ -339,21 +339,21 @@ static void Tls_client()
339339

340340
/* TSIP specific RSA private key */
341341
if (ret == 0) {
342-
ret = tsip_use_PrivateKey_buffer(ssl,
342+
ret = tsip_use_PrivateKey_buffer_TLS(ssl,
343343
(const char*)g_key_block_data.encrypted_user_rsa2048_private_key,
344344
sizeof(g_key_block_data.encrypted_user_rsa2048_private_key),
345345
TSIP_RSA2048);
346346
if (ret != 0) {
347-
printf("ERROR tsip_use_PrivateKey_buffer :%d\n", ret);
347+
printf("ERROR tsip_use_PrivateKey_buffer_TLS :%d\n", ret);
348348
}
349349
}
350350
if (ret == 0) {
351-
ret = tsip_use_PublicKey_buffer(ssl,
351+
ret = tsip_use_PublicKey_buffer_TLS(ssl,
352352
(const char*)g_key_block_data.encrypted_user_rsa2048_public_key,
353353
sizeof(g_key_block_data.encrypted_user_rsa2048_public_key),
354354
TSIP_RSA2048);
355355
if (ret != 0) {
356-
printf("ERROR tsip_use_PublicKey_buffer: %d\n", ret);
356+
printf("ERROR tsip_use_PublicKey_buffer_TLS: %d\n", ret);
357357
}
358358
}
359359

0 commit comments

Comments
 (0)