Topic: Certificate decode error during TLS handshake
The main problem is when decoding a certificate during TLS handshake.
Received certificate:
https://lapo.it/asn1js/#308203C93082036 … A9D5721F92
you can see parameter called keyUsage, but when it's decoded by wolfCrypt in function CheckBitString is a premise that the lowest bit of value have to be 1. I don't know why. The certificate is ok but wolfCrypt can't parse it.
input = 03 02 05 80
static int CheckBitString(const byte* input, word32* inOutIdx, int* len,
word32 maxIdx, int zeroBits, byte* unusedBits)
{
...
if (b >= 0x08)
return ASN_PARSE_E;
if (b != 0) { // b = 5
if ((byte)(input[idx + length - 1] << (8 - b)) != 0)
return ASN_PARSE_E;
if (((input[idx + length - 1] >> b) & 0x01) != 0x01) /// PROBLEM!!!!!! input[idx + length - 1] = 0x80, (0x80 >> 5 & 1) == 0!!
return ASN_PARSE_E;
}
...
return 0;
}