Repository navigation
Report token store failures and keep stored state consistent - #232
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A failed user-PIN change can leave committed object records encrypted under a discarded key, making them unreadable after restart.
3 open findings
What changed in this PR
Hardens token persistence, lifecycle cleanup, stored-object validation, and PKCS#11 operation handling.
Changes:
- Propagates storage failures and improves rollback/cleanup behavior.
- Strengthens stored-object decoding, policy integrity, and session lifecycle handling.
- Adds targeted tests and a no-environment CI configuration.
| File | Description |
|---|---|
.github/workflows/unit-test.yml |
Adds no-environment CI coverage. |
src/crypto.c |
Improves operation cleanup and object failure handling. |
src/internal.c |
Implements persistence, rollback, loading, and lifecycle changes. |
src/slot.c |
Corrects token information and mechanism metadata. |
src/wolfpkcs11.c |
Propagates finalization errors and pads information fields. |
tests/include.am |
Registers the new test programs. |
tests/info_mech_table_test.c |
Tests information and mechanism contracts. |
tests/login_pin_state_test.c |
Tests PIN, login, and concurrency invariants. |
tests/object_policy_integrity_test.c |
Tests persisted key-policy integrity. |
tests/object_store_decode_test.c |
Tests malformed stored-record handling. |
tests/pkcs11mtt.c |
Updates PKCS#11 v3 cancellation expectations. |
tests/pkcs11test.c |
Updates clock and cancellation tests. |
tests/session_op_lifecycle_test.c |
Tests operation cleanup and cancellation. |
tests/token_store_test.c |
Tests storage failures and recovery. |
wolfpkcs11/internal.h |
Adds internal limits and lifecycle APIs. |
wolfpkcs11/pkcs11.h |
Defines the cancellation failure result code. |
🧠 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-10378-10379
branch
2 times, most recently
from
October 10, 2026 03:20
2711d6d to
ea58fe1
Compare
Frauschi
reviewed
Oct 13, 2026
aidangarske
force-pushed
the
fenrir-fixes-10378-10379
branch
from
October 13, 2026 22:19
ea58fe1 to
eafe9ba
Compare
aidangarske
force-pushed
the
fenrir-fixes-10378-10379
branch
3 times, most recently
from
October 13, 2026 23:43
03f5514 to
036219e
Compare
Frauschi
previously approved these changes
Oct 14, 2026
aidangarske
force-pushed
the
fenrir-fixes-10378-10379
branch
from
October 15, 2026 16:12
636fe06 to
b977085
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-10378-10379
branch
from
October 15, 2026 21:00
456266a to
cc1d926
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-10378- 325fa7a - wolfPKCS11_Store_Name now declares its string unconditionally and guards the HOME and APPDIR lookup with WOLFPKCS11_NO_ENV, and a no_env CI job is added.F-10379- 5d0def0 - wp11_Token_Store no longer changes the token object count on a failed store or turns a TPM NV_SPACE error into success, and C_DeriveKey frees the derived object when AddObject fails.F-10386- b0ed4a4 - Store commit failures are now reported: a new wolfPKCS11_Store_CloseCommit returns rename and close errors and discards a failed write, and the user PIN, SO PIN and token reset paths restore their previous state when the store fails.F-10384- 617f7b4 - For the file backend, wp11_Token_Store no longer replaces the token record with an empty temporary file before the objects are written.F-11505- c79ea02 - WP11_Library_Final now returns the first slot store error after finishing cleanup, and C_Finalize maps it to CKR_FUNCTION_FAILED.F-8645- 5bb3614 - WP11_Library_Init now tracks the global lock, wolfCrypt, the global RNG and initialized slots and unwinds them when initialization fails.F-10385- 844537c - wp11_Object_New now frees only a non-NULL object, and WP11_Object_Free(NULL) does nothing.F-13243- fe5d444 - Destroying a token object now reports the first unstore error, ignoring NOT_AVAILABLE_E, and the file backend treats a missing file as success on remove.F-2791- ca3304f - wp11_Token_Final now clears the token with wc_ForceZero instead of XMEMSET.F-11502- 97b89ab - wp11_Token_Load now reads nextObjId only when the token flags read succeeded, and falls back only on BUFFER_E or a successful read of 0, so other errors fail the load.F-10380- 2711d6d - The TPM store now sizes ML-DSA, ML-KEM, HSS and XMSS records, and the handle type mask is widened from 0x0F to 0x1F so these types get distinct handles. Existing handles below 0x10 are unchanged.