diff --git a/IDE/Renesas/e2studio/RA6M4/tools/README.md b/IDE/Renesas/e2studio/RA6M4/tools/README.md index afe12a5743..aa2f0d5b28 100644 --- a/IDE/Renesas/e2studio/RA6M4/tools/README.md +++ b/IDE/Renesas/e2studio/RA6M4/tools/README.md @@ -99,8 +99,8 @@ example_keys/ +-- rsa_public.pem matching public key, used to verify the signature +-- generate_SignedCA.sh sign + verify + convert to C, in one step (Linux/macOS/Git Bash) +-- generate_SignedCA.bat Windows cmd.exe/PowerShell wrapper (calls the .sh via Git Bash) -+-- ca-cert.der.sign pre-generated: RSA-PSS signature over certs/ca-cert.der -+-- ca-cert.der.c pre-generated: the above, as a C byte array -+-- ca-ecc-cert.der.sign pre-generated: RSA-PSS signature over certs/ca-ecc-cert.der -+-- ca-ecc-cert.der.c pre-generated: the above, as a C byte array ``` + +Running the script above also writes `.der.sign` and `.der.c` next to it +(e.g. `ca-cert.der.sign`/`ca-cert.der.c`, `ca-ecc-cert.der.sign`/`ca-ecc-cert.der.c`) -- +these are generated output, not checked into this tree. diff --git a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c index 510c38a2c0..a6c3f611ee 100644 --- a/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c +++ b/wolfcrypt/src/port/Renesas/renesas_fspsm_aes.c @@ -340,6 +340,7 @@ int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out, uint8_t delta; uint8_t aadDelta; int initOk = 0; + int updateOk = 0; const uint8_t* iv_l = NULL; uint32_t ivSz_l = 0; @@ -508,7 +509,8 @@ int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out, &out_len_tmp); out_len += out_len_tmp; } - if (ret != FSP_SUCCESS) { + updateOk = (ret == FSP_SUCCESS); + if (!updateOk) { WOLFSSL_MSG("R_XXXX_AesXXXGcmEncryptUpdate2: failed"); ret = -1; } @@ -537,7 +539,7 @@ int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out, #endif aTagBuf); - if (ret == FSP_SUCCESS) { + if (ret == FSP_SUCCESS && updateOk) { #if (WOLFSSL_RENESAS_RZFSP_VER >= 220) out_len += out_len_tmp; dataLen = out_len; @@ -554,7 +556,9 @@ int wc_fspsm_AesGcmEncrypt(struct Aes* aes, byte* out, } } else { - WOLFSSL_MSG("R_SCE_AesxxxGcmEncryptFinal: failed"); + if (ret != FSP_SUCCESS) { + WOLFSSL_MSG("R_SCE_AesxxxGcmEncryptFinal: failed"); + } ret = -1; } } @@ -613,6 +617,7 @@ int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out, uint8_t delta; uint8_t aadDelta; int initOk = 0; + int updateOk = 0; const uint8_t* iv_l = NULL; uint32_t ivSz_l = 0; @@ -771,7 +776,8 @@ int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out, plainBuf, sz, NULL, 0UL, &out_len_tmp); out_len += out_len_tmp; } - if (ret != FSP_SUCCESS) { + updateOk = (ret == FSP_SUCCESS); + if (!updateOk) { WOLFSSL_MSG("R_XXXX_AesXXXGcmDecryptUpdate: failed in decrypt"); ret = -1; } @@ -800,7 +806,7 @@ int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out, aTagBuf, min(16, authTagSz)); - if (ret == FSP_SUCCESS) { + if (ret == FSP_SUCCESS && updateOk) { #if (WOLFSSL_RENESAS_RZFSP_VER >= 220) out_len += out_len_tmp; dataLen = out_len; @@ -814,21 +820,22 @@ int wc_fspsm_AesGcmDecrypt(struct Aes* aes, byte* out, XMEMCPY(out, plainBuf, dataLen); } } - else { + else if (ret != FSP_SUCCESS) { WOLFSSL_MSG("R_XXXX_AesXXXGcmDecryptFinal: failed"); - /* A bad/tampered auth tag is reported by the hardware as one - * of these FSP-specific codes, not a generic failure -- the - * wolfCrypt API contract requires AES_GCM_AUTH_E specifically - * here (callers, and wolfcrypt_test()'s tampered-tag test, - * distinguish "authentication failed" from other errors). */ - if (ret == FSP_ERR_CRYPTO_SCE_AUTHENTICATION || - ret == FSP_ERR_CRYPTO_AUTHENTICATION_FAILED) { + /* Only map to AES_GCM_AUTH_E if Update actually succeeded. */ + if (updateOk && + (ret == FSP_ERR_CRYPTO_SCE_AUTHENTICATION || + ret == FSP_ERR_CRYPTO_AUTHENTICATION_FAILED)) { ret = AES_GCM_AUTH_E; } else { ret = -1; } } + else { + /* Final reported success, but Update had already failed. */ + ret = -1; + } } }