Skip to content

x/crypto/cryptobyte: cannot read boolean values #26565

Description

@szank

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 value
length 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.

  1. Using ReadASN1Boolean - it expects tag 0x02 - Integer instead of tag 0x01 - Boolean, so it returns false when reading 0x0101FF value

  2. Using 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions