Skip to content

[Renesas RX72N] RX72N TSIP fixes and command-line build/flash/UART tooling#10842

Open
miyazakh wants to merge 4 commits into
wolfSSL:masterfrom
miyazakh:f6162_tsiphash
Open

[Renesas RX72N] RX72N TSIP fixes and command-line build/flash/UART tooling#10842
miyazakh wants to merge 4 commits into
wolfSSL:masterfrom
miyazakh:f6162_tsiphash

Conversation

@miyazakh

@miyazakh miyazakh commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

RX72N TSIP fixes and command-line build/flash/UART tooling

TSIP crypto/hardware fixes

  • tsip_ImportPublicKey / wc_tsip_generateSessionKey: fixed tsip_hw_lock() leaks on allocation failure (renesas_tsip_util.c) — an XMALLOC failure returned early without calling tsip_hw_unlock(), permanently holding the TSIP hardware lock. (f5419)
  • TSIPHashFinal / TSIPHashGet: fixed silent-success-on-failure bugs in renesas_tsip_sha.cret was left uninitialized on some paths, a Final() call that succeeded with the wrong output size still returned 0 (success), and TSIPHashGet unconditionally return 0 regardless of the actual result. (f6162)
  • wc_tsip_AesGcmDecrypt: fixed a copy-paste bug where the 32-bit-aligned aadBuf was allocated and filled but never used — the TSIP updateFn call passed the original (possibly unaligned) authIn pointer instead, unlike the correct encrypt-side code. Could cause AES_GCM_AUTH_E on valid input when the caller's AAD buffer isn't aligned. (f6163)
  • tsip_Tls13AesEncrypt: fixed two error-log messages copy-pasted from the decrypt function (said "Decrypt" instead of "Encrypt"); no functional impact, diagnostics only. (f1535)

build.bat, debug_run.bat, and UART output

  • Routed printf() to the on-board SCI2 UART (switchable back to the E1/E2 Virtual Console via BSP_CFG_USER_CHARPUT_ENABLED), and fixed the underlying clock-forcing and baud-rate calculation bugs that caused wrong benchmark timing and garbled UART output.
  • Rewrote debug_run.bat to flash and run via Renesas Flash Programmer instead of a raw GDB session (more reliable — sidesteps device-specific GDB setup e2studio's GUI does internally).
  • build.bat now accepts crypt/bench/TLSClient to switch the demo mode before building, fixes a stale-object incremental-build bug, and fails with a clear message on a not-yet-bootstrapped checkout.
  • Updated README_EN.md / README_JP.md accordingly.

Testing

Run example programs including crypt, bench and TLS

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

  - Add GCM_TABLE_4BIT
  - Add build.bat for command line build
  - f5419 mutex
  - f6163 AES aadBuf
  - Add debug_run.bat to write and run the example from CL
  - Add UART message
  - Messages are routed sci2_uart_charput(). To get back to Virtual Consol, it takes BSP_CFG_USER_CHARPUT_ENABLED 0.

f1535 error messaages typo
Copilot AI review requested due to automatic review settings July 3, 2026 05:18
@miyazakh miyazakh self-assigned this Jul 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the Renesas RX72N TSIP integration by fixing several concrete error-path and correctness issues in TSIP-backed crypto operations, and adds/updates RX72N e2studio “Simple” tooling to support command-line build/flash and reliable UART printf() output.

Changes:

  • Fix TSIP hardware-lock handling and correctness/return-value bugs in TSIP key import, hash finalize/get, and AES-GCM decrypt AAD handling.
  • Add TSIP SHA-1/SHA-256 behavioral tests to the RX72N TSIP unit test app.
  • Add RX72N command-line helper scripts (build / demo-mode switch / flash-run) and route printf() to SCI2 UART via BSP charput.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
wolfcrypt/src/port/Renesas/renesas_tsip_util.c Fix TSIP HW lock leak on allocation failure paths.
wolfcrypt/src/port/Renesas/renesas_tsip_sha.c Fix uninitialized/incorrect return behavior in TSIP hash Final/Get paths.
wolfcrypt/src/port/Renesas/renesas_tsip_aes.c Fix AES-GCM decrypt to use aligned AAD buffer; correct TLS 1.3 encrypt log strings.
IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c Add TSIP SHA-1/SHA-256 tests; minor test-flow change near TSIP init.
IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h Enable GCM_TABLE_4BIT in RX72N demo settings.
IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/test.scfg Enable BSP charput hook and point it to sci2_uart_charput; other config text normalization.
IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/test/src/test_main.c Initialize SCI2 UART for printf(), including a re-init after wolfCrypt_Init().
IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/common/wolfssl_dummy.c Implement SCI2 UART charput + init used by BSP hook for printf().
IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/set_demo_mode.ps1 New script to toggle demo-mode macros and touch dependents for rebuild.
IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/debug_run.bat New script to flash/run via Renesas Flash Programmer CLI.
IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/build.bat New command-line build wrapper with demo-mode switching and bootstrap checks.
IDE/Renesas/e2studio/RX72N/EnvisionKit/include.am Update distribution list to include new tooling (currently only adds build.bat).
Comments suppressed due to low confidence (1)

IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c:1703

  • This if (ret != 0) block is unreachable because ret is initialized to 0 and not modified before the check, making the error path dead code and the message misleading. Either assign ret from the intended key-generation/init step, or remove this block.

    if (ret != 0) {
        printf("TSIP Key Generation failed\n");
        return -1;
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/set_demo_mode.ps1
Comment thread IDE/Renesas/e2studio/RX72N/EnvisionKit/include.am
Comment thread IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/build.bat Outdated
Comment thread IDE/Renesas/e2studio/RX72N/EnvisionKit/Simple/debug_run.bat Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread wolfcrypt/src/port/Renesas/renesas_tsip_sha.c Outdated
Comment thread IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c Outdated
@miyazakh miyazakh marked this pull request as ready for review July 3, 2026 21:41
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

retest this please

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m3

  • FLASH: .text +72 B (+0.1%, 122,181 B / 262,144 B, total: 47% used)

gcc-arm-cortex-m4

  • FLASH: .rodata.wolfSSL_ERR_reason_error_string.str1.1 +18 B, .text +128 B (+0.1%, 199,902 B / 262,144 B, total: 76% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +128 B (+0.1%, 180,632 B / 1,048,576 B, total: 17% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +16 B, .text +576 B (+0.1%, 769,492 B / 1,048,576 B, total: 73% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +64 B (+0.0%, 212,142 B / 262,144 B, total: 81% used)

gcc-arm-cortex-m4-pq

  • FLASH: .rodata +24 B, .text +320 B (+0.1%, 278,984 B / 1,048,576 B, total: 27% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .rodata +24 B, .text +384 B (+0.1%, 324,584 B / 1,048,576 B, total: 31% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +64 B (+0.1%, 122,957 B / 262,144 B, total: 47% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .rodata.wolfSSL_ERR_reason_error_string.str1.1 +18 B, .text +320 B (+0.1%, 235,728 B / 262,144 B, total: 90% used)

gcc-arm-cortex-m7

  • FLASH: .rodata.wolfSSL_ERR_reason_error_string.str1.1 +18 B, .text +64 B (+0.0%, 199,838 B / 262,144 B, total: 76% used)

gcc-arm-cortex-m7-pq

  • FLASH: .rodata +24 B, .text +320 B (+0.1%, 279,560 B / 1,048,576 B, total: 27% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .rodata.wolfSSL_ERR_reason_error_string.str1.1 +18 B, .text +320 B (+0.1%, 235,728 B / 262,144 B, total: 90% used)

linuxkm-pie

  • Data: __patchable_function_entries +40 B (+0.2%, 25,320 B)

linuxkm-standard

  • Data: __patchable_function_entries +96 B (+0.2%, 47,952 B)

stm32-sim-stm32h753

@miyazakh

miyazakh commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

retest this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants