Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The damaged-blob guarantee overstates integrity protection because qx and qy are neither authenticated nor read during loading; the documentation and test description need to distinguish authenticated scalar-wrap protection from public-key integrity.
1 open issue
What changed in this PR
Adds a HUK-wrapped P-256 key reload example to the RTL8735B demo and aligns existing tests and documentation with the RealTek port’s behavior.
Changes:
- Adds a stored-key blob format and helpers to wrap, reload, and sign, with signature verification and tag-tampering checks.
- Replaces plaintext AES-GCM long-IV rejection expectations with a software-fallback comparison.
- Corrects scalar-wrapping descriptions from ECB to AES-GCM and updates sample output.
| File | Description |
|---|---|
rtl8735b/README.md |
Documents wrapped-key storage, corrects the wrapping mode, and updates expected output. |
rtl8735b/main.c |
Adds blob creation and reload tests, corrects the long-IV test, and updates comments. |
Review effort: Balanced
| - HMAC-SHA256 under the HUK (`wc_HmacInit` with `devId = WC_HUK_DEVID`, then `wc_HmacSetKey`/`wc_HmacUpdate`/`wc_HmacFinal`): the MAC is deterministic for a given seed and differs for a wrong seed. | ||
| - HUK-bound ECDSA P-256 sign: a key is generated in software, its private scalar is wrapped under the HUK (ECB-encrypted with the HUK device), and signing then goes through the HUK device (unwrap + sign); the signature verifies against the software public key. | ||
| - HUK-bound ECDSA P-256 sign: a key is generated in software, its private scalar is wrapped under the HUK (AES-GCM-encrypted with the HUK device), and signing then goes through the HUK device (unwrap + sign); the signature verifies against the software public key. | ||
| - HUK-wrapped key storage: `huk_blob_create()` and `huk_blob_load()` in `main.c` show how to wrap a P-256 key, keep the seed, IV, tag, wrapped scalar and public key as a stored blob, and sign with a key set up from that blob alone. The blob only unwraps on the device that wrapped it, and a damaged blob fails with `AES_GCM_AUTH_E`. |
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
Adds a wrap, store, reload and sign example for a HUK-wrapped ECC key to the
rtl8735bexample, and corrects two places where the example disagreed with the wolfSSL RealTek port.What it adds
huk_key_blob- the seed, IV, tag, wrapped scalar and public key an application storeshuk_blob_create()- generates a P-256 key and wraps its scalar under the HUK with a fresh seed and IVhuk_blob_load()- sets up a signing key from a stored blob throughecc_key->devCtxhuk_ecdsa_reload_test()- signs from the blob, verifies with the stored public key, and checks that a damaged blob fails withAES_GCM_AUTH_ECorrections
The README and the comment above
huk_ecdsa_test()described the scalar wrap as ECB. The code and the port'swc_Rtl8735b_EccKeyuse AES-GCM with an IV and tag, and both now say so.plain_gcm_badiv_test()required a non-12-byte IV to fail on the plaintext-key AES device. The port deliberately declines that request so software GCM serves it with the same literal key, so the encrypt succeeds and the test printed[FAIL]. It is nowplain_gcm_long_iv_test(), which requires the encrypt to succeed and its output to match software GCM with the same key. The HUK device still hard-fails a non-12-byte IV because its key bytes are a derivation seed, andhuk_gcm_badiv_test()is unchanged.Testing
Built with the RealTek FreeRTOS SDK against current wolfSSL master and run on an RTL8735B EVB with all checks passing. A blob wrapped by one flashed image also loaded and signed correctly in a later image after a power-on reset, using a temporary test build of the example. Moving a blob to a second device was not tested, because only one board was available.