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

encoding/asn1: unmarshal of Context Specific into slice of RawValue #31954

Open
doowon opened this issue May 10, 2019 · 3 comments
Open

encoding/asn1: unmarshal of Context Specific into slice of RawValue #31954

doowon opened this issue May 10, 2019 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@doowon
Copy link

doowon commented May 10, 2019

What version of Go are you using (go version)?

go version go1.12.5 windows/amd64

Does this issue reproduce with the latest release?

My Go version is the latest version.

What operating system and processor architecture are you using (go env)?

go env Output
set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

I tried to ASN.1 unmarshal UnauthenticatedAttributes of a PKCS #7 SignedData. But the Unmarshal() does not properly unmarshal (only two of the total of three are unmarshalled) and returns the rest as a return value. However, other asn1 editor or viewers or OpenSSL properly unmarshal and show the result.

My code is available at https://play.golang.org/p/2W2xBUjbpqO

What did you expect to see?

The ASN1 editor shows like the following pics.
https://imgur.com/vfiSt3Q
https://imgur.com/OhjLlsY

What did you see instead?

They are not properly unmarshalled.

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 13, 2019
@andybons andybons added this to the Unplanned milestone May 13, 2019
@andybons
Copy link
Member

@FiloSottile

@doowon
Copy link
Author

doowon commented May 16, 2019

I found myself (+ help from @thsnr). I need to iterate unmarshal until the rest becomes 0.

Here is the example presented by @thsnr.
https://play.golang.org/p/heggS9bD85K

Is it a bug or an intention?

@thsnr
Copy link

thsnr commented May 17, 2019

@doowon you asked me how we worked around #17321. As I said, it was fixed in Go 1.10 and the linked workaround is only necessary up to Go 1.9.

Your example is faulty because you are trying to unmarshal a SET into a single RawValue and not telling the asn1 package about the implicit 0 tag. Here is a fixed version of the same playground:

https://play.golang.org/p/tYJOCZeIQZd

If you want to unmarshal the entire SignerInfo (not SignedData) element in a single call, then set the params as an asn1 field tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants