Skip to content

Allow NULL NVM context#392

Merged
billphipps merged 1 commit into
wolfSSL:mainfrom
bigbrett:nvm-optional
Jun 5, 2026
Merged

Allow NULL NVM context#392
billphipps merged 1 commit into
wolfSSL:mainfrom
bigbrett:nvm-optional

Conversation

@bigbrett
Copy link
Copy Markdown
Contributor

@bigbrett bigbrett commented Jun 1, 2026

Refactors some server-side code to allow for a NULL NVM context on server init. This formalizes the use case of relying on the keycache only for platforms without NVM.

@bigbrett bigbrett self-assigned this Jun 1, 2026
Copilot AI review requested due to automatic review settings June 1, 2026 17:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors server-side code to make the NVM context optional at wh_Server_Init time, so platforms without persistent storage can run the server using only the in-RAM key cache. Cache-only crypto continues to work when keys are primed, while NVM-only features (object request API, counters, certificate chain verification against stored roots, key commit, SHE persistence, image-sig load) now fail gracefully at runtime instead of crashing.

Changes:

  • Make whServerConfig.nvm optional and guard all server->nvm dereferences in the keystore, counter handler, and lock helpers; global-key routing falls back to the per-context local cache when nvm is NULL.
  • Add comprehensive unit tests (both test/ and test-refactor/server/) that stand up a server with nvm == NULL and exercise priming, read, freshen, AES-CBC round trip, erase, erase-checked, revoke, NVM-only request handlers, SHE keystore, and threadsafe lock no-ops.
  • Update API docs/header comments to describe the optional-NVM mode and what does/doesn't work without NVM.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wolfhsm/wh_server.h Documents nvm as optional in whServerConfig and updates wh_Server_Init Doxygen.
src/wh_server.c wh_Server_NvmLock/Unlock return OK as a no-op when nvm == NULL.
src/wh_server_keystore.c NULL-safe server->nvm in cache routing, policy check, unique-id allocation, freshen/read/commit/erase/erase-checked/revoke.
src/wh_server_counter.c Removes server->nvm == NULL early BADARGS so handler formats a real error response.
docs/src/5-Features.md New "Optional NVM Backing" section + TOC entry.
test/wh_test.c Invokes the new whTest_NvmOptional() test under server+crypto build.
test/wh_test_nvm_optional.h Public declaration of the new test entrypoint.
test/wh_test_nvm_optional.c New self-contained test that stands up an NVM-less server and exercises the keystore, counter, NVM request handler, and SHE paths.
test-refactor/wh_test_list.c Registers whTest_NvmOptional under the server test list.
test-refactor/server/wh_test_nvm_optional.c Mirror of the standalone test for the shared-context refactor runner; temporarily detaches/restores server->nvm.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #392

Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

No new issues found in the changed files. ✅

@bigbrett bigbrett force-pushed the nvm-optional branch 4 times, most recently from 551e17d to 36e9ce5 Compare June 1, 2026 20:46
@billphipps billphipps merged commit 803241b into wolfSSL:main Jun 5, 2026
108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants