Skip to content

Static code analysis fixes#178

Open
LinuxJedi wants to merge 9 commits intowolfSSL:masterfrom
LinuxJedi:f-fixes7
Open

Static code analysis fixes#178
LinuxJedi wants to merge 9 commits intowolfSSL:masterfrom
LinuxJedi:f-fixes7

Conversation

@LinuxJedi
Copy link
Copy Markdown
Member

Mostly fixes to missing flags or incorrect return codes. Also an endianness fix.

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 addresses several static-analysis findings and PKCS#11 conformance issues by correcting return codes, recording key-generation metadata (CKA_LOCAL / CKA_KEY_GEN_MECHANISM), and adding regression tests (plus an HKDF length-cast fix).

Changes:

  • Fix PIN length handling to return CKR_PIN_LEN_RANGE and update tests accordingly.
  • Track locally-generated keys and key generation mechanisms for C_GenerateKey (including PBKDF2/PBE and random symmetric generation) and set derived sensitivity/extractability attributes.
  • Add new tests validating CKA_LOCAL / CKA_KEY_GEN_MECHANISM for AES and PBKDF2 key generation; adjust HKDF CKA_VALUE_LEN read to use CK_ULONG.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
wolfpkcs11/internal.h Adds internal helper prototype and updates random-key generator signature to include mechanism.
src/internal.c Implements helper to mark objects as locally generated and store key-gen mechanism; updates random key generation.
src/crypto.c Updates digest return handling, verify-recover attribute check, key generation metadata/attrs, and HKDF length casting.
src/slot.c Returns CKR_PIN_LEN_RANGE for invalid PIN lengths; propagates that return through token/PIN APIs.
tests/pkcs11test.c Updates expected error codes for too-short/too-long PIN test cases.
tests/include.am Adds new AES and PBKDF2 keygen attribute tests to the build.
tests/aes_keygen_attrs_test.c New regression test for CKA_LOCAL / CKA_KEY_GEN_MECHANISM on AES key generation.
tests/pbkdf2_keygen_attrs_test.c New regression test for CKA_LOCAL / CKA_KEY_GEN_MECHANISM and sensitivity/extractability-derived attributes on PBKDF2 keygen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/crypto.c
Comment thread src/crypto.c
Comment thread src/crypto.c
Comment thread src/crypto.c Outdated
Comment thread src/crypto.c Outdated
Comment thread src/crypto.c Outdated
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 #178

Scan targets checked: wolfpkcs11-bugs, wolfpkcs11-compliance, wolfpkcs11-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/crypto.c
Copilot AI review requested due to automatic review settings April 7, 2026 14:46
@LinuxJedi
Copy link
Copy Markdown
Member Author

ML-DSA tests will fail until #175 or #176 is merged.

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/crypto.c
Comment thread src/crypto.c Outdated
Comment thread src/crypto.c
Comment thread src/crypto.c
Comment thread src/slot.c
Copilot AI review requested due to automatic review settings April 16, 2026 13:28
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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/crypto.c Outdated
Comment thread src/crypto.c Outdated
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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/internal.c
Comment thread src/internal.c
Comment thread tests/pkcs11mtt.c
Comment thread tests/pkcs11mtt.c
Comment thread tests/pkcs11mtt.c
Comment thread tests/pkcs11mtt.c
Comment thread tests/aes_keygen_attrs_test.c
Comment thread tests/pbkdf2_keygen_attrs_test.c
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