Repository navigation
Add ECB-wrapped ECC keys and AES key-store slots to the RTL8735B HUK port - #12056
Conversation
|
5a95202 to
46d016e
Compare
46d016e to
93dd1e8
Compare
93dd1e8 to
34c61ef
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A critical race between key-slot validation and AES execution allows concurrent deletion to zero the key before use, potentially causing successful encryption with an all-zero key.
1 open issue
What changed in this PR
This PR extends the RTL8735B HUK port with ECB-wrapped ECC scalars and hardware-slot AES keys through wolfCrypt’s key-store interface, while retaining GCM as the recommended ECC wrapping format.
Changes:
- Adds ECB scalar unwrapping and rejects partial IV/tag parameters.
- Adds AES key import, deletion and slot-backed GCM, ECB, CBC and CTR operations.
- Expands documentation, host self-tests and CI coverage.
| File | Description |
|---|---|
wolfssl/wolfcrypt/port/realtek/rtl8735b.h |
Defines slot configuration, key references and wrapping contracts. |
wolfcrypt/src/port/realtek/rtl8735b.c |
Implements wrapping support, key-store operations and host checks. |
wolfcrypt/src/port/realtek/rtl8735b_shim.h |
Adds a host stub for hardware key-slot writes. |
wolfcrypt/src/port/realtek/README.md |
Documents ECB-wrapped scalars and slot-backed AES usage. |
.github/workflows/rtl8735b.yml |
Adds key-store build and self-test coverage. |
Review effort: Balanced
436284b to
b87d4f3
Compare
|
Jenkins retest this please |
night1rider
left a comment
There was a problem hiding this comment.
Some last items I saw, along with:
Key-store slots are never exercised through the public API by any in-repo test, is this something we need?
b87d4f3 to
8e7d0c4
Compare
|
Jenkins Retest this please |

Description
The RTL8735B HUK ECDSA sign path (
wc_Rtl8735b_EccKeyviaecc_key->devCtx) only accepted an AES-GCM-wrapped scalar, so a blob wrapped with AES-ECB under the HUK, the layout STM32 DHUK uses forwc_ecc_import_wrapped_private(), could not be signed with. It now treats a key withiv,ivSz,tagandtagSzall NULL/0 as ECB-wrapped (block-padded, scalar in the firstplainLenbytes), rejects a partial IV/tag set, and leaves GCM unchanged and recommended.The HUK device also implements the key-store interface (
WOLF_CRYPTO_CB_KEYSTORE):wc_KeyStore_ImportWrapped()unwraps an AES key wrapped under the HUK (RFC 3394, or raw ECB like STM32 DHUK blobs) into a hardware key-storage slot, and anAesmade withwc_AesInit_Id()then runs GCM, ECB, CBC or CTR from that slot, so the key is in RAM only during the import. Each operation re-checks its slot under the crypto mutex, so a slot deleted or re-imported while an operation is pending fails withBAD_STATE_E.Testing
Tested on an RTL8735B EVB with both ECC wrap formats and both AES key-store formats (AES-128 and AES-256), using the example in wolfSSL/wolfssl-examples#655. Host self-test cases cover the format checks, key references, slot bookkeeping, import checks and a round trip through the public
wc_KeyStore_*andwc_AesInit_Id()calls, and the rtl8735b CI workflow gains key-store (with and withoutWOLFSSL_SMALL_STACK) and ECB-only ECC builds.Checklist