Skip to content

Reject empty PKCS11 ECDSA integers - #11339

Open
aidangarske wants to merge 3 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-12259
Open

Reject empty PKCS11 ECDSA integers#11339
aidangarske wants to merge 3 commits into
wolfSSL:masterfrom
aidangarske:fenrir-fixes-12259

Conversation

@aidangarske

Copy link
Copy Markdown
Member
F-12259

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.

Pull request overview

This PR hardens PKCS#11 ECDSA signature DER decoding in wc_pkcs11 by rejecting empty INTEGER encodings for r/s, preventing malformed signatures from progressing to PKCS#11 verify operations.

Changes:

  • Tighten Pkcs11ECDSASig_Decode() bounds checks and explicitly reject zero-length ASN.1 INTEGERs.
  • Add an API test that exercises empty-r and empty-s ECDSA signatures and asserts early ASN_PARSE_E without invoking C_VerifyInit.
  • Wire the new PKCS#11 API test into both Autotools and CMake test builds.

Reviewed changes

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

Show a summary per file
File Description
wolfcrypt/src/wc_pkcs11.c Adds explicit empty-INTEGER rejection and safer length/bounds validation during ECDSA DER signature decode.
tests/api/test_pkcs11.h Declares the new PKCS#11 API test and integrates it into the test case registry via TEST_DECL_GROUP.
tests/api/test_pkcs11.c Adds a targeted regression test covering empty r/s INTEGERs and ensuring no PKCS#11 verify calls occur.
tests/api/include.am Registers the new PKCS#11 API test source/header in the Autotools test build.
tests/api.c Includes the new test header and registers the PKCS#11 test group in the global API test list.
CMakeLists.txt Adds the new PKCS#11 API test source to the CMake test build inputs.

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

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #11339

Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src

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

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread tests/api.c
Comment thread tests/api/test_pkcs11.c
Comment thread tests/api/test_pkcs11.c
@aidangarske
aidangarske marked this pull request as ready for review September 1, 2026 17:30
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

retest this please

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m0plus

  • FLASH: .text +76 B (+0.1%, 66,959 B / 262,144 B, total: 26% used)

gcc-arm-cortex-m3

  • FLASH: .text +108 B (+0.1%, 125,775 B / 262,144 B, total: 48% used)

gcc-arm-cortex-m4

  • FLASH: .rodata.CSWTCH.1 +16 B, .rodata.str1.1 +158 B, .text +448 B (+0.3%, 204,957 B / 262,144 B, total: 78% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .text +64 B (+0.1%, 69,475 B / 262,144 B, total: 27% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .rodata.CSWTCH.1 +16 B, .rodata.str1.1 +158 B, .text +768 B (+0.5%, 178,904 B / 262,144 B, total: 68% used)

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +384 B (+0.2%, 186,620 B / 1,048,576 B, total: 18% used)

gcc-arm-cortex-m4-min-ecc

  • FLASH: .text +64 B (+0.1%, 64,325 B / 262,144 B, total: 25% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .rodata +104 B, .text +2,752 B (+0.4%, 783,204 B / 1,048,576 B, total: 75% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .rodata.CSWTCH.1 +16 B, .rodata.str1.1 +158 B, .text +192 B (+0.2%, 217,628 B / 262,144 B, total: 83% used)

gcc-arm-cortex-m4-pq

  • FLASH: .rodata +172 B, .text +448 B (+0.2%, 301,640 B / 1,048,576 B, total: 29% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .rodata +176 B, .text +832 B (+0.3%, 332,448 B / 1,048,576 B, total: 32% used)

gcc-arm-cortex-m4-sp-math

  • FLASH: .text +64 B (+0.1%, 64,325 B / 262,144 B, total: 25% used)

gcc-arm-cortex-m4-tls12

  • FLASH: .text +128 B (+0.1%, 126,579 B / 262,144 B, total: 48% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .rodata.CSWTCH.1 +16 B, .rodata.str1.1 +158 B, .text +320 B (+0.2%, 242,127 B / 262,144 B, total: 92% used)

gcc-arm-cortex-m7

  • FLASH: .rodata.CSWTCH.1 +16 B, .rodata.str1.1 +158 B, .text +448 B (+0.3%, 204,957 B / 262,144 B, total: 78% used)

gcc-arm-cortex-m7-pq

  • FLASH: .rodata +172 B, .text +448 B (+0.2%, 302,600 B / 1,048,576 B, total: 29% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .rodata.CSWTCH.1 +16 B, .rodata.str1.1 +158 B, .text +320 B (+0.2%, 242,191 B / 262,144 B, total: 92% used)

linuxkm-pie

  • Data: __patchable_function_entries +152 B (+0.6%, 27,000 B)

linuxkm-standard

  • Data: __patchable_function_entries +128 B (+0.3%, 49,792 B)

stm32-sim-stm32h753

  • FLASH: .text +372 B (+0.2%, 188,580 B / 2,097,152 B, total: 9% used)

@aidangarske

Copy link
Copy Markdown
Member Author

retest this please

@aidangarske

Copy link
Copy Markdown
Member Author

Jenkins retest this please
logs lost

@aidangarske aidangarske removed their assignment Sep 8, 2026
@aidangarske
aidangarske requested a review from philljj September 8, 2026 22:58
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