Repository navigation
Validate KDF and TLS derive parameters and derived key state - #234
Open
aidangarske wants to merge 104 commits into
Open
aidangarske wants to merge 104 commits into
aidangarske wants to merge 104 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
TLS multi-key derivation can bypass the new oversized CKA_VALUE_LEN validation, and several unavailable test configurations incorrectly report success.
4 open findings
What changed in this PR
Hardens PKCS#11 derivation, persistence, session lifecycle, and metadata behavior while expanding regression coverage.
Changes:
- Validates KDF, DH, AES-CBC, and TLS derivation parameters and derived-key state.
- Improves token persistence, login state, operation cleanup, and mechanism reporting.
- Adds extensive derive, storage, concurrency, and lifecycle tests.
| File | Description |
|---|---|
.github/workflows/unit-test.yml |
Adds TPM-debug and no-environment CI coverage. |
wolfpkcs11/pkcs11.h |
Defines operation-cancellation failure status. |
wolfpkcs11/internal.h |
Adds size limits and internal lifecycle helpers. |
src/crypto.c |
Hardens derivation and operation lifecycle handling. |
src/internal.c |
Implements storage, session, and derive safeguards. |
src/slot.c |
Corrects token information and mechanism reporting. |
src/wolfpkcs11.c |
Improves initialization, finalization, and field padding. |
tests/include.am |
Registers the new test executables. |
tests/pkcs11test.c |
Updates expectations for corrected behavior. |
tests/pkcs11mtt.c |
Updates multithreaded cancellation expectations. |
tests/ec_derive_test.c |
Tests ECDH validation and derived state. |
tests/kdf_tls_derive_test.c |
Tests KDF and TLS derivation behavior. |
tests/token_store_test.c |
Tests transactional token persistence. |
tests/object_store_decode_test.c |
Tests malformed stored-object rejection. |
tests/login_pin_state_test.c |
Tests login, PIN, and concurrency invariants. |
tests/info_mech_table_test.c |
Tests metadata and mechanism consistency. |
tests/object_policy_integrity_test.c |
Tests persisted object policy integrity. |
tests/session_op_lifecycle_test.c |
Tests operation cleanup and cancellation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
aidangarske
force-pushed
the
fenrir-fixes-4687-4804
branch
3 times, most recently
from
October 10, 2026 03:20
32108ba to
28c52a6
Compare
Frauschi
reviewed
Oct 13, 2026
Frauschi
left a comment
Member
There was a problem hiding this comment.
One comment on the DH padding, inline.
aidangarske
force-pushed
the
fenrir-fixes-4687-4804
branch
from
October 13, 2026 22:19
28c52a6 to
f14e59f
Compare
aidangarske
force-pushed
the
fenrir-fixes-4687-4804
branch
3 times, most recently
from
October 13, 2026 23:44
1b4da5a to
b359492
Compare
Frauschi
previously approved these changes
Oct 14, 2026
Frauschi
left a comment
Member
There was a problem hiding this comment.
Thanks, the DH padding fix and the stripped-peer test look good.
aidangarske
force-pushed
the
fenrir-fixes-4687-4804
branch
2 times, most recently
from
October 15, 2026 16:51
366a776 to
54a995c
Compare
Frauschi
previously approved these changes
Oct 15, 2026
aidangarske
dismissed
Frauschi’s stale review
October 15, 2026 20:36
The merge-base changed after approval.
aidangarske
force-pushed
the
fenrir-fixes-4687-4804
branch
from
October 15, 2026 21:01
54a995c to
147e5a2
Compare
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.


F-4687- 10d946f - WP11_KDF_Derive now rejects HKDF salt and info lengths that do not fit in 32 bits.F-4804- 00a5d9c - The NSS extended master secret derive now rejects a session hash length that does not fit in 32 bits.F-4274- 58bd287 - CKM_DH_PKCS_DERIVE now rejects a peer public value longer than WP11_MAX_DH_KEY_SZ, and the macro moves to wolfpkcs11/internal.h.F-5077- 837ca4c - CKM_AES_CBC_ENCRYPT_DATA now rejects a data length that does not fit in 32 bits.F-10389- 37fdc66 - CKM_TLS12_KEY_AND_MAC_DERIVE now requires each MAC, key and IV size to be a multiple of 8 bits.F-10381- 9723108 - A single WP11_DERIVE_SECRET_KEY macro now guards the C_DeriveKey locals and helpers for ECC, DH, HKDF, AES-CBC and PRF.F-11518- a12c83b - TLS key and MAC derive now requires non-NULL client and server randoms, and the NSS extended master secret derive requires a non-NULL session hash.F-4066- 686b6aa - CKM_TLS12_MASTER_KEY_DERIVE now returns CKR_MECHANISM_PARAM_INVALID for any version other than 3.3.F-13245- 799862c - C_DeriveKey now returns CKR_ATTRIBUTE_VALUE_INVALID when CKA_VALUE_LEN is larger than the derived secret, and DH secrets are left padded up to the smaller of the parameter length and the prime length.F-3636- c834de9 - TLS key material keys now take their ALWAYS_SENSITIVE and NEVER_EXTRACTABLE history from the base key through SetDerivedStates.F-4074- d43a3c7 - SetKeyExtract now sets the MAC attributes before AddObject, frees the object on failure, and maps a SymmKeyLen failure to CKR_FUNCTION_FAILED.F-8644- 32108ba - WP11_KDF_Derive now requires the HKDF salt key to be a generic secret, AES or HKDF secret key with key data, and C_DeriveKey passes CKR_MECHANISM_PARAM_INVALID through.