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

Re-evaluate OCTET STRING equality #203

Closed
JesusMcCloud opened this issue Nov 22, 2024 · 2 comments
Closed

Re-evaluate OCTET STRING equality #203

JesusMcCloud opened this issue Nov 22, 2024 · 2 comments
Assignees

Comments

@JesusMcCloud
Copy link
Collaborator

Assigning you guys too, so we can discuss this here.

Currently, we have two kinds of octet strings, because octet strings are frequently used to encode structures:

  • Asn1PrimitiveOctetString is a primitive, containing unstructured data
  • Asn1EncapsulatingOctetString is an ASN.1 structure with SEQUENCE semantics

When parsing ASN.1 bytes, we try to recursively decode octet strings into structures. If this works, we have an encapsulating variant, if this fails, we have have a primitive octet string. Now it is really not that unusual for a small (<20 bytes) octet string containing supposedly unstructured data, to accidentally contain a valid ASN.1 structure. Another was to reliably trigger this, is to SEC1-encode and decode few hundred P521 private keys. At least one of them is bound to contain an encapsulating octet string and some other foo as private key.

This parsing logic is fine and there is no other way to do it. All ASN.1 parsers inherently have to behave like this. The issue is equality. In #202, I added a conversion function Asn1EncapsulatingOctetString.toPrimitive(), which will make an encapsulating octet string into a primitive one.

  • Do we need more?
  • Should the two kinds of octet strings be considered equal or not?
@JesusMcCloud
Copy link
Collaborator Author

@iaik-jheher this can be closed, right?!

@iaik-jheher
Copy link
Collaborator

should be fixed after #202, yeah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants