diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c index 6340bf411..1fb11207a 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c @@ -244,7 +244,8 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out, (void) key_server_aes; /* sanity check */ - if (aes == NULL || authTagSz > WC_AES_BLOCK_SIZE || ivSz == 0 || info == NULL) { + if (aes == NULL || authTagSz > WC_AES_BLOCK_SIZE || ivSz == 0 || + info == NULL) { return BAD_FUNC_ARG; } @@ -453,7 +454,8 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out, FSPSM_AES_PWKEY key_server_aes = NULL; (void) key_client_aes; /* sanity check */ - if (aes == NULL || authTagSz > WC_AES_BLOCK_SIZE || ivSz == 0 || info == NULL) { + if (aes == NULL || authTagSz > WC_AES_BLOCK_SIZE || ivSz == 0 || + info == NULL) { return BAD_FUNC_ARG; } @@ -812,14 +814,15 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen, } #endif -WOLFSSL_LOCAL int wc_fspsm_AesCipher(int devIdArg, wc_CryptoInfo* info, void* ctx) +WOLFSSL_LOCAL int wc_fspsm_AesCipher(int devIdArg, wc_CryptoInfo* info, + void* ctx) { int ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN); FSPSM_ST* cbInfo = (FSPSM_ST*)ctx; (void)devIdArg; WOLFSSL_ENTER("wc_fspsm_AesCipher"); - + if (info == NULL || ctx == NULL) { return BAD_FUNC_ARG; } diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c index 4f586d201..d17865a22 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_util.c @@ -67,10 +67,6 @@ static fspsm_key_data g_user_key_info; static uint32_t g_encrypted_publicCA_key[HW_SCE_SINST_WORD_SIZE]; extern uint32_t g_CAscm_Idx; /* index of CM table */ -//#define USE_GLOBAL_INTERNAL -#if !defined(USE_GLOBAL_INTERNAL) -FSPSM_ST_Internal g_internal; -#endif #endif #endif /* WOLFSSL_RENESAS_FSPSM*/ @@ -445,7 +441,7 @@ int fspsm_EccSharedSecret(WOLFSSL* ssl, ecc_key* otherKey, } else { /* set master secret generation callback for use */ - wolfSSL_CTX_SetGenMasterSecretCb(ssl->ctx, + wolfSSL_CTX_SetGenMasterSecretCb(ssl->ctx, Renesas_cmn_genMasterSecret); wolfSSL_SetGenMasterSecretCtx(ssl, cbInfo); } @@ -458,7 +454,7 @@ int fspsm_EccSharedSecret(WOLFSSL* ssl, ecc_key* otherKey, wc_fspsm_hw_unlock(); *outlen = 64; - WOLFSSL_PKMSG("PK ECC PMS: ret %d, PubKeySz %d, OutLen %d\n", + WOLFSSL_PKMSG("PK ECC PMS: ret %d, PubKeySz %d, OutLen %d\n", ret, *pubKeySz, *outlen); } @@ -852,9 +848,9 @@ int wc_fspsm_generateSessionKey(WOLFSSL *ssl, /* ready-for-use flag will be set when SetKeySide() is called */ } - if (cbInfo->internal->cipher == + if (cbInfo->internal->cipher == SCE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 || - cbInfo->internal->cipher == + cbInfo->internal->cipher == SCE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) { enc->aes->nonceSz = AEAD_MAX_IMP_SZ; dec->aes->nonceSz = AEAD_MAX_IMP_SZ; @@ -1151,12 +1147,12 @@ int wc_fspsm_storeKeyCtx(WOLFSSL* ssl, FSPSM_ST* info) ret = BAD_FUNC_ARG; if (ret == 0) { - XMEMCPY(info->internal->masterSecret, + XMEMCPY(info->internal->masterSecret, ssl->arrays->fspsm_masterSecret, FSPSM_TLS_MASTERSECRET_SIZE); - XMEMCPY(info->internal->clientRandom, + XMEMCPY(info->internal->clientRandom, ssl->arrays->clientRandom, 32); - XMEMCPY(info->internal->serverRandom, + XMEMCPY(info->internal->serverRandom, ssl->arrays->serverRandom, 32); info->internal->cipher = (uint8_t)GetSceCipherSuite( @@ -1246,12 +1242,8 @@ void wc_fspsm_TlsCleanup(WOLFSSL* ssl) return; /* free internal structure */ if (tuc->internal) { -#if !defined(USE_GLOBAL_INTERNAL) XFREE(tuc->internal, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER); tuc->internal = NULL; -#else - ForceZero(tuc->internal, sizeof(FSPSM_ST_Internal)); -#endif } /* zero clear */ @@ -1272,14 +1264,9 @@ WOLFSSL_API int wc_fspsm_set_callback_ctx(WOLFSSL* ssl, void* user_ctx) } ForceZero(uCtx, sizeof(FSPSM_ST)); -#if !defined(USE_GLOBAL_INTERNAL) uCtx->internal = (FSPSM_ST_Internal*)XMALLOC(sizeof(FSPSM_ST_Internal), ssl->heap, DYNAMIC_TYPE_TMP_BUFFER); -#else - printf("sizeof (FSPSM_ST_Internal) = %d\n", sizeof(FSPSM_ST_Internal)); - uCtx->internal = &g_internal; -#endif if (!uCtx->internal) { WOLFSSL_MSG("Failed to allocate memory for user ctx internal"); return MEMORY_E; diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h index 48be879a9..dc341bdce 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h @@ -46,7 +46,7 @@ typedef struct FSPSM_ST_Internal FSPSM_ST_Internal; typedef struct FSPSM_tag_ST { /* unique number for each session */ int devId; - + /* installed key handling */ /* aes */ FSPSM_W_KEYVAR wrapped_key_aes256; diff --git a/wolfssl/wolfcrypt/port/Renesas/renesas_fspsm_internal.h b/wolfssl/wolfcrypt/port/Renesas/renesas_fspsm_internal.h index 89ad9ab67..4acf44e5a 100644 --- a/wolfssl/wolfcrypt/port/Renesas/renesas_fspsm_internal.h +++ b/wolfssl/wolfcrypt/port/Renesas/renesas_fspsm_internal.h @@ -180,7 +180,7 @@ WOLFSSL_LOCAL int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out, const byte* authTag, word32 authTagSz, const byte* authIn, word32 authInSz, void* ctx); - + WOLFSSL_LOCAL int wc_fspsm_AesCipher(int devIdArg, struct wc_CryptoInfo* info, void* ctx); WOLFSSL_LOCAL int wc_fspsm_tls_RootCertVerify(