Skip to content

Static analysis fixes#9795

Merged
dgarske merged 9 commits intowolfSSL:masterfrom
LinuxJedi:static-fixes2
Feb 18, 2026
Merged

Static analysis fixes#9795
dgarske merged 9 commits intowolfSSL:masterfrom
LinuxJedi:static-fixes2

Conversation

@LinuxJedi
Copy link
Member

@LinuxJedi LinuxJedi commented Feb 18, 2026

This includes

  • Fixes to size checking in QUIC
  • Fix SM4 TLS 1.3 decrypt auth tag and SM2 cert verification
    • Fix SM4 GCM/CCM TLS 1.3 decrypt to read auth tag from input buffer instead of output buffer
    • Fix SM4_BLOCK_SIZE typo (was SM$_BLOCK_SIZE) in TicketEncDec SM4-GCM decrypt path
    • Fix SM2 certificate signature verification for certs using id-ecPublicKey (ECDSAk) with SM2-with-SM3 signature algorithm.
    • Regenerate expired SM2 test certificates
  • Fix copy/paste error in SM4 CBC Decrypt Async
  • Add CI test for wolfSM + wolfSSL
  • Fix leak in Aria upon error
  • Fix wrong flags read on BIO write
  • Fix OCSP key-based responder ID lookup when SM2/SM3 is enabled

In `quic_record_transfer()`, the unsigned subtraction
`qr->end - qr->start` could wrap around if `end < start`, and the
subsequent `len <= 0` check was ineffective on a `word32`. Move the
comparison before the subtraction so the function returns `0` safely.

In `GetEchConfig()`, `XSTRLEN(config->publicName)` was assigned to a
single byte, silently truncating names longer than 255 characters while
`XMEMCPY` still copied the full string. Add a 255-byte length
validation in both `wolfSSL_CTX_GenerateEchConfig()` and
`GetEchConfig()`, and cache the length in a local variable to avoid
redundant `XSTRLEN` calls.
- Fix SM4 GCM/CCM TLS 1.3 decrypt to read auth tag from input buffer
  instead of output buffer, consistent with all other AEAD ciphers
  (src/tls13.c)

- Fix SM4_BLOCK_SIZE typo (was SM$_BLOCK_SIZE) in TicketEncDec SM4-GCM
  decrypt path (src/internal.c)

- Fix SM2 certificate signature verification for certs using
  id-ecPublicKey (ECDSAk) with SM2-with-SM3 signature algorithm.
  OpenSSL creates SM2 cert signatures without the standard
  distinguishing identifier in the ZA hash. The SM2k code path already
  handled this correctly (idSz=0), but the ECDSAk + CTC_SM3wSM2 path
  was incorrectly using CERT_SIG_ID_SZ (16), causing ASN_SIG_CONFIRM_E
  (-155) when verifying non-self-signed SM2 certs (wolfcrypt/src/asn.c)

- Regenerate expired SM2 test certificates via certs/sm2/gen-sm2-certs.sh
  They had expired.
When WOLFSSL_SM2 and WOLFSSL_SM3 are both defined, KEYID_SIZE becomes 32
(WC_SM3_DIGEST_SIZE) but OCSP_RESPONDER_ID_KEY_SZ remains 20 (SHA-1 per
RFC 6960). The guard (int)KEYID_SIZE == OCSP_RESPONDER_ID_KEY_SZ in
OcspFindSigner() and OcspRespIdMatch() evaluated to false (32 != 20),
completely disabling key-based OCSP responder ID matching. This caused
OCSP stapling to fail with BAD_CERTIFICATE_STATUS_ERROR (-406) against
any server using a key-based responder ID (e.g. login.live.com).

Fix by comparing only OCSP_RESPONDER_ID_KEY_SZ bytes for the responder
ID match, and zero-padding the 20-byte key hash to KEYID_SIZE before
passing to CA lookup functions that compare the full KEYID_SIZE.
OpenSSL 3.5+ handles the OIDs differently.
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

Awesome!

@dgarske dgarske merged commit eceb55e into wolfSSL:master Feb 18, 2026
574 of 576 checks passed
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

Comments