Fix TSIP SHA error propagation in TSIPHashFinal / TSIPHashGet#10789
Draft
miyazakh wants to merge 1 commit into
Draft
Fix TSIP SHA error propagation in TSIPHashFinal / TSIPHashGet#10789miyazakh wants to merge 1 commit into
miyazakh wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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 inTSIPHashGet. - Add explicit failure handling for TSIP
Update()failures. - Add TSIP SHA-1/SHA-256 tests validating
Finalcorrectness andGetHashnon-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 on lines
410
to
+414
| tsip_hw_unlock(); | ||
|
|
||
| if (ret != 0) { | ||
| return ret; | ||
| } |
Comment on lines
+412
to
417
| if (ret != 0) { | ||
| return ret; | ||
| } | ||
|
|
||
| TSIPHashFree(hash); | ||
| return TSIPHashInit(hash, heap, 0, hash->sha_type); |
Comment on lines
+1512
to
+1516
| wc_Sha256 sha; | ||
| byte hash1[WC_SHA256_DIGEST_SIZE]; | ||
| byte hash2[WC_SHA256_DIGEST_SIZE]; | ||
| int ret = 0; | ||
|
|
Comment on lines
+1530
to
+1534
| ret = wc_InitSha256_ex(&sha, NULL, 0); | ||
| if (ret != 0) { | ||
| ret = -1; | ||
| goto out; | ||
| } |
Comment on lines
+1587
to
+1594
| out: | ||
| if (prnt) { | ||
| if (ret != 0) | ||
| printf("(code=%d) ", ret); | ||
| RESULT_STR(ret) | ||
| } | ||
| return ret; | ||
| } |
Comment on lines
+1600
to
+1604
| wc_Sha sha; | ||
| byte hash1[WC_SHA_DIGEST_SIZE]; | ||
| byte hash2[WC_SHA_DIGEST_SIZE]; | ||
| int ret = 0; | ||
|
|
Comment on lines
+1617
to
+1621
| ret = wc_InitSha_ex(&sha, NULL, 0); | ||
| if (ret != 0) { | ||
| ret = -1; | ||
| goto out; | ||
| } |
Comment on lines
+1680
to
+1687
| out: | ||
| if (prnt) { | ||
| if (ret != 0) | ||
| printf("(code=%d) ", ret); | ||
| RESULT_STR(ret) | ||
| } | ||
| return ret; | ||
| } |
Comment on lines
403
to
404
| return ret; | ||
| } |
Comment on lines
455
to
456
| return ret; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix TSIP SHA error propagation in TSIPHashFinal / TSIPHashGet
Problem
TSIPHashFinalandTSIPHashGetinrenesas_tsip_sha.csilently returned 0(success) when the TSIP hardware
Init()orUpdate()step failed, leavingthe digest buffer unwritten. Same defect class as issue #5420 (FSPSM path).
Fix
ret = WC_HW_Einstead of leaving it uninitialized.else { ret = WC_HW_E; }forUpdate()failure.trailing
TSIPHashFree/TSIPHashInitcalls.return 0at the end ofTSIPHashGetwithreturn ret.Tests Added (
wolfssl_tsip_unit_test.c)tsip_sha256_hash_test()— verifieswc_Sha256Finaldigest and confirmswc_Sha256GetHashis non-destructive.tsip_sha1_hash_test()— same for SHA-1.Both tests pass on RX72N EnvisionKit.
Checklist