Skip to content

Skip the redundant signature verification for normal CAs. - #11892

Merged
philljj merged 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/ConfirmSelfSignature
Oct 29, 2026
Merged

philljj merged 1 commit into
wolfSSL:masterfrom
yosuke-wolfssl:fix/ConfirmSelfSignature

Conversation

@yosuke-wolfssl

@yosuke-wolfssl yosuke-wolfssl commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

PR #11334 introduced selfSigned and its verifier ConfirmSelfSignature.
It increased the memory usage for CA loads unconditionally.
The PR recognized the runtime cost only.

Fix

a CA_TYPE cert now skips ConfirmSelfSignature() only when its AKID is set and equals its SKID, and Key Usage allows keyCertSign.
Also, ProcessPeerCertParse() sets selfSigned on the small-cert path when the signature verified with the certificate's own key. wc_CheckCertSignature_ex() is added for the purpose.

Test

make check with --enable-all: pass.

Verification (peak heap)

Configs are the low_ecc and low_rsa2048 lines from nightly-memusage-v2,
plus --enable-trackmemory (prints peak Bytes on exit) and
--disable-shared:

# low_ecc
./configure --enable-singlethreaded --enable-lowresource --disable-sha512 \
  --disable-sha3 --disable-sha --disable-aescbc --enable-smallstack \
  --disable-tls13 --disable-eccshamir --disable-dh --disable-rsa \
  --enable-ecc --enable-curve25519 --disable-ed25519 \
  CFLAGS=-DSP_INT_BITS=256 C_EXTRA_FLAGS=-DFP_MAX_BITS=512 \
  --enable-trackmemory --disable-shared
# low_rsa2048
./configure --enable-singlethreaded --enable-lowresource --disable-sha512 \
  --disable-sha3 --disable-sha --disable-aescbc --enable-smallstack \
  --disable-tls13 --enable-dh --enable-rsa --disable-ecc \
  --disable-curve25519 --disable-ed25519 \
  CFLAGS=-DSP_INT_BITS=2048 C_EXTRA_FLAGS=-DFP_MAX_BITS=4096 \
  --enable-trackmemory --disable-shared
make examples/client/client examples/server/server

One mutual-auth TLS 1.2 handshake between examples/server/server and
examples/client/client; numbers are each process's peak Bytes (whole
process, CA load included). Repeated runs gave identical numbers.

  • ECC: server -c certs/server-ecc.pem -k certs/ecc-key.pem -A certs/client-ecc-cert.pem,
    client -A certs/ca-ecc-cert.pem -c certs/client-ecc-cert.pem -k certs/ecc-client-key.pem
  • RSA: default certs on both sides (DHE-RSA)
Peak bytes before (1625c65a1e) after
low_ecc client 10313 9123
low_ecc server 11241 9425
low_rsa2048 client 19895 17355
low_rsa2048 server 21513 21169

@yosuke-wolfssl yosuke-wolfssl self-assigned this Oct 26, 2026
Copilot AI balanced review requested due to automatic review settings October 26, 2026 01:48

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m0plus

  • FLASH: .text +68 B (+0.1%, 70,527 B / 262,144 B, total: 27% used)

gcc-arm-cortex-m3

  • FLASH: .text +48 B (+0.0%, 130,817 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .text +64 B (+0.1%, 73,079 B / 262,144 B, total: 28% used)

gcc-arm-cortex-m4-crypto-only

  • FLASH: .text +64 B (+0.0%, 179,859 B / 262,144 B, total: 69% used)

gcc-arm-cortex-m4-min-ecc

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

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +128 B (+0.0%, 793,564 B / 1,048,576 B, total: 76% used)

gcc-arm-cortex-m4-pkcs7

  • FLASH: .text +64 B (+0.0%, 220,884 B / 262,144 B, total: 84% used)

gcc-arm-cortex-m4-pq

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

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +64 B (+0.0%, 340,424 B / 1,048,576 B, total: 32% used)

gcc-arm-cortex-m4-sp-math

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

gcc-arm-cortex-m4-tls12

  • FLASH: .text +64 B (+0.0%, 131,601 B / 262,144 B, total: 50% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +64 B (+0.0%, 246,562 B / 262,144 B, total: 94% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +64 B (+0.0%, 309,968 B / 1,048,576 B, total: 30% used)

gcc-arm-cortex-m7-tls13

  • FLASH: .text +64 B (+0.0%, 246,562 B / 262,144 B, total: 94% used)

stm32-sim-stm32h753

  • FLASH: .text +128 B (+0.1%, 203,116 B / 2,097,152 B, total: 10% used)

zephyr-frdm_rw612

  • FLASH: rodata +100 B, text +256 B (+0.1%, 282,608 B / 67,108,864 B, total: 0% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@yosuke-wolfssl
yosuke-wolfssl force-pushed the fix/ConfirmSelfSignature branch from b64333d to b147ee5 Compare October 26, 2026 02:05
@yosuke-wolfssl yosuke-wolfssl changed the title Skip the full signature verification for normal CAs. Skip the redundant signature verification for normal CAs. Oct 26, 2026

@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 #11892

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

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

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

Review tier: Lite

Comment thread wolfcrypt/src/asn.c Outdated

@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 #11892

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Coverage: 1 of 3 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c, wolfssl/wolfcrypt/asn.h

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

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

Review tier: Lite

Comment thread src/ssl_certman.c Outdated

@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 #11892

Scan targets checked: wolfssl-src, wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c

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

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

Review tier: Lite

Comment thread src/ssl_certman.c Outdated

@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 for chasing down the memory cost from #11334. Skipping the self-signature check for AKID == SKID roots looks sound for the common case. A few comments: the VERIFY_NAME change sets selfSigned from a key that isn't guaranteed to be the one that verified the signature, the skip is a bit broader than the root case it targets, and the new tests don't exercise the changed path yet.

Comment thread wolfcrypt/src/asn.c Outdated
Comment thread wolfcrypt/src/asn.c Outdated
Comment thread src/ssl_certman.c Outdated
Comment thread tests/api.c
Comment thread tests/api.c

@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 #11892

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): doc/dox_comments/header_files/asn.h
Coverage: 5 of 5 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed stale reviews from themself October 27, 2026 02:42

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@yosuke-wolfssl

Copy link
Copy Markdown
Contributor Author

Hi @Frauschi ,
Thank you for reviewing. I addressed all issues you mentioned.

Frauschi
Frauschi previously approved these changes Oct 27, 2026

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

LGTM

@Frauschi Frauschi assigned wolfSSL-Bot and unassigned Frauschi Oct 27, 2026
@Frauschi
Frauschi requested a review from philljj October 27, 2026 15:09
@philljj philljj self-assigned this Oct 28, 2026
Comment thread tests/api.c
 - a CA_TYPE cert now skips ConfirmSelfSignature() only when its AKID is set and equals its SKID,
  and Key Usage allows keyCertSign
 - wc_CheckCertSignature_ex() reports the key of the CA that verified the signature;
  wc_CheckCertSignature() calls it without one.
 - CheckCertSignature_ex() in asn.c and asn_orig.c fills that key.
 - ProcessPeerCertParse() sets selfSigned on the small-cert path when
  the signature verified with the certificate's own key.
@philljj

philljj commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

tests good with multi-test with gcc-c89, c89-clang-tidy, wolfssl-all, asn-original, asn-template, smallstack, openssl-extra-coexist, etc scenarios.

@philljj
philljj merged commit ca357b7 into wolfSSL:master Oct 29, 2026
438 of 439 checks passed
@yosuke-wolfssl
yosuke-wolfssl deleted the fix/ConfirmSelfSignature branch October 29, 2026 04:28
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.

6 participants