diff --git a/IDE/Renesas/e2studio/RA6M4/common/user_settings.h b/IDE/Renesas/e2studio/RA6M4/common/user_settings.h
index 23822c2ec..e471a7aad 100644
--- a/IDE/Renesas/e2studio/RA6M4/common/user_settings.h
+++ b/IDE/Renesas/e2studio/RA6M4/common/user_settings.h
@@ -33,7 +33,7 @@
/* XXX_CRYPTONLY definition enables FSP SM module for Crypto only use.
* Therefore, it disables TLS related API use
*/
-/* # define WOLFSSL_RENESAS_SCEPROTECT_CRYPTONLY */
+/* #define WOLFSSL_RENESAS_SCEPROTECT_CRYPTONLY */
#if defined(WOLFSSL_RENESAS_SCEPROTECT_CRYPTONLY)
#undef WOLFSSL_RENESAS_FSPSM_TLS
@@ -51,6 +51,7 @@
#define NO_MAIN_DRIVER
#define BENCH_EMBEDDED
#define NO_WRITEV
+#define WOLFSSL_NO_FLOAT_FMT
#define NO_DEV_RANDOM
#define SIZEOF_LONG_LONG 8
@@ -102,10 +103,11 @@
#endif
#define WOLF_CRYPTO_CB
-/* Enable SCEKEY_INSTALLED if keys are installed */
-#define SCEKEY_INSTALLED
-#if defined(WOLFSSL_RENESAS_SCEPROTECT) && defined(SCEKEY_INSTALLED)
+#if defined(WOLFSSL_RENESAS_SCEPROTECT_CRYPTONLY)
#define HAVE_RENESAS_SYNC
+ #define WC_USE_DEVID 7890
+ #define NO_AES_192
+ #define NO_SW_BENCH
#endif
#if defined(WOLFSSL_RENESAS_SCEPROTECT_CRYPTONLY)
diff --git a/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h b/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h
index 18be598ea..dd56fc1e7 100644
--- a/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h
+++ b/IDE/Renesas/e2studio/RA6M4/common/wolfssl_demo.h
@@ -36,7 +36,7 @@
#define DIRECT_KEY_ADDRESS_128 FLASH_HP_DF_BLOCK_2
/* Client connects to the server with these details. */
-#define SERVER_IP "192.168.11.49"
+#define SERVER_IP "192.168.11.4"
#define DEFAULT_PORT 11111
/* Enable wolfcrypt test */
@@ -45,7 +45,7 @@
/* Enable benchmark */
/* can be enabled with cyrpt test */
-/*#define BENCHMARK*/
+/* #define BENCHMARK */
/* Enable TLS client */
/* cannot enable with CRYPT_TEST or BENCHMARK */
diff --git a/IDE/Renesas/e2studio/RA6M4/test/.cproject b/IDE/Renesas/e2studio/RA6M4/test/.cproject
index 7d3b1437b..61375953a 100644
--- a/IDE/Renesas/e2studio/RA6M4/test/.cproject
+++ b/IDE/Renesas/e2studio/RA6M4/test/.cproject
@@ -40,7 +40,7 @@
-
+
@@ -54,7 +54,7 @@
-
+
-
+
@@ -217,7 +217,7 @@
-
+
+
@@ -150,6 +156,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -203,7 +321,7 @@
-
+
@@ -221,7 +339,7 @@
-
+
@@ -241,9 +359,12 @@
+
+
+
@@ -266,9 +387,12 @@
+
+
+
@@ -307,6 +431,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c b/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c
index 520c56800..14152aa82 100644
--- a/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c
+++ b/IDE/Renesas/e2studio/RZN2L/test/src/rzn2l_tst_thread_entry.c
@@ -267,15 +267,15 @@ void rzn2l_tst_thread_entry(void *pvParameters)
#if defined(WOLFSSL_AES_128)
uint8_t wrapped_key1[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128];
- FSPSM_AES_WKEY user_aes128_key_index =
- (FSPSM_AES_WKEY)wrapped_key1;
+ FSPSM_AES_PWKEY user_aes128_key_index =
+ (FSPSM_AES_PWKEY)wrapped_key1;
guser_PKCbInfo.wrapped_key_aes128 = user_aes128_key_index;
#endif
#if defined(WOLFSSL_AES_256)
uint8_t wrapped_key2[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256];
- FSPSM_AES_WKEY user_aes256_key_index =
- (FSPSM_AES_WKEY)wrapped_key2;
+ FSPSM_AES_PWKEY user_aes256_key_index =
+ (FSPSM_AES_PWKEY)wrapped_key2;
guser_PKCbInfo.wrapped_key_aes256 = user_aes256_key_index;
#endif
/* Generate Wrapped aes key */
@@ -311,15 +311,15 @@ void rzn2l_tst_thread_entry(void *pvParameters)
#if defined(WOLFSSL_AES_128)
uint8_t wrapped_key1[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128];
- FSPSM_AES_WKEY user_aes128_key_index =
- (FSPSM_AES_WKEY)wrapped_key1;
+ FSPSM_AES_PWKEY user_aes128_key_index =
+ (FSPSM_AES_PWKEY)wrapped_key1;
guser_PKCbInfo.wrapped_key_aes128 = user_aes128_key_index;
#endif
#if defined(WOLFSSL_AES_256)
uint8_t wrapped_key2[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256];
- FSPSM_AES_WKEY user_aes256_key_index =
- (FSPSM_AES_WKEY)wrapped_key2;
+ FSPSM_AES_PWKEY user_aes256_key_index =
+ (FSPSM_AES_PWKEY)wrapped_key2;
guser_PKCbInfo.wrapped_key_aes256 = user_aes256_key_index;
#endif
/* Generate Wrapped aes key */
diff --git a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c
index e22c95cb4..9e943259c 100644
--- a/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c
+++ b/IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c
@@ -90,19 +90,19 @@ FSPSM_ST gCbInfo_a; /* for multi testing */
#if defined(WOLFSSL_AES_128)
uint8_t wrapped_key1[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128];
uint8_t wrapped_key2[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_128];
- FSPSM_AES_WKEY g_user_aes128_key_index1 =
- (FSPSM_AES_WKEY)wrapped_key1;
- FSPSM_AES_WKEY g_user_aes128_key_index2 =
- (FSPSM_AES_WKEY)wrapped_key2;
+ FSPSM_AES_PWKEY g_user_aes128_key_index1 =
+ (FSPSM_AES_PWKEY)wrapped_key1;
+ FSPSM_AES_PWKEY g_user_aes128_key_index2 =
+ (FSPSM_AES_PWKEY)wrapped_key2;
#endif
#if defined(WOLFSSL_AES_256)
uint8_t wrapped_key3[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256];
uint8_t wrapped_key4[RSIP_BYTE_SIZE_WRAPPED_KEY_AES_256];
- FSPSM_AES_WKEY g_user_aes256_key_index1 =
- (FSPSM_AES_WKEY)wrapped_key3;
- FSPSM_AES_WKEY g_user_aes256_key_index2 =
- (FSPSM_AES_WKEY)wrapped_key4;
+ FSPSM_AES_PWKEY g_user_aes256_key_index1 =
+ (FSPSM_AES_PWKEY)wrapped_key3;
+ FSPSM_AES_PWKEY g_user_aes256_key_index2 =
+ (FSPSM_AES_PWKEY)wrapped_key4;
#endif
#endif
@@ -124,12 +124,12 @@ FSPSM_ST gCbInfo_a; /* for multi testing */
#endif
typedef struct tagInfo
{
- FSPSM_AES_WKEY aes_key;
+ FSPSM_AES_PWKEY aes_key;
} Info;
#if defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128)
-static int rsip_aes128_cbc_test(int prnt, FSPSM_AES_WKEY aes_key)
+static int rsip_aes128_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
{
Aes aes[1];
@@ -214,7 +214,7 @@ static void tskAes128_Cbc_Test(void *pvParam)
#endif
#ifdef WOLFSSL_AES_256
-static int rsip_aes256_cbc_test(int prnt, FSPSM_AES_WKEY aes_key)
+static int rsip_aes256_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
{
Aes enc[1];
byte cipher[AES_BLOCK_SIZE];
@@ -313,7 +313,7 @@ static void tskAes256_Cbc_Test(void *pvParam)
#endif /* WOLFSSL_AES_256 */
#if defined(WOLFSSL_AES_256)
-static int rsip_aesgcm256_test(int prnt, FSPSM_AES_WKEY aes256_key)
+static int rsip_aesgcm256_test(int prnt, FSPSM_AES_PWKEY aes256_key)
{
Aes enc[1];
Aes dec[1];
@@ -493,7 +493,7 @@ static void tskAes256_Gcm_Test(void *pvParam)
#if defined(WOLFSSL_AES_128)
-static int rsip_aesgcm128_test(int prnt, FSPSM_AES_WKEY aes128_key)
+static int rsip_aesgcm128_test(int prnt, FSPSM_AES_PWKEY aes128_key)
{
Aes enc[1];
Aes dec[1];
@@ -942,13 +942,13 @@ int rsip_crypt_AesCbc_multitest()
#if defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128)
XMEMCPY(&info_aes1.aes_key, &g_user_aes128_key_index1,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
xRet = xTaskCreate(tskAes128_Cbc_Test, "aes_cbc_tes1t",
STACK_SIZE, &info_aes1, 3, NULL);
#endif
#if defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_128)
XMEMCPY(&info_aes2.aes_key, &g_user_aes128_key_index2,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes128_Cbc_Test, "aes_cbc_test2",
STACK_SIZE, &info_aes2, 3, NULL);
@@ -956,14 +956,14 @@ int rsip_crypt_AesCbc_multitest()
#if defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_256)
XMEMCPY(&info_aes256_1.aes_key, &g_user_aes256_key_index1,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes256_Cbc_Test, "aes256_cbc_test1",
STACK_SIZE, &info_aes256_1, 3, NULL);
#endif
#if defined(HAVE_AES_CBC) && defined(WOLFSSL_AES_256)
XMEMCPY(&info_aes256_2.aes_key, &g_user_aes256_key_index2,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes256_Cbc_Test, "aes256_cbc_test2",
STACK_SIZE, &info_aes256_2, 3, NULL);
@@ -1024,14 +1024,14 @@ int rsip_crypt_AesGcm_multitest()
#if defined(WOLFSSL_AES_128)
XMEMCPY(&info_aes1.aes_key, &g_user_aes128_key_index1,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
xTaskCreate(tskAes128_Gcm_Test, "aes128_gcm_test1",
STACK_SIZE, &info_aes1, 3, NULL);
#endif
#if defined(WOLFSSL_AES_128)
XMEMCPY(&info_aes2.aes_key, &g_user_aes128_key_index2,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes128_Gcm_Test, "aes128_gcm_test2",
STACK_SIZE, &info_aes2, 3, NULL);
@@ -1039,7 +1039,7 @@ int rsip_crypt_AesGcm_multitest()
#if defined(WOLFSSL_AES_256)
XMEMCPY(&info_aes256_1.aes_key, &g_user_aes256_key_index1,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes256_Gcm_Test, "aes256_gcm_test1",
STACK_SIZE, &info_aes256_1, 3, NULL);
@@ -1047,7 +1047,7 @@ int rsip_crypt_AesGcm_multitest()
#if defined(WOLFSSL_AES_256)
XMEMCPY(&info_aes256_2.aes_key, &g_user_aes256_key_index2,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes256_Gcm_Test, "aes256_gcm_test2",
STACK_SIZE, &info_aes256_2, 3, NULL);
@@ -1124,7 +1124,7 @@ int rsip_crypt_Sha_AesCbcGcm_multitest()
#if defined(WOLFSSL_AES_128)
XMEMCPY(&info_aes128cbc.aes_key, &g_user_aes128_key_index1,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes128_Cbc_Test, "aes128_cbc_test1",
STACK_SIZE, &info_aes128cbc, 3, NULL);
@@ -1132,7 +1132,7 @@ int rsip_crypt_Sha_AesCbcGcm_multitest()
#if defined(WOLFSSL_AES_128)
XMEMCPY(&info_aes128gcm.aes_key, &g_user_aes128_key_index2,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes128_Gcm_Test, "aes128_gcm_test2",
STACK_SIZE, &info_aes128gcm, 3, NULL);
@@ -1140,7 +1140,7 @@ int rsip_crypt_Sha_AesCbcGcm_multitest()
#if defined(WOLFSSL_AES_256)
XMEMCPY(&info_aes256cbc.aes_key, &g_user_aes256_key_index1,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes256_Cbc_Test, "aes256_cbc_test1",
STACK_SIZE, &info_aes256cbc, 3, NULL);
@@ -1148,7 +1148,7 @@ int rsip_crypt_Sha_AesCbcGcm_multitest()
#if defined(WOLFSSL_AES_256)
XMEMCPY(&info_aes256gcm.aes_key, &g_user_aes256_key_index2,
- sizeof(FSPSM_AES_WKEY));
+ sizeof(FSPSM_AES_PWKEY));
if (xRet == pdPASS)
xRet = xTaskCreate(tskAes256_Gcm_Test, "aes256_gcm_test2",
STACK_SIZE, &info_aes256gcm, 3, NULL);
diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c
index d06c15844..8762eb66d 100644
--- a/wolfcrypt/src/aes.c
+++ b/wolfcrypt/src/aes.c
@@ -2871,9 +2871,8 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt(
#elif defined(WOLFSSL_SILABS_SE_ACCEL)
/* implemented in wolfcrypt/src/port/silabs/silabs_aes.c */
-#elif ((defined(WOLFSSL_RENESAS_FSPSM_TLS) || \
- defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)) && \
- !defined(NO_WOLFSSL_RENESAS_FSPSM_AES))
+#elif defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) && \
+ !defined(NO_WOLFSSL_RENESAS_FSPSM_AES)
/* implemented in wolfcrypt/src/port/renesas/renesas_fspsm_aes.c */
#else
@@ -4993,9 +4992,8 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
}
#endif /* WOLFSSL_SECO_CAAM */
- #if ((defined(WOLFSSL_RENESAS_FSPSM_TLS) || \
- defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)) && \
- !defined(NO_WOLFSSL_RENESAS_FSPSM_AES))
+ #if defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) && \
+ !defined(NO_WOLFSSL_RENESAS_FSPSM_AES)
return ret;
#endif /* WOLFSSL_RENESAS_RSIP && WOLFSSL_RENESAS_FSPSM_CRYPTONLY*/
diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c
index 4a7bf34a0..2017a4832 100644
--- a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c
+++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c
@@ -57,14 +57,14 @@ extern FSPSM_INSTANCE gFSPSM_ctrl;
#endif
typedef fsp_err_t (*aesGcmEncInitFn)
- (FSPSM_AESGCM_HANDLE*, FSPSM_AES_WKEY*, uint8_t*, uint32_t);
+ (FSPSM_AESGCM_HANDLE*, FSPSM_AES_PWKEY, uint8_t*, uint32_t);
typedef fsp_err_t (*aesGcmEncUpdateFn)
(FSPSM_AESGCM_HANDLE*,uint8_t*, uint8_t*, uint32_t, uint8_t*, uint32_t);
typedef fsp_err_t (*aesGcmEncFinalFn)
(FSPSM_AESGCM_HANDLE*, uint8_t*, uint32_t*, uint8_t*);
typedef fsp_err_t (*aesGcmDecInitFn)
- (FSPSM_AESGCM_HANDLE*, FSPSM_AES_WKEY*, uint8_t*, uint32_t);
+ (FSPSM_AESGCM_HANDLE*, FSPSM_AES_PWKEY, uint8_t*, uint32_t);
typedef fsp_err_t (*aesGcmDecUpdateFn)
(FSPSM_AESGCM_HANDLE*,uint8_t*, uint8_t*, uint32_t, uint8_t*, uint32_t);
typedef fsp_err_t (*aesGcmDecFinalFn)
@@ -73,11 +73,11 @@ typedef fsp_err_t (*aesGcmDecFinalFn)
#if defined(WOLFSSL_RENESAS_RSIP)
/* wrapper for Gcm enrypt init */
static fsp_err_t _R_RSIP_AES_GCM_EncryptInit(FSPSM_AESGCM_HANDLE* h,
- FSPSM_AES_WKEY* k, uint8_t* iv,
+ FSPSM_AES_PWKEY k, uint8_t* iv,
uint32_t iv_l)
{
(void) h;
- return R_RSIP_AES_GCM_EncryptInit(&gFSPSM_ctrl, (FSPSM_AES_WKEY const)*k,
+ return R_RSIP_AES_GCM_EncryptInit(&gFSPSM_ctrl, (FSPSM_AES_PWKEY const)k,
(uint8_t* const)iv, iv_l);
}
/* wrapper for Gcm enrypt update */
@@ -104,10 +104,10 @@ static fsp_err_t _R_RSIP_AES_GCM_EncryptFinal(FSPSM_AESGCM_HANDLE* h,
}
/* wrapper for Gcm decrypt init */
static fsp_err_t _R_RSIP_AES_GCM_DecryptInit(FSPSM_AESGCM_HANDLE* h,
- FSPSM_AES_WKEY* k, uint8_t* iv, uint32_t iv_l)
+ FSPSM_AES_PWKEY k, uint8_t* iv, uint32_t iv_l)
{
(void) h;
- return R_RSIP_AES_GCM_DecryptInit(&gFSPSM_ctrl, (FSPSM_AES_WKEY const)*k,
+ return R_RSIP_AES_GCM_DecryptInit(&gFSPSM_ctrl, (FSPSM_AES_PWKEY const)k,
(uint8_t* const)iv, iv_l);
}
/* wrapper for Gcm decrypt update */
@@ -135,7 +135,7 @@ static fsp_err_t _R_RSIP_AES_GCM_DecryptFinal(FSPSM_AESGCM_HANDLE* h,
}
/* wrapper for aes cbc encrypt init */
static fsp_err_t _R_RSIP_AESCBC_Cipher_EncryptInit(FSPSM_AES_HANDLE* h,
- FSPSM_AES_WKEY k,
+ FSPSM_AES_PWKEY k,
uint8_t* iv)
{
(void) h;
@@ -167,7 +167,7 @@ static fsp_err_t _R_RSIP_AESCBC_Cipher_EncryptFinal(FSPSM_AES_HANDLE* h,
}
/* wrapper for aes cbc decrypt init */
static fsp_err_t _R_RSIP_AESCBC_Cipher_DecryptInit(FSPSM_AES_HANDLE* h,
- FSPSM_AES_WKEY k,
+ FSPSM_AES_PWKEY k,
uint8_t* iv)
{
(void) h;
@@ -238,8 +238,8 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out,
FSPSM_HMAC_WKEY key_client_mac;
FSPSM_HMAC_WKEY key_server_mac;
#endif
- FSPSM_AES_WKEY key_client_aes;
- FSPSM_AES_WKEY key_server_aes;
+ FSPSM_AES_PWKEY key_client_aes = NULL;
+ FSPSM_AES_PWKEY key_server_aes = NULL;
(void) key_server_aes;
/* sanity check */
@@ -272,7 +272,7 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out,
/* check if AES GCM can be used by FSP SM */
if ((ret = wc_fspsm_hw_lock()) == 0) {
- /* allocate buffers for plaintext, ciphertext and authTag to make sure
+ /* allocate buffers for plain text, cipher text and authTag to make sure
* those buffers 32bit aligned as SCE requests.
*/
delta = ((sz % AES_BLOCK_SIZE) == 0) ? 0 :
@@ -300,6 +300,17 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out,
/* generate AES-GCM session key. The key stored in
* Aes.ctx.tsip_keyIdx is not used here.
*/
+ key_client_aes = (FSPSM_AES_PWKEY)XMALLOC(sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ key_server_aes = (FSPSM_AES_PWKEY)XMALLOC(sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ if (key_client_aes == NULL || key_server_aes == NULL) {
+ XFREE(plainBuf, aes->heap, DYNAMIC_TYPE_AES);
+ XFREE(cipherBuf, aes->heap, DYNAMIC_TYPE_AES);
+ XFREE(aTagBuf, aes->heap, DYNAMIC_TYPE_AES);
+ return MEMORY_E;
+ }
+
ret = FSPSM_SESSIONKEY_GEN_FUNC(
info->cipher,
(uint32_t*)info->masterSecret,
@@ -308,8 +319,8 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out,
&iv[AESGCM_IMP_IV_SZ], /* use exp_IV */
&key_client_mac,
&key_server_mac,
- &key_client_aes,
- &key_server_aes,
+ key_client_aes,
+ key_server_aes,
NULL, NULL);
if (ret != FSP_SUCCESS) {
WOLFSSL_MSG("R_XXX_TLS_SessionKeyGenerate failed");
@@ -323,24 +334,7 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out,
#endif
if (info->keyflgs_crypt.bits.aes256_installedkey_set == 1 ||
info->keyflgs_crypt.bits.aes128_installedkey_set == 1) {
- if (aes->ctx.keySize == 32) {
- #if defined(WOLFSSL_RENESAS_RSIP)
- key_client_aes = aes->ctx.wrapped_key;
- #else
- XMEMCPY(&key_client_aes,
- (FSPSM_AES_WKEY*)info->wrapped_key_aes256,
- sizeof(FSPSM_AES_WKEY));
- #endif
- }
- else {
- #if defined(WOLFSSL_RENESAS_RSIP)
- key_client_aes = aes->ctx.wrapped_key;
- #else
- XMEMCPY(&key_client_aes,
- (FSPSM_AES_WKEY*)info->wrapped_key_aes128,
- sizeof(FSPSM_AES_WKEY));
- #endif
- }
+ key_client_aes = aes->ctx.wrapped_key;
iv_l = iv;
ivSz_l = ivSz;
}
@@ -355,7 +349,7 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out,
/* since generated session key is coupled to iv, no need to pass
* them init func.
*/
- ret = initFn(&_handle, &key_client_aes, (uint8_t*)iv_l, ivSz_l);
+ ret = initFn(&_handle, key_client_aes, (uint8_t*)iv_l, ivSz_l);
if (ret == FSP_SUCCESS) {
ret = updateFn(&_handle, NULL, NULL, 0UL, (uint8_t*)authIn,
@@ -403,9 +397,13 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out,
XFREE(plainBuf, aes->heap, DYNAMIC_TYPE_AES);
XFREE(cipherBuf, aes->heap, DYNAMIC_TYPE_AES);
XFREE(aTagBuf, aes->heap, DYNAMIC_TYPE_AES);
-
+ if (info->keyflgs_tls.bits.session_key_set == 1 &&
+ key_client_aes != NULL)
+ XFREE(key_client_aes, aes->heap, DYNAMIC_TYPE_AES);
+ if (info->keyflgs_tls.bits.session_key_set == 1 &&
+ key_server_aes != NULL)
+ XFREE(key_server_aes, aes->heap, DYNAMIC_TYPE_AES);
wc_fspsm_hw_unlock();
-
}
return ret;
@@ -446,12 +444,12 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out,
const uint8_t* iv_l = NULL;
uint32_t ivSz_l = 0;
-#ifdef WOLFSSL_RENESAS_TLS
+#ifdef WOLFSSL_RENESAS_FSPSM_TLS
FSPSM_HMAC_WKEY key_client_mac;
FSPSM_HMAC_WKEY key_server_mac;
#endif
- FSPSM_AES_WKEY key_client_aes;
- FSPSM_AES_WKEY key_server_aes;
+ FSPSM_AES_PWKEY key_client_aes = NULL;
+ FSPSM_AES_PWKEY key_server_aes = NULL;
(void) key_client_aes;
/* sanity check */
if (aes == NULL || authTagSz > AES_BLOCK_SIZE || ivSz == 0 || ctx == NULL) {
@@ -506,6 +504,17 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out,
/* generate AES-GCM session key. The key stored in
* Aes.ctx.tsip_keyIdx is not used here.
*/
+ key_client_aes = (FSPSM_AES_PWKEY)XMALLOC(sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ key_server_aes = (FSPSM_AES_PWKEY)XMALLOC(sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ if (key_client_aes == NULL || key_server_aes == NULL) {
+ XFREE(plainBuf, aes->heap, DYNAMIC_TYPE_AES);
+ XFREE(cipherBuf, aes->heap, DYNAMIC_TYPE_AES);
+ XFREE(aTagBuf, aes->heap, DYNAMIC_TYPE_AES);
+ return MEMORY_E;
+ }
+
ret = FSPSM_SESSIONKEY_GEN_FUNC(
info->cipher,
(uint32_t*)info->masterSecret,
@@ -514,8 +523,8 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out,
(uint8_t*)&iv[AESGCM_IMP_IV_SZ], /* use exp_IV */
&key_client_mac,
&key_server_mac,
- &key_client_aes,
- &key_server_aes,
+ key_client_aes,
+ key_server_aes,
NULL, NULL);
if (ret != FSP_SUCCESS) {
WOLFSSL_MSG("R_XXXX_TLS_SessionKeyGenerate failed");
@@ -528,24 +537,8 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out,
#endif
if (info->keyflgs_crypt.bits.aes256_installedkey_set == 1 ||
info->keyflgs_crypt.bits.aes128_installedkey_set == 1) {
- if (aes->ctx.keySize == 32) {
- #if defined(WOLFSSL_RENESAS_RSIP)
- key_server_aes = aes->ctx.wrapped_key;
- #else
- XMEMCPY(&key_server_aes,
- (FSPSM_AES_WKEY*)info->wrapped_key_aes256,
- sizeof(FSPSM_AES_WKEY));
- #endif
- }
- else {
- #if defined(WOLFSSL_RENESAS_RSIP)
- key_server_aes = aes->ctx.wrapped_key;
- #else
- XMEMCPY(&key_server_aes,
- (FSPSM_AES_WKEY*)info->wrapped_key_aes128,
- sizeof(FSPSM_AES_WKEY));
- #endif
- }
+
+ key_server_aes = aes->ctx.wrapped_key;
iv_l = iv;
ivSz_l = ivSz;
}
@@ -559,7 +552,7 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out,
/* since key_index has iv and ivSz in it, no need to pass them init
* func. Pass NULL and 0 as 3rd and 4th parameter respectively.
*/
- ret = initFn(&_handle, &key_server_aes, (uint8_t*)iv_l, ivSz_l);
+ ret = initFn(&_handle, key_server_aes, (uint8_t*)iv_l, ivSz_l);
if (ret == FSP_SUCCESS) {
@@ -603,7 +596,12 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out,
XFREE(aTagBuf, aes->heap, DYNAMIC_TYPE_AES);
XFREE(plainBuf, aes->heap, DYNAMIC_TYPE_AES);
XFREE(cipherBuf, aes->heap, DYNAMIC_TYPE_AES);
-
+ if (info->keyflgs_tls.bits.session_key_set == 1 &&
+ key_client_aes != NULL)
+ XFREE(key_client_aes, aes->heap, DYNAMIC_TYPE_AES);
+ if (info->keyflgs_tls.bits.session_key_set == 1 &&
+ key_server_aes != NULL)
+ XFREE(key_server_aes, aes->heap, DYNAMIC_TYPE_AES);
wc_fspsm_hw_unlock();
}
@@ -640,20 +638,12 @@ WOLFSSL_LOCAL int wc_fspsm_AesCbcEncrypt(struct Aes* aes, byte* out,
if (aes->ctx.keySize == 16) {
ret = FSPSM_AES128CBCEnc_Init(&_handle,
- #ifdef WOLFSSL_RENESAS_RSIP
aes->ctx.wrapped_key,
- #else
- &aes->ctx.wrapped_key,
- #endif
iv);
}
else if (aes->ctx.keySize == 32) {
ret = FSPSM_AES256CBCEnc_Init(&_handle,
- #ifdef WOLFSSL_RENESAS_RSIP
aes->ctx.wrapped_key,
- #else
- &aes->ctx.wrapped_key,
- #endif
iv);
}
else {
@@ -720,20 +710,12 @@ WOLFSSL_LOCAL int wc_fspsm_AesCbcDecrypt(struct Aes* aes, byte* out,
if (aes->ctx.keySize == 16) {
ret = FSPSM_AES128CBCDec_Init(&_handle,
- #ifdef WOLFSSL_RENESAS_RSIP
aes->ctx.wrapped_key,
- #else
- &aes->ctx.wrapped_key,
- #endif
iv);
}
else if (aes->ctx.keySize == 32) {
ret = FSPSM_AES256CBCDec_Init(&_handle,
- #ifdef WOLFSSL_RENESAS_RSIP
aes->ctx.wrapped_key,
- #else
- &aes->ctx.wrapped_key,
- #endif
iv);
}
else {
@@ -777,17 +759,27 @@ WOLFSSL_LOCAL int wc_fspsm_AesCbcDecrypt(struct Aes* aes, byte* out,
*/
WOLFSSL_LOCAL void wc_fspsm_Aesfree(Aes* aes)
{
-#if defined(WOLFSSL_RENESAS_RSIP)
+#if defined(WOLFSSL_RENESAS_FSPSM_TLS)
+ /* In the case of session key, memory is allocated
+ * therefore, it should be freed here
+ */
+ if (aes->ctx.setup == 1 && aes->ctx.wrapped_key) {
+ XFREE(aes->ctx.wrapped_key, aes->heap, DYNAMIC_TYPE_AES);
+ aes->ctx.setup = 0;
+ }
+#else
if (aes->ctx.wrapped_key) {
- /* aes ctx just points user created wrapped key.
+ /* aes ctx just points user created wrapped key
+ * in the case of CryptOnly Mode
* therefore, it just sets pointing to NULL.
- * user key should be freed by owenr(user)
+ * user key should be freed by owner(user)
*/
aes->ctx.wrapped_key = NULL;
}
#endif
}
+#if defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
const byte* iv, int dir)
{
@@ -810,14 +802,14 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
/* if there is previous key, free */
if(aes->ctx.wrapped_key)
wc_fspsm_Aesfree(aes);
-
- /* generate aes key beased on length */
- aes->ctx.wrapped_key = (FSPSM_AES_WKEY)userKey;
+ /* Generate aes key based on length */
+ aes->ctx.wrapped_key = (FSPSM_AES_PWKEY)userKey;
aes->keylen = (int)keylen;
aes->ctx.keySize = keylen;
return wc_AesSetIV(aes, iv);
}
+#endif
#endif /* WOLFSSL_RENESAS_FSPSM_TLS
WOLFSSL_RENESAS_FSPSM_CRYPTONLY
NO_WOLFSSL_RENESAS_FSPSM_AES */
diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c
index 530839938..5cc02a121 100644
--- a/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c
+++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_sha.c
@@ -30,9 +30,9 @@
#include
-#if defined(WOLFSSL_RENESAS_RSIP) || \
- defined(WOLFSSL_RENESAS_FSPSM_TLS) || \
- defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
+#if (defined(WOLFSSL_RENESAS_SCEPROTECT) || \
+ defined(WOLFSSL_RENESAS_RSIP)) && \
+ !defined(NO_WOLFSSL_RENESAS_TSIP_CRYPT_HASH)
#include
#include
diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c
index 4491113a7..1de283d3a 100644
--- a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c
+++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c
@@ -697,8 +697,9 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl,
FSPSM_HMAC_WKEY key_client_mac;
FSPSM_HMAC_WKEY key_server_mac;
- FSPSM_AES_WKEY key_client_aes;
- FSPSM_AES_WKEY key_server_aes;
+ FSPSM_AES_PWKEY key_client_aes = NULL;
+ FSPSM_AES_PWKEY key_server_aes = NULL;
+
uint32_t sceCS = GetSceCipherSuite(ssl->options.cipherSuite0,
ssl->options.cipherSuite);
@@ -717,6 +718,14 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl,
}
else {
+ key_client_aes = (FSPSM_AES_PWKEY)XMALLOC(sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ key_server_aes = (FSPSM_AES_PWKEY)XMALLOC(sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ if (key_client_aes == NULL || key_server_aes == NULL) {
+ return MEMORY_E;
+ }
+
ret = FSPSM_SESSIONKEY_GEN_FUNC(
GetSceCipherSuite(
ssl->options.cipherSuite0,
@@ -727,8 +736,8 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl,
NULL,
&key_client_mac,
&key_server_mac,
- &key_client_aes,
- &key_server_aes,
+ key_client_aes,
+ key_server_aes,
NULL, NULL);
}
@@ -748,8 +757,12 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl,
if (enc->aes == NULL)
return MEMORY_E;
}
-
XMEMSET(enc->aes, 0, sizeof(Aes));
+ enc->aes->ctx.wrapped_key = (FSPSM_AES_PWKEY)XMALLOC
+ (sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ if (enc->aes->ctx.wrapped_key == NULL)
+ return MEMORY_E;
}
if (dec) {
if (dec->aes == NULL) {
@@ -761,22 +774,27 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl,
}
return MEMORY_E;
}
- }
-
- XMEMSET(dec->aes, 0, sizeof(Aes));
+ XMEMSET(dec->aes, 0, sizeof(Aes));
+
+ dec->aes->ctx.wrapped_key = (FSPSM_AES_PWKEY)XMALLOC
+ (sizeof(FSPSM_AES_WKEY),
+ aes->heap, DYNAMIC_TYPE_AE);
+ if (dec->aes->ctx.wrapped_key == NULL)
+ return MEMORY_E;
+ }
}
/* copy key index into aes */
if (ssl->options.side == PROVISION_CLIENT) {
- XMEMCPY(&enc->aes->ctx.wrapped_key, &key_client_aes,
- sizeof(key_client_aes));
- XMEMCPY(&dec->aes->ctx.wrapped_key, &key_server_aes,
- sizeof(key_server_aes));
+ XMEMCPY(enc->aes->ctx.wrapped_key, key_client_aes,
+ sizeof(FSPSM_AES_WKEY));
+ XMEMCPY(dec->aes->ctx.wrapped_key, key_server_aes,
+ sizeof(FSPSM_AES_WKEY));
}
else {
- XMEMCPY(&enc->aes->ctx.wrapped_key, &key_server_aes,
- sizeof(key_server_aes));
- XMEMCPY(&dec->aes->ctx.wrapped_key, &key_client_aes,
- sizeof(key_client_aes));
+ XMEMCPY(enc->aes->ctx.wrapped_key, key_server_aes,
+ sizeof(FSPSM_AES_WKEY));
+ XMEMCPY(dec->aes->ctx.wrapped_key, key_client_aes,
+ sizeof(FSPSM_AES_WKEY));
}
/* copy mac key index into keys */
ssl->keys.fspsm_client_write_MAC_secret = key_client_mac;
@@ -808,8 +826,15 @@ WOLFSSL_LOCAL int wc_fspsm_generateSessionKey(WOLFSSL *ssl,
/* marked as session key is set */
cbInfo->keyflgs_tls.bits.session_key_set = 1;
}
+
+ if (key_client_aes)
+ XFREE(key_client_aes, aes->heap, DYNAMIC_TYPE_AES);
+ if (key_server_aes)
+ XFREE(key_server_aes, aes->heap, DYNAMIC_TYPE_AES);
+
/* unlock hw */
wc_fspsm_hw_unlock();
+
}
else {
WOLFSSL_LEAVE("hw lock failed", ret);
diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c
index b25309e3c..013dffffb 100644
--- a/wolfcrypt/src/rsa.c
+++ b/wolfcrypt/src/rsa.c
@@ -597,8 +597,7 @@ int wc_FreeRsaKey(RsaKey* key)
wc_MemZero_Check(key, sizeof(RsaKey));
#endif
-#if defined(WOLFSSL_RENESAS_FSPSM_TLS) || \
- defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
+#if defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
wc_fspsm_RsaKeyFree(key);
#endif
diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c
index 8e9a1f82c..002437f9e 100644
--- a/wolfcrypt/test/test.c
+++ b/wolfcrypt/test/test.c
@@ -1300,7 +1300,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
#if defined(HAVE_AESGCM) && defined(WOLFSSL_AES_128) && \
!defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT) && \
- !defined(WOLFSSL_RENESAS_FSPSM)
+ !defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
if ( (ret = gmac_test()) != 0)
TEST_FAIL("GMAC test failed!\n", ret);
else
@@ -1377,7 +1377,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
TEST_PASS("AES test passed!\n");
#if defined(WOLFSSL_AES_192) && \
- !defined(WOLFSSL_RENESAS_FSPSM)
+ !defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY)
if ( (ret = aes192_test()) != 0)
TEST_FAIL("AES192 test failed!\n", ret);
else
@@ -1404,7 +1404,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
TEST_FAIL("AES-GCM test failed!\n", ret);
#endif
#if !defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT) && \
- !defined(WOLFSSL_RENESAS_FSPSM) && \
+ !defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY) && \
!defined(WOLFSSL_KCAPI_AES) && !(defined(WOLF_CRYPTO_CB) && \
(defined(HAVE_INTEL_QA_SYNC) || defined(HAVE_CAVIUM_OCTEON_SYNC)))
if ((ret = aesgcm_default_test()) != 0) {
diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h
index 0e822ec1b..443540179 100644
--- a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h
+++ b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h
@@ -104,7 +104,7 @@ typedef struct tagPKCbInfo {
uint32_t num_session;
} FSPSM_ST_PKC;
-#ifdef WOLFSSL_RENSAS_FSPSM_TLS
+#ifdef WOLFSSL_RENESAS_FSPSM_TLS
typedef struct
{
uint8_t *encrypted_provisioning_key;
@@ -127,8 +127,11 @@ WOLFSSL_LOCAL int wc_fspsm_usable(const struct WOLFSSL *ssl,
uint8_t session_key_generated);
typedef struct {
- FSPSM_AES_WKEY wrapped_key;
+ FSPSM_AES_PWKEY wrapped_key;
word32 keySize;
+#ifdef WOLFSSL_RENESAS_FSPSM_TLS
+ byte setup;
+#endif
} FSPSM_AES_CTX;
struct Aes;
diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h
index 2cb451ecc..3b6ce7960 100644
--- a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h
+++ b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-types.h
@@ -79,6 +79,7 @@
/* aes */
#define FSPSM_AES_WKEY sce_aes_wrapped_key_t
+ #define FSPSM_AES_PWKEY sce_aes_wrapped_key_t*
#define FSPSM_AESGCM_HANDLE sce_gcm_handle_t
#define FSPSM_AES_HANDLE sce_aes_handle_t
/* aes 128 cbc */
@@ -217,7 +218,8 @@
#define FSPSM_SHA512_256_Up _R_RSIP_SHA_GenerateUpdate
#define FSPSM_SHA512_256_Final _R_RSIP_SHA_GenerateFinal
/* aes */
- #define FSPSM_AES_WKEY rsip_wrapped_key_t*
+ #define FSPSM_AES_WKEY rsip_wrapped_key_t
+ #define FSPSM_AES_PWKEY rsip_wrapped_key_t*
#define FSPSM_AESGCM_HANDLE rsip_instance_ctrl_t*
#define FSPSM_AES_HANDLE rsip_instance_ctrl_t*
#define FSPSM_AES_KEYGEN_FUNC _R_RSIP_KeyGenerate