fenrir fixes - #518
Conversation
Fixes fenrir 11419
Fixes fenrir: 10226
Fixes fenrir: 11394
Fixes fenrir: 11393
Fixes fenrir: 10219
Fixes fenrir: 11410
There was a problem hiding this comment.
Pull request overview
This PR tightens and documents SHE key-update authorization behavior, improves keystore/NVM consistency, and hardens several client/server crypto edge cases while expanding test coverage for the updated rules.
Changes:
- Enforce AUTOSAR SHE Table 4.5 key-update authorization matrix server-side and add tests validating allowed/denied pairings.
- Improve key/seed consistency by evicting stale cached entries after persisting updates and by persisting revocations before mutating cache state.
- Harden client crypto helpers (SHA state rollback on error; ML-DSA public export buffer sizing) and document the SHE authorization policy.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/wh_test_she.c | Adds SHE LOAD_KEY authorization-matrix test coverage (reject/allow cases). |
| test-refactor/client-server/wh_test_she.c | Mirrors authorization-matrix tests and fixes an oversized-auth test to align with new policy checks. |
| src/wh_server.c | Wires optional DMA custom client-copy callback from config into server DMA context. |
| src/wh_server_she.c | Adds explicit LOAD_KEY authorization-matrix enforcement; evicts cached PRNG seed after updates. |
| src/wh_server_keystore.c | Reorders key revocation to persist to NVM before mutating cache/commit state. |
| src/wh_client_crypto.c | Restores SHA state on client-side errors for software fallback; increases ML-DSA export public buffer size. |
| docs/src/5-Features.md | Documents SHE memory update authorization policy and wolfHSM’s SECRET_KEY authorization extension. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #518
Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
| _revokeKey(&revokedMeta); | ||
| ret = wh_Nvm_AddObjectWithReclaim(server->nvm, &revokedMeta, | ||
| revokedMeta.len, cacheBuf); | ||
| if (ret == WH_ERROR_OK) { |
There was a problem hiding this comment.
If the NVM write fails, looks like the revoked copy is dropped and the entry lives on unrevoked. Is that what you're going for?
Alternatively, should we mark the entry as uncommitted/dirty and then do the write?
| @@ -190,8 +190,9 @@ int whServerDma_CopyToClient(struct whServerContext_t* server, | |||
| /* Perform the actual copy */ | |||
| #ifdef WOLFHSM_CFG_DMA_CUSTOM_CLIENT_COPY | |||
There was a problem hiding this comment.
Should WOLFHSM_CFG_DMA_CUSTOM_CLIENT_COPY exist in a test case, or even a Makefile?
| * Table 4.5), with one documented wolfHSM extension: SECRET_KEY, the ROM root | ||
| * of trust, may authorize any load so it can provision MASTER_ECU_KEY. | ||
| * Returns 0 when allowed, WH_SHE_ERC_KEY_INVALID otherwise. */ | ||
| static int _CheckLoadKeyAuth(uint16_t targetId, uint16_t authId) |
There was a problem hiding this comment.
According to a quick coverage run, the two SHE fixes here aren't covered with the new tests. Could we add those?
LOAD_KEYaccepted any slot as the authorizing key (e.g. a client-loaded RAM key could overwriteMASTER_ECU_KEY). Changed to now enforce the AUTOSAR SHE update-authorization matrix (Table 4.5), documented indocs/src/5-Features.md.wh_Server_Initdropped the DMAmemCopyCbsupplied throughwhServerConfig. Fixed, it is now installed (underWOLFHSM_CFG_DMA_CUSTOM_CLIENT_COPY)._ExtendSeedre-read a stale seed. Fixed so the cache entry is now evicted after the NVM write.