Skip to content

Instantly share code, notes, and snippets.

@sipa
Last active October 13, 2015 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sipa/bd97f869dbe88f02a393 to your computer and use it in GitHub Desktop.
Save sipa/bd97f869dbe88f02a393 to your computer and use it in GitHub Desktop.
Differences between OpenSSL's ASN.1 parser and BER
  • Zero-length integers are accepted (with value 0), 8.3.1 says this is not allowed.
  • Expected-to-be-unsigned integers are parsed as if they weren't two's complement, violating 8.3.3.
  • Integers with excessive padding are accepted, violating 8.3.2.
  • Primitive values with indefinite length are accepted, when they are inside a constructed value with known length, violating 8.3.2.a. End-of-contents octets are not supported in this case, violating 8.1.5.
  • Lengths of constructed values are ignored in several cases.
  • Garbage inside sequences is accepted.
  • Garbage at the end is accepted.
  • Data types that are required to be primitive can be encoded as constructed instead, in which case the concatenation of all primitive values inside is used (ignoring their data types), violating for example 8.3.1.
  • 127-byte long length descriptors are accepted (ASN.1 allows up to 126 bytes), violating 8.1.3.5.c.
  • Older OpenSSL code only accepted length descriptors up to the size of a 'long int' (which is platform dependent), violating 8.1.3.5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment