Skip to content

Fix TSIP SHA error propagation in TSIPHashFinal / TSIPHashGet#10789

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

Fix TSIP SHA error propagation in TSIPHashFinal / TSIPHashGet#10789
miyazakh wants to merge 4 commits into
wolfSSL:masterfrom
miyazakh:f6162_tsiphash

Conversation

@miyazakh

Copy link
Copy Markdown
Contributor

Description

Fix TSIP SHA error propagation in TSIPHashFinal / TSIPHashGet

Problem

TSIPHashFinal and TSIPHashGet in renesas_tsip_sha.c silently returned 0
(success) when the TSIP hardware Init() or Update() step failed, leaving
the digest buffer unwritten. Same defect class as issue #5420 (FSPSM path).

Fix

  • Initialize ret = WC_HW_E instead of leaving it uninitialized.
  • Add else { ret = WC_HW_E; } for Update() failure.
  • Add early return after the hardware block so failures are not swallowed by the
    trailing TSIPHashFree / TSIPHashInit calls.
  • Replace the hardcoded return 0 at the end of TSIPHashGet with return ret.

Tests Added (wolfssl_tsip_unit_test.c)

  • tsip_sha256_hash_test() — verifies wc_Sha256Final digest and confirms
    wc_Sha256GetHash is non-destructive.
  • tsip_sha1_hash_test() — same for SHA-1.

Both tests pass on RX72N EnvisionKit.

Checklist

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

@miyazakh miyazakh self-assigned this Jun 26, 2026
Copilot AI review requested due to automatic review settings June 26, 2026 06:03

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

Fixes error propagation in the Renesas TSIP hash (SHA-1/SHA-256) Final/Get paths so hardware failures don’t incorrectly return success, and adds RX72N EnvisionKit demo/unit tests to validate correct digest output and non-destructive GetHash behavior.

Changes:

  • Initialize return codes to a failing default (WC_HW_E) and stop returning hardcoded success in TSIPHashGet.
  • Add explicit failure handling for TSIP Update() failures.
  • Add TSIP SHA-1/SHA-256 tests validating Final correctness and GetHash non-destructiveness.

Reviewed changes

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

File Description
wolfcrypt/src/port/Renesas/renesas_tsip_sha.c Improves TSIP SHA Final/Get error propagation and return semantics.
IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/wolfssl_tsip_unit_test.c Adds SHA-256 and SHA-1 TSIP hash tests and runs them from tsip_crypt_test().

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

Comment thread wolfcrypt/src/port/Renesas/renesas_tsip_sha.c
Comment thread wolfcrypt/src/port/Renesas/renesas_tsip_sha.c
Comment thread wolfcrypt/src/port/Renesas/renesas_tsip_sha.c Outdated
Comment thread wolfcrypt/src/port/Renesas/renesas_tsip_sha.c Outdated
@miyazakh miyazakh marked this pull request as ready for review June 27, 2026 09:09
@github-actions

Copy link
Copy Markdown

retest this please

@miyazakh

Copy link
Copy Markdown
Contributor Author

retest this please

1 similar comment
@miyazakh

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