Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASN1 corrupted data when using EnvelopedCms to decrypt on Debian Stretch #26000

Closed
samdearden opened this issue Apr 26, 2018 · 7 comments
Closed

Comments

@samdearden
Copy link

I am using EnvelopedCms in the 2.1 preview 2 to decrypt a file that was encrypted using BouncyCastle.

Using EnvelopedCms to decode & decrypt the file under Windows works without error.

Running the same code under Debian stretch (microsoft/dotnet:2.1.300-preview2-sdk-stretch docker image) on the call to EnvelopedCms.Decode I get the following error:

System.Security.Cryptography.CryptographicException: Unable to set field EncryptedContentInfo on type System.Security.Cryptography.Pkcs.Asn1.EnvelopedDataAsn. ---> System.Security.Cryptography.CryptographicException: Unable to set field EncryptedContent on type System.Security.Cryptography.Pkcs.Asn1.EncryptedContentInfoAsn. ---> System.Security.Cryptography.CryptographicException: ASN1 corrupted data.

I have attached the encrypted data and the full stack trace.

encrypted.zip
stack trace.txt

@karelz
Copy link
Member

karelz commented Apr 26, 2018

@bartonjs is that new code in 2.1?

@bartonjs
Copy link
Member

@karelz Yep, in 2.0 and prior it would have been PlatformNotSupportedException

@bartonjs
Copy link
Member

Looks like a deserializer problem reading implicitly tagged indefinite length octet strings (missed passing expectedTag). Easy fix, I'll have a PR up in a bit.

@bartonjs
Copy link
Member

   at System.Security.Cryptography.Asn1.AsnReader.TryCopyOctetStringBytes(Asn1Tag expectedTag, Span`1 destination, Int32& bytesWritten)
   at System.Security.Cryptography.Asn1.AsnSerializer.<>c__DisplayClass21_0.<GetSimpleDeserializer>b__6(AsnReader reader)

This is a misleading callstack, since it misses the inlined call to the overload that didn't take expectedTag :).

@bartonjs
Copy link
Member

@samdearden Do you mind if I use your file for a compat test going forward?

@samdearden
Copy link
Author

@bartonjs Go ahead, its just a test file.

@bartonjs
Copy link
Member

This is fixed in master, and the fixed has merged into the release branch for the post-RC1 build.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants