Global SHE keys#478
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a build-time option to place all AUTOSAR SHE key slots in the global-keys namespace so all clients share a single SHE device view, and updates keystore/keywrap behavior plus tests and documentation accordingly. It also hardens whnvmtool by adding SHE entry support, stricter bounds checking, fail-fast behavior, and expanded negative test coverage.
Changes:
- Add
WOLFHSM_CFG_SHE_GLOBAL_KEYSand route SHE slot key IDs through the global namespace when enabled. - Extend
whnvmtoolconfig format to supportshe ...entries, add fail-fast behavior, and add negative tests. - Add/extend multiclient + interop tests and update docs/CI workflows to cover the new configuration.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfhsm/wh_she_common.h | Introduces WH_SHE_MAKE_KEYID() / global-user selection for SHE slot key IDs. |
| wolfhsm/wh_settings.h | Documents and enforces compile-time dependencies for WOLFHSM_CFG_SHE_GLOBAL_KEYS. |
| wolfhsm/wh_client_she.h | Updates API docstring to reflect optional global SHE slot namespace. |
| tools/whnvmtool/whnvmtool.c | Adds she entries, stronger parse-time bounds, and fail-fast entry processing. |
| tools/whnvmtool/test/test_invalid_input.sh | Adds negative test script ensuring invalid configs/files fail with nonzero exit. |
| tools/whnvmtool/test/nvminit/test.nvminit | Updates test init config with a global key and example SHE entries. |
| tools/whnvmtool/test/data/she2.bin | Adds binary test fixture data for SHE provisioning tests. |
| tools/whnvmtool/README.md | Documents new bounds, global namespace semantics, and she entry format. |
| tools/whnvmtool/Makefile | Runs new negative tests as part of the test target. |
| tools/whnvmtool/.gitignore | Ensures test binary fixtures under test/data/*.bin are not ignored. |
| test/wh_test_she.c | Updates SHE key ID construction and adds global/per-client blob interop assertions. |
| test/wh_test_she_no_nvm.c | Updates SHE key ID construction to use WH_SHE_MAKE_KEYID(). |
| test/wh_test_multiclient.c | Adds a global-SHE multiclient test suite and wires in server SHE contexts. |
| test/Makefile | Adds SHE_GLOBAL build option for tests. |
| test-refactor/server/wh_test_she_server.c | Updates SHE key ID construction to use WH_SHE_MAKE_KEYID(). |
| test-refactor/server/wh_test_nvm_optional.c | Updates SHE key ID construction to use WH_SHE_MAKE_KEYID(). |
| test-refactor/posix/Makefile | Adds SHE_GLOBAL build option for refactor posix tests. |
| test-refactor/misc/wh_test_she_no_nvm.c | Updates SHE key ID construction to use WH_SHE_MAKE_KEYID(). |
| test-refactor/misc/wh_test_she_keywrap.c | Adds global/per-client blob interop assertions and updates key ID construction. |
| test-refactor/misc/wh_test_multiclient.c | Adds a global-SHE multiclient test suite and wires in server SHE contexts. |
| test-refactor/client-server/wh_test_she.c | Updates SHE key ID construction to use WH_SHE_MAKE_KEYID(). |
| src/wh_server_she.c | Routes SHE slot lookups through WH_SHE_MAKE_KEYID() so slot IDs resolve correctly under global mode. |
| src/wh_server_keystore.c | Normalizes wrap-export and unwrap-and-cache behavior for global SHE slot IDs (and rejects global-id blobs in per-client mode). |
| src/wh_client_she.c | Updates provisioning to use WH_SHE_MAKE_KEYID() for correct slot ID resolution. |
| docs/src/9-Configuration.md | Documents WOLFHSM_CFG_SHE_GLOBAL_KEYS in the configuration reference. |
| docs/src/5-Features.md | Adds “Global SHE Keys” feature documentation and updates SHE/global-keys discussion. |
| .github/workflows/build-and-test.yml | Adds CI jobs to build/test with SHE_GLOBAL=1. |
| .github/workflows/build-and-test-refactor.yml | Adds CI jobs to build/test refactor suite with SHE_GLOBAL=1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #478
Error: UnicodeDecodeError
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #478
Error: UnicodeDecodeError
8afec1b to
995fc9b
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #478
Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src
No new issues found in the changed files. ✅
- change whnvmtool to fail-fast when an image generation error occurs - Enhance whnvmtool test coverage - Small code hygene fixes
| * otherwise each client gets its own slots. The global form still evaluates | ||
| * _clientId (times zero) so call sites don't trip unused warnings. */ | ||
| #ifdef WOLFHSM_CFG_SHE_GLOBAL_KEYS | ||
| #define WH_SHE_KEY_USER(_clientId) ((_clientId) * 0 + WH_KEYUSER_GLOBAL) |
There was a problem hiding this comment.
why can't it just be WH_KEYUSER_GLOBAL?
There was a problem hiding this comment.
do we want to track these?
| * the same way the SHE commands do, whether or not the client passed the | ||
| * global flag. */ | ||
| if (targetKeyType == WH_KEYTYPE_SHE) { | ||
| targetKeyId = WH_MAKE_KEYID(WH_KEYTYPE_SHE, WH_KEYUSER_GLOBAL, |
There was a problem hiding this comment.
why would we not include this in the above swtich statement?
| /* Move the blob's id to the global namespace where the SHE commands look; | ||
| * blobs minted by per-client builds would otherwise cache under an id no | ||
| * SHE command uses and no client request can evict. Do this before the | ||
| * in-cache check and counter guard below so both see the final id. */ |
There was a problem hiding this comment.
this comment is all jargon and unintelligible. Simplify into something human readible.
| /* SHE slots are per-client on this build, so a blob minted by a global-SHE | ||
| * build would cache under an id no SHE command reads and no client request | ||
| * can evict, pinning the cache slot until reboot. Reject it instead. */ |
There was a problem hiding this comment.
jargon, unintelligible. Simplify and make human readible
| for (i = 0; i < (int)sizeof(evictSlots); i++) { | ||
| ret = wh_Server_KeystoreEvictKey( | ||
| server1, | ||
| WH_SHE_MAKE_KEYID(client1->comm->client_id, evictSlots[i])); | ||
| if (ret != 0 && ret != WH_ERROR_NOTFOUND) { |
| for (i = 0; i < (int)sizeof(evictSlots); i++) { | ||
| ret = wh_Server_KeystoreEvictKey( | ||
| server1, | ||
| WH_SHE_MAKE_KEYID(client1->comm->client_id, evictSlots[i])); | ||
| if (ret != 0 && ret != WH_ERROR_NOTFOUND) { |
| @@ -161,55 +204,93 @@ static void processEntry(Entry* entry, int isKey, whNvmContext* nvmContext) | |||
| fprintf(stderr, "Error: Failed to read entire file %s\n", | |||
| entry->filePath); | |||
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #478
Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src
No new issues found in the changed files. ✅
Adds support for global SHE keys
Other fixes: