Fix RSA_W_ENC verify guard in signature wrapper

The DigestInfo length extraction in wc_SignatureVerifyHash was compiled
only when WOLFSSL_RSA_PUBLIC_ONLY was not defined, but the block depends
on ASN.1 support, not on private key support. In a public only build the
RSA verify path stays reachable and wc_SignatureVerify still DER encodes
the digest, so the length check fell through to the plain digest size
comparison and rejected every valid signature with BAD_LENGTH_E. The
same guard also broke compilation with NO_ASN and RSA enabled, since
asn.h is not included in that case and GetSequence and GetOctetString
are undeclared.

Guard the block on NO_ASN instead, matching the DER encode call site in
wc_SignatureVerify.

Fixes F-7412.
This commit is contained in:
Tobias Frauenschläger
2026-08-07 08:11:23 +02:00
parent e260a8e103
commit 9533a8182a
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -336,5 +336,9 @@
{"name": "opensslextra-no-filesystem-no-bio", "minutes": 0.9,
"configure": ["--enable-opensslextra", "--disable-filesystem", "CPPFLAGS=-DNO_BIO"]},
{"name": "no-examples-no-malloc", "minutes": 0.8,
"configure": ["--disable-examples", "CPPFLAGS=-DWOLFSSL_NO_MALLOC"]}
"configure": ["--disable-examples", "CPPFLAGS=-DWOLFSSL_NO_MALLOC"]},
{"name": "cryptonly-no-asn-rsa", "minutes": 0.2, "check": false,
"comment": "RSA with ASN.1 disabled. Build only, since wolfcrypt test and benchmark do not support this combination.",
"configure": ["--enable-cryptonly", "--disable-asn", "--enable-lowresource",
"--disable-crypttests", "--disable-examples"]}
]
+1 -1
View File
@@ -203,7 +203,7 @@ int wc_SignatureVerifyHash(
return ret;
}
#if !defined(NO_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
#if !defined(NO_RSA) && !defined(NO_ASN)
/* For WC_SIGNATURE_TYPE_RSA_W_ENC, we need to extract the actual size of
* the ASN.1-encoded hash.
*/