Skip to content

Tighten ECDH derive input checks and derived key state - #233

Open
aidangarske wants to merge 102 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-10396-1610
Open

aidangarske wants to merge 102 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-10396-1610

Conversation

@aidangarske

@aidangarske aidangarske commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

F-10396 - d904877 - C_DeriveKey ECDH now returns CKR_MECHANISM_PARAM_INVALID when shared data is supplied with CKD_NULL.

F-4272 - e879a0b - ECDH derive now rejects public data longer than 2 * MAX_ECC_BYTES + 4 and passes the length as word32.

F-1610 - 64809c7 - The raw point fallback in WP11_EC_Derive now resets its index and skips the DER length re-parse, so an unsupported DER length form is treated as a raw point.

F-5159 - 451c81e - ECDH derive now requires the encoded point length to fit in what remains of the supplied public data, returning BUFFER_E otherwise.

F-10383 - 800b60c - WP11_EC_Derive now clears the key's RNG association before freeing its stack RNG, and token keys take the key write lock for the whole derive.

F-6959 - a1f3613 - C_DeriveKey now calls CheckPrivateLogin after the CKA_DERIVE check, as C_GenerateKey does, so deriving a private key object requires a user login.

F-13818 - 0ff14c3 - C_DeriveKey now sets the initial states before AddObject and frees the object if AddObject fails.

F-13816 - 955c000 - New SetDerivedStates sets ALWAYS_SENSITIVE and NEVER_EXTRACTABLE on a derived key from the base key's history and its own SENSITIVE and EXTRACTABLE values.

F-3403 - 97ed5c1 - A SymmKeyLen failure in C_DeriveKey now returns CKR_FUNCTION_FAILED instead of a raw wolfCrypt error code.

@aidangarske aidangarske self-assigned this Oct 8, 2026
Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Several feature-gated tests incorrectly report PASS instead of SKIP, and the description omits substantial behavioral changes.

4 open findings
What changed in this PR

Hardens ECDH derivation and also introduces broader PKCS#11 state, persistence, login, and operation-lifecycle fixes.

Changes:

  • Validates ECDH inputs, derived-key state, locking, and login requirements.
  • Improves token storage, PIN state, operation cancellation, and mechanism metadata.
  • Adds extensive regression tests and CI configurations.
File Description
.github/​workflows/​unit-test.yml Adds TPM-debug and no-environment CI jobs.
src/​crypto.c Hardens derive and operation lifecycle behavior.
src/​internal.c Updates storage, locking, login, and session internals.
src/​slot.c Corrects token metadata, PIN handling, and mechanisms.
src/​wolfpkcs11.c Reports finalization failures and pads metadata.
tests/​ec_derive_test.c Adds ECDH regression coverage.
tests/​include.am Registers new test programs.
tests/​info_mech_table_test.c Tests metadata and mechanism consistency.
tests/​login_pin_state_test.c Tests login, PIN, and concurrency state.
tests/​object_policy_integrity_test.c Tests persisted object-policy integrity.
tests/​object_store_decode_test.c Tests malformed stored-object handling.
tests/​pkcs11mtt.c Updates v3 operation-cancellation expectations.
tests/​pkcs11test.c Updates clock and cancellation expectations.
tests/​session_op_lifecycle_test.c Tests operation cleanup and cancellation.
tests/​token_store_test.c Tests transactional token persistence.
wolfpkcs11/​internal.h Declares new limits and internal helpers.
wolfpkcs11/​pkcs11.h Adds the operation-cancellation error constant.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/ec_derive_test.c
Comment thread tests/object_policy_integrity_test.c Outdated
Comment thread tests/object_store_decode_test.c Outdated
Comment thread src/wolfpkcs11.c
@aidangarske
aidangarske force-pushed the fenrir-fixes-10396-1610 branch 3 times, most recently from 97ed5c1 to aafebc1 Compare October 10, 2026 03:20

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, one test request inline.

Comment thread src/internal.c
@aidangarske
aidangarske force-pushed the fenrir-fixes-10396-1610 branch from aafebc1 to a653795 Compare October 13, 2026 22:19
@aidangarske
aidangarske requested a review from Frauschi October 13, 2026 22:24
@aidangarske
aidangarske force-pushed the fenrir-fixes-10396-1610 branch from a653795 to 921c4f5 Compare October 13, 2026 22:45
@aidangarske
aidangarske force-pushed the fenrir-fixes-10396-1610 branch from 916da34 to 5beb906 Compare October 13, 2026 23:44
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.

3 participants