3333#if defined(WOLFSSL_RENESAS_FSPSM_TLS ) || \
3434 defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY )
3535
36- #include <wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt .h>
36+ #include <wolfssl/wolfcrypt/port/Renesas/renesas_fspsm_internal .h>
3737 #define cmn_hw_lock wc_fspsm_hw_lock
3838 #define cmn_hw_unlock wc_fspsm_hw_unlock
3939
@@ -87,6 +87,8 @@ WOLFSSL_LOCAL int Renesas_cmn_Cleanup(struct WOLFSSL* ssl)
8787
8888#if defined(WOLFSSL_RENESAS_TSIP_TLS )
8989 ret = tsip_TlsCleanup (ssl );
90+ #elif defined(WOLFSSL_RENESAS_FSPSM_TLS )
91+ ret = wc_fspsm_TlsCleanup (ssl );
9092#endif
9193
9294 WOLFSSL_LEAVE ("Renesas_cmn_Cleanup" , ret );
@@ -166,6 +168,7 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
166168#elif defined(WOLFSSL_RENESAS_FSPSM_TLS ) || \
167169 defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY )
168170 FSPSM_ST * cbInfo = (FSPSM_ST * )ctx ;
171+ (void )cbInfo ;
169172#endif
170173
171174 if (info == NULL || ctx == NULL )
@@ -276,88 +279,19 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
276279
277280 if (info -> algo_type == WC_ALGO_TYPE_CIPHER ) {
278281 #if !defined(NO_AES )
279- #ifdef HAVE_AESGCM
280- if (info -> cipher .type == WC_CIPHER_AES_GCM ) {
281-
282- if (info -> cipher .enc &&
283- (cbInfo -> keyflgs_tls .bits .session_key_set == 1 ||
284- (cbInfo -> keyflgs_crypt .bits .aes256_installedkey_set == 1 &&
285- info -> cipher .aesgcm_enc .aes -> keylen == 32 ) ||
286- (cbInfo -> keyflgs_crypt .bits .aes128_installedkey_set == 1 &&
287- info -> cipher .aesgcm_enc .aes -> keylen == 16 ))) {
288-
289- ret = wc_fspsm_AesGcmEncrypt (
290- info -> cipher .aesgcm_enc .aes ,
291- (byte * )info -> cipher .aesgcm_enc .out ,
292- (byte * )info -> cipher .aesgcm_enc .in ,
293- info -> cipher .aesgcm_enc .sz ,
294- (byte * )info -> cipher .aesgcm_enc .iv ,
295- info -> cipher .aesgcm_enc .ivSz ,
296- (byte * )info -> cipher .aesgcm_enc .authTag ,
297- info -> cipher .aesgcm_enc .authTagSz ,
298- (byte * )info -> cipher .aesgcm_enc .authIn ,
299- info -> cipher .aesgcm_enc .authInSz ,
300- (void * )ctx );
301-
302- }
303- else if (cbInfo -> keyflgs_tls .bits .session_key_set == 1 ||
304- (cbInfo -> keyflgs_crypt .bits .aes256_installedkey_set == 1 &&
305- info -> cipher .aesgcm_dec .aes -> keylen == 32 ) ||
306- (cbInfo -> keyflgs_crypt .bits .aes128_installedkey_set == 1 &&
307- info -> cipher .aesgcm_dec .aes -> keylen == 16 )) {
308-
309- ret = wc_fspsm_AesGcmDecrypt (
310- info -> cipher .aesgcm_dec .aes ,
311- (byte * )info -> cipher .aesgcm_dec .out ,
312- (byte * )info -> cipher .aesgcm_dec .in ,
313- info -> cipher .aesgcm_dec .sz ,
314- (byte * )info -> cipher .aesgcm_dec .iv ,
315- info -> cipher .aesgcm_dec .ivSz ,
316- (byte * )info -> cipher .aesgcm_dec .authTag ,
317- info -> cipher .aesgcm_dec .authTagSz ,
318- (byte * )info -> cipher .aesgcm_dec .authIn ,
319- info -> cipher .aesgcm_dec .authInSz ,
320- (void * )ctx );
321- }
322- }
323- #endif /* HAVE_AESGCM */
324- #ifdef HAVE_AES_CBC
325- if ((info -> cipher .type == WC_CIPHER_AES_CBC ) &&
326- (cbInfo -> keyflgs_tls .bits .session_key_set == 1 ||
327- (cbInfo -> keyflgs_crypt .bits .aes256_installedkey_set == 1 &&
328- info -> cipher .aescbc .aes -> keylen == 32 ) ||
329- (cbInfo -> keyflgs_crypt .bits .aes128_installedkey_set == 1 &&
330- info -> cipher .aescbc .aes -> keylen == 16 ))) {
331- if (info -> cipher .enc ) {
332- ret = wc_fspsm_AesCbcEncrypt (
333- info -> cipher .aescbc .aes ,
334- (byte * )info -> cipher .aescbc .out ,
335- (byte * )info -> cipher .aescbc .in ,
336- info -> cipher .aescbc .sz );
337- }
338- else {
339- ret = wc_fspsm_AesCbcDecrypt (
340- info -> cipher .aescbc .aes ,
341- (byte * )info -> cipher .aescbc .out ,
342- (byte * )info -> cipher .aescbc .in ,
343- info -> cipher .aescbc .sz );
344- }
345- }
346- #endif /* HAVE_AES_CBC */
282+ ret = wc_fspsm_AesCipher (devIdArg , info , ctx );
347283 #endif /* !NO_AES */
348284 }
349285
350286#if !defined(NO_RSA ) && defined(WOLFSSL_RENESAS_FSPSM_CRYPTONLY )
351287 else if (info -> algo_type == WC_ALGO_TYPE_PK ) {
352288 #if defined(WOLFSSL_KEY_GEN )
353- if (info -> pk .type == WC_PK_TYPE_RSA_KEYGEN &&
354- (info -> pk .rsakg .size == 1024 ||
355- info -> pk .rsakg .size == 2048 )) {
289+ if (info -> pk .type == WC_PK_TYPE_RSA_KEYGEN ) {
356290 ret = wc_fspsm_MakeRsaKey (info -> pk .rsakg .key ,
357291 info -> pk .rsakg .size , (void * )ctx );
358292 }
359293 #endif
360- if (info -> pk .type == WC_PK_TYPE_RSA ) {
294+ if (info -> pk .type == WC_PK_TYPE_RSA_PKCS ) {
361295 /* to perform RSA on SCE, wrapped keys should be installed
362296 * in advance. SCE supports 1024 or 2048 bits key size.
363297 * otherwise, falls-through happens.
@@ -367,10 +301,6 @@ static int Renesas_cmn_CryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
367301 cbInfo -> keyflgs_crypt .bits .rsapri1024_installedkey_set ||
368302 cbInfo -> keyflgs_crypt .bits .rsapub1024_installedkey_set ) {
369303
370- ret = wc_fspsm_MakeRsaKey (info -> pk .rsa .key , 0 , cbInfo );
371- if (ret == WC_NO_ERR_TRACE (CRYPTOCB_UNAVAILABLE ))
372- return ret ;
373-
374304 if (info -> pk .rsa .type == RSA_PRIVATE_DECRYPT ||
375305 info -> pk .rsa .type == RSA_PUBLIC_ENCRYPT )
376306 {
@@ -769,8 +699,9 @@ static int Renesas_cmn_EncryptKeys(WOLFSSL* ssl, void* ctx)
769699 #elif defined(WOLFSSL_RENESAS_FSPSM_TLS)
770700 FSPSM_ST * cbInfo = (FSPSM_ST * )ctx ;
771701
772- if (cbInfo -> keyflgs_tls .bits .session_key_set == 1 ) {
773- switch (cbInfo -> side ) {
702+ if (cbInfo != NULL && cbInfo -> internal != NULL &&
703+ cbInfo -> internal -> keyflgs_tls .bits .session_key_set == 1 ) {
704+ switch (cbInfo -> internal -> side ) {
774705 #endif
775706 case 1 :/* ENCRYPT_SIDE_ONLY */
776707 ssl -> encrypt .setup = 1 ;
0 commit comments