Skip to content

cache-only shared secrets#372

Open
bigbrett wants to merge 3 commits into
wolfSSL:mainfrom
bigbrett:cached-shared-secret
Open

cache-only shared secrets#372
bigbrett wants to merge 3 commits into
wolfSSL:mainfrom
bigbrett:cached-shared-secret

Conversation

@bigbrett
Copy link
Copy Markdown
Contributor

@bigbrett bigbrett commented May 18, 2026

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.

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.
Copilot AI review requested due to automatic review settings May 18, 2026 20:55
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

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.

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 #372

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

No new issues found in the changed files. ✅

bigbrett added 2 commits May 18, 2026 14:24
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
@bigbrett bigbrett marked this pull request as ready for review May 19, 2026 05:47
@bigbrett bigbrett requested a review from rizlik May 19, 2026 05:48
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.

4 participants