igrr / axtls-8266

axTLS port for ESP8266
Other
79 stars 33 forks source link

FIX: asn1: parsing of bit string for key usage #59

Closed jonnykl closed 5 years ago

jonnykl commented 6 years ago

To see what does not work load a certificate with this library and dump it. Then do this with openssl x509 -in cert.der -inform der -noout -text and compare the key usage fields!

The parsing algorithm for bit strings was not correct:

  1. The offset wasn't correct at the end of the function (one too low)
  2. Bit strings are encoded in big endian byte order, not little endian.
  3. The most significant bit of the bit string as number (taking into account of the bit string length) has to be the least significant bit of the key usage value (see https://security.stackexchange.com/a/10396)

No. 1 didn't produce following errors because the rest of the outer ASN.1 sequence is skipped after calling this function (asn1_get_bit_string_as_int).