Fix PKCS7 SignerIdentifier SKID to implicit [0] tagging#10937
Open
embhorn wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request corrects CMS/PKCS7 SignedData SignerIdentifier.subjectKeyIdentifier encoding to use implicit context-specific [0] tagging (per RFC 5652 IMPLICIT TAGS), improving interoperability with strict DER parsers (e.g., OpenSSL) while keeping decode compatibility with legacy explicit-form outputs.
Changes:
- Update
PKCS7_EncodeSigned()to emit SKID as implicit[0](context-specific primitive tag0x80) rather than an explicit wrapper. - Remove the now-unneeded inner OCTET STRING header fields/sizing from the
ESDencoding state. - Add regression tests to (a) assert implicit wire form + round-trip verify, and (b) verify decoding of a captured legacy explicit-form fixture.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| wolfcrypt/src/pkcs7.c | Switch SKID SignerIdentifier encoding to implicit [0] tagging and adjust size/write-out logic accordingly. |
| tests/api/test_pkcs7.h | Register two new PKCS7 SignedData regression tests in the test declarations list. |
| tests/api/test_pkcs7.c | Add encoding/decoding regression tests covering implicit SKID emission and legacy explicit SKID acceptance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Jenkins retest this please |
Member
Author
|
Pending customer review |
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.
Description
PKCS7_EncodeSigned emitted the SignedData SignerIdentifier subjectKeyIdentifier as an explicit [0] wrapper around an OCTET STRING (0xA0 len 0x04 len value). RFC 5652 defines the CMS module with IMPLICIT TAGS, so the [0] choice must use an implicit context tag that replaces the OCTET STRING tag (0x80 len value). Strict DER parsers such as OpenSSL reject the explicit form.
Encode with SetImplicit(ASN_OCTET_STRING, ...) and remove the now unused inner OCTET STRING header and its ESD struct members. The decoder already accepts both the explicit and implicit forms, so SignedData produced by earlier releases still verifies.
Fixes zd22160
Testing
Add a regression test asserting the implicit wire form and round-trip verify, plus a decode test that verifies a captured explicit-form fixture so the backward-compatible parse path stays covered.
Checklist