Skip to content

asn: verify KeyPurposeId OID bytes before setting extended key usage bits - #11205

Open
gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:eku-oid-checksum-fix
Open

asn: verify KeyPurposeId OID bytes before setting extended key usage bits#11205
gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:eku-oid-checksum-fix

Conversation

@gasbytes

Copy link
Copy Markdown
Contributor

Description

Verify a KeyPurposeId's OID bytes before mapping its wc_oid_sum() to an extended key usage bit.

Fixes zd#22337

Testing

Added a regression test that tests the behaviour with an actual id-kp-serverAuth as oid and one that must collide and check that it still doesn't allow server authentication.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@gasbytes gasbytes self-assigned this Aug 19, 2026
Copilot AI lite review requested due to automatic review settings August 19, 2026 14:23

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

Improves EKU (Extended Key Usage) decoding safety by ensuring a KeyPurposeId’s raw OID bytes match the known OID associated with its wc_oid_sum() before mapping it to an authorization bit (preventing checksum-collision misclassification, e.g., falsely granting serverAuth).

Changes:

  • Hardened DecodeExtKeyUsage() to validate OID bytes against the known OID before setting EKU bits.
  • Added regression coverage (whitebox + API-level) for an OID checksum collision against id-kp-serverAuth.
  • Registered the new API test in the ASN test suite header.

Reviewed changes

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

File Description
wolfcrypt/src/asn.c Adds OID-byte verification to prevent wc_oid_sum() collision from setting the wrong EKU bit.
tests/unit-mcdc/test_asn_ext_whitebox.c Adds a whitebox regression case for a colliding OID not being treated as serverAuth.
tests/api/test_asn.h Registers the new API regression test function in the ASN test list.
tests/api/test_asn.c Adds an API-level regression test generating/parsing certs to validate EKU collision handling.

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

Comment thread tests/unit-mcdc/test_asn_ext_whitebox.c
Comment thread tests/api/test_asn.c
@gasbytes
gasbytes force-pushed the eku-oid-checksum-fix branch from d79d27a to 369a439 Compare August 19, 2026 14:36
@gasbytes
gasbytes marked this pull request as ready for review August 19, 2026 14:44
@github-actions

Copy link
Copy Markdown

retest this please

@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m0plus

  • FLASH: .text +36 B (+0.1%, 65,027 B / 262,144 B, total: 25% used)

gcc-arm-cortex-m3

  • FLASH: .text +28 B (+0.0%, 123,839 B / 262,144 B, total: 47% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .text +64 B (+0.1%, 67,619 B / 262,144 B, total: 26% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .text +64 B (+0.0%, 176,170 B / 262,144 B, total: 67% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +64 B (+0.0%, 215,022 B / 262,144 B, total: 82% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +64 B (+0.0%, 328,432 B / 1,048,576 B, total: 31% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +64 B (+0.0%, 238,753 B / 262,144 B, total: 91% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +64 B (+0.0%, 298,908 B / 1,048,576 B, total: 29% used)

stm32-sim-stm32h753

@gasbytes gasbytes assigned anhu and wolfSSL-Bot and unassigned gasbytes Aug 19, 2026
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