Skip to content

Make key material and certificate values fixed after creation - #236

Open
aidangarske wants to merge 144 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-11500-11501
Open

aidangarske wants to merge 144 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-11500-11501

Conversation

@aidangarske

@aidangarske aidangarske commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

F-11500 - 34a2a43 - SetAttributeValue now returns CKR_ATTRIBUTE_READ_ONLY for key component and certificate CKA_VALUE changes on existing objects, covering C_SetAttributeValue and C_CopyObject.

F-10387 - c0a668d - WP11_Object_SetSecretKey now validates the new key into a local length before zeroizing and replacing the existing key.

F-10399 - de79c8c - WP11_Object_SetDhKey now clears the whole fixed key buffer before storing a private value.

F-11515 - f9ce527 - RSA and EC private components cannot be replaced on an existing object, which the read-only key component policy already enforces; this commit changes no library code.

F-13815 - b7dc62d - WP11_Object_SetEcKey now rejects an EC private value or point when no curve is set.

F-5158 - 4195e7a - WP11_Object_SetRsaKey now rejects a CKA_MODULUS_BITS value above RSA_MAX_SIZE instead of narrowing it.

F-12458 - 89ecb2c - WP11_Object_SetCert no longer resets the certificate length on entry, and CKA_CERTIFICATE_TYPE is read-only once the object exists, though restating the same value is allowed.

F-4528 - 96f5ab4 - WP11_Object_SetCert now allocates and copies the new certificate value before freeing the old one, and sets the length only on success.

F-11501 - ec82128 - SetCert now clears keyData when it aliases the certificate data, and WP11_Object_Copy rejects certificate and trust objects.

F-4318 - 7b777a2 - WP11_Object_SetDhKey now rejects CKA_PRIME or CKA_BASE longer than WP11_MAX_DH_KEY_SZ before calling wc_DhSetKey.

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

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

The stored-object security test can miss secrets released by realloc, and its unavailable-feature path is incorrectly reported as passing.

2 open findings
What changed in this PR

Hardens key/certificate immutability, token persistence, session lifecycle, validation, and PKCS#11 metadata behavior.

Changes:

  • Makes key material and certificate values read-only after creation.
  • Improves persistence failure handling and stored-object validation.
  • Expands tests across attributes, login state, mechanisms, and storage.
File Description
wolfpkcs11/​pkcs11.h Adds operation-cancellation status.
wolfpkcs11/​internal.h Adds limits and internal helpers.
tests/​token_store_test.c Tests persistence failure recovery.
tests/​pkcs11v3test.c Updates immutable-key expectations.
tests/​pkcs11test.c Updates copying and cancellation tests.
tests/​pkcs11mtt.c Updates multithreaded cancellation tests.
tests/​object_store_decode_test.c Tests corrupted storage handling.
tests/​login_pin_state_test.c Tests login and PIN invariants.
tests/​key_material_update_test.c Tests immutable key material.
tests/​info_mech_table_test.c Validates metadata and mechanisms.
tests/​include.am Registers new tests.
tests/​attribute_validation_test.c Expands attribute validation coverage.
src/​wolfpkcs11.c Improves finalization and metadata output.
src/​slot.c Corrects token information and mechanisms.
.github/​workflows/​unit-test.yml Adds TPM and no-environment jobs.

🧠 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/object_store_decode_test.c
Comment thread tests/object_store_decode_test.c Outdated
@aidangarske
aidangarske force-pushed the fenrir-fixes-11500-11501 branch 3 times, most recently from 7b777a2 to aad61a3 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.

Two comments, inline.

Comment thread src/internal.c
Comment thread tests/key_material_update_test.c
@aidangarske
aidangarske force-pushed the fenrir-fixes-11500-11501 branch from aad61a3 to dfb20cb 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-11500-11501 branch 2 times, most recently from 4c60ed7 to 62ea00b Compare October 13, 2026 22:49
@aidangarske
aidangarske force-pushed the fenrir-fixes-11500-11501 branch from d05e5f2 to 03bef3f Compare October 13, 2026 23:45

@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.

Thanks, the error mapping and the test changes look good. The msys-static failure is a package mirror 429 and just needs a rerun.

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