cache-only shared secrets#372
Open
bigbrett wants to merge 3 commits into
Open
Conversation
Extend EccSharedSecret and Curve25519SharedSecret APIs with CacheKey variants (sync + async request/response) that store the derived secret in a server key cache slot instead of returning it to the client. Adds flags/keyId/label fields to the ECDH and Curve25519 messages, a shared wh_Server_KeyCacheImportRaw helper, and crypto tests covering both paths.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds cache-mode shared-secret support so ECDH and X25519 outputs can remain server-resident instead of always being returned to the client.
Changes:
- Extends ECDH and Curve25519 request/response messages with cache flags, output key IDs, and labels.
- Adds client/server handling for cached shared-secret outputs using raw key-cache import.
- Adds crypto tests covering cached ECDH/X25519 secrets, caller-supplied IDs, NONEXPORTABLE behavior, and guard cases.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
wolfhsm/wh_server_crypto.h |
Declares raw key-cache import helper for shared-secret/KDF outputs. |
wolfhsm/wh_message_crypto.h |
Extends ECDH and Curve25519 message structs for cache-mode semantics. |
wolfhsm/wh_client_crypto.h |
Adds public cache-mode shared-secret APIs and async Curve25519 shared-secret APIs. |
src/wh_server_crypto.c |
Implements cache-mode ECDH/X25519 server handling and raw cache import helper. |
src/wh_message_crypto.c |
Translates new message fields. |
src/wh_client_crypto.c |
Refactors shared-secret client paths and adds cache-key request/response wrappers. |
test/wh_test_crypto.c |
Adds ECDH and X25519 cache-mode shared-secret coverage. |
test/wh_test_check_struct_padding.c |
Includes Curve25519 message structs in padding checks. |
💡 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 #372
Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src
No new issues found in the changed files. ✅
When the blocking CacheKey API auto-imports local input keys, the server allocates their keyIds from WH_KEYID_IDMAX downward (0xFF, 0xFE, ...). If the caller picks an output keyId that collides with one of those auto-imported inputs, the EVICTPUB/EVICTPRV cleanup runs after the import and deletes the cache slot we just wrote the secret to, while still returning success and the keyId. Clear the matching evict flag after a successful import so cleanup leaves the cached secret alone
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.
This PR adds cache-mode shared-secret support so ECDH and X25519 outputs can remain server-resident instead of always being returned to the client.
Changes: