-
Notifications
You must be signed in to change notification settings - Fork 18k
x/crypto/cryptobyte: cannot read boolean values #26565
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
Comments
CC: @FiloSottile |
Hi, I'm using the cryptobyte library and I stumbled upon this, too What version of Go are you using? $ go version go1.11.5 darwin/amd64 Does this issue reproduce with the latest release? What did you do? I can't provide a playground example, so I'll just copy paste it here
I also agree with the last point by szank. Both fixes should be trivial and I'd be happy to contribute. |
According to ITU-T X.690:
So the problem for ReadASN1Boolean seems to be just the wrong tag, like said previously. Added a pull request for fixing this: golang/crypto#137. |
Fixed by golang.org/cl/233161. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.3 darwin/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
I tried to decode a boolean asn.1 value using the cryptobyte package.
Boolean "True" value encoded using the stdlib asn.1 encoder is
0x0101FF
tag 0x01 - boolean valuelength 0x01 - 1 byte and the value 0xff - 0x00 is false, everything else if true.
When decoding the value using the cryptobyte package I have encountered some issues.
Using
ReadASN1Boolean
- it expects tag 0x02 - Integer instead of tag 0x01 - Boolean, so it returns false when reading 0x0101FF valueUsing
ReadOptionalASN1Boolean
- it correctly expects 0x01 tag, and reads the value into a child cryptobyte string (that would contain x0FF bytes in my case), then in case the value exists, proceeds to read the remainder of the input which is not correct, it should examine the value read into the child cryptobyte string and return without advancing further.Both bugs are trivial to fix and I am happy to submit a patch.
The text was updated successfully, but these errors were encountered: