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

doowon opened this issue May 10, 2019 · 3 comments

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

doowon opened this issue May 10, 2019 · 3 comments


Copy link

@doowon 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

What did you expect to see?

The ASN1 editor shows like the following pics.

What did you see instead?

They are not properly unmarshalled.

@andybons andybons added the NeedsInvestigation label May 13, 2019
@andybons andybons added this to the Unplanned milestone May 13, 2019
Copy link

@andybons andybons commented May 13, 2019


Copy link

@doowon 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.

Is it a bug or an intention?

Copy link

@thsnr 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:

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
None yet

No branches or pull requests

3 participants