This repository was archived by the owner on Jan 23, 2023. It is now read-only.
[release/2.1]: Fix compatibility issues vs NetFX in SignedCms and EnvelopedCms#30432
Merged
bartonjs merged 3 commits intodotnet:release/2.1from Jun 27, 2018
Merged
[release/2.1]: Fix compatibility issues vs NetFX in SignedCms and EnvelopedCms#30432bartonjs merged 3 commits intodotnet:release/2.1from
bartonjs merged 3 commits intodotnet:release/2.1from
Conversation
* Windows EnvelopedCms removes an outer BER tag and length when encrypting types other than id-data, match that on Unix. * When decrypting said data, wrap the response in a definite length SEQUENCE (which may change the tag) * Make the Windows version encrypt an indefinite length value when not id-data * Tests for all these things
* SignedCms with a content-type other than id-data should have attributes * Read classic PKCS7 SignedData(EnvelopedData) documents (NetFx compat) In NetFX if a SignedCms is created using only CmsSigners with IssuerAndSerial as the signer identifier type, the document gets encoded using the older PKCS7 structural definition instead of the newer CMS one. RFC 5652 has a long section (5.2.1) on how to read these documents compatibly. Since the defaults in SignedCms / CmsSigner are the PKCS7 behavior, not reading it means that Signed(Enveloped) documents from NetFX cannot be read.
Member
Author
|
@dotnet-bot test Outerloop Windows x64 Debug Build |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
NetFX and EnvelopedCms on Windows are both built on the same set of P/Invokes into Windows CryptMsg* APIs, and the EnvelopedCms recently added for Unix uses a new implementation. When the content type identifier for the payload is not
id-datathe two implementations encrypt different content. Windows removed the outer ASN/BER tag (and length) and encrypted only the payload bytes, reassembling the outgoing data by wrapping it in an ASN SEQUENCE. Unix/Managed wrote all of the bytes as-were. Both implementations therefore successfully read back what was written by their implementation, but neither implementation could read the content produced by the other. For this change, Unix EnvelopedCms has been changed to write content in the same manner as the existing Windows implementation and therefore to also be able to read that data.NetFX SignedCms is built on P/Invokes into Windows CryptMsg* APIs, but the CoreFx version is a new pure-managed implementation. When the content type identifier for a SignedCms payload is not
id-dataand the document was signed by a signer using a signer identifier type of IssuerAndSubjectName (the default) the NetFX version writes the content without a wrapping OCTET STRING, because that was what the pre-1999 PKCS7 specification said to do. The managed implementation could only read the post-1999 CMS format. This change enables the managed implementation of SignedCms to read older PKCS7-conforming documents, but continues to write using the CMS1999 rules (which are successfully read by NetFX).This is a port of #29926 (EnvelopedCms) and #30405 (SignedCms) to release/2.1.
Fixes #29825