Fix PKCS7 streamed SignedData dropping content#10904
Merged
Frauschi merged 1 commit intoJul 15, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a logic error in PKCS7 streamed SignedData encoding where wc_PKCS7_EncodeContentStreamHelper() could leave ret as BAD_FUNC_ARG in the WC_CIPHER_NONE path when the content digest was precomputed (or when esd is NULL), preventing the eContent bytes from being written despite overall encoding succeeding.
Changes:
- Ensure
wc_PKCS7_EncodeContentStreamHelper()returns success (ret = 0) forWC_CIPHER_NONEwhen no hashing update is needed (contentDigestSet == 1) or whenesdis not provided. - As a result, the
if (ret == 0)block that emits the OCTET STRING header and content now runs correctly in these cases.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
aidangarske
force-pushed
the
fix/pkcs7-stream-signed-content
branch
from
July 14, 2026 23:49
72a5c50 to
9b1aad4
Compare
Contributor
|
Jenkins retest this please |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wc_PKCS7_EncodeContentStreamHelper()initializesrettoBAD_FUNC_ARGand, in theWC_CIPHER_NONEcase, only assigns it insideif (esd->contentDigestSet != 1). When the caller passes a precomputed hash towc_PKCS7_EncodeSignedData_ex(),contentDigestSetis 1, so that branch is skipped,retkeepsBAD_FUNC_ARG, and theif (ret == 0)block that writes the content never runs.PKCS7_EncodeSigned()does not check the return value, so encoding reports success while emitting a bundle with an empty eContent.Found with
wolfssl-examplespkcs7/signedData-stream, which failed verification withASN_PARSE_E (-140). OpenSSL rejected the same bundle withCMS Verification failure, confirming the bundle was malformed rather than wolfSSL being strict.With the fix the bundle grows by the 32 bytes that were missing (2 byte OCTET STRING header plus 30 bytes of content), and it verifies with both wolfSSL and
openssl cms -verify.testwolfcryptandtests/unit.testpass.