mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
Decode the key usage extension as LE not BE
This commit is contained in:
@ -19247,14 +19247,24 @@ static int DecodeKeyUsage(const byte* input, word32 sz, DecodedCert* cert)
|
|||||||
#else
|
#else
|
||||||
ASNGetData dataASN[keyUsageASN_Length];
|
ASNGetData dataASN[keyUsageASN_Length];
|
||||||
word32 idx = 0;
|
word32 idx = 0;
|
||||||
|
byte keyUsage[OPAQUE16_LEN];
|
||||||
|
word32 keyUsageSz = sizeof(keyUsage);
|
||||||
|
int ret;
|
||||||
WOLFSSL_ENTER("DecodeKeyUsage");
|
WOLFSSL_ENTER("DecodeKeyUsage");
|
||||||
|
|
||||||
/* Clear dynamic data and set where to store extended key usage. */
|
/* Clear dynamic data and set where to store extended key usage. */
|
||||||
XMEMSET(dataASN, 0, sizeof(dataASN));
|
XMEMSET(dataASN, 0, sizeof(dataASN));
|
||||||
GetASN_Int16Bit(&dataASN[KEYUSAGEASN_IDX_STR], &cert->extKeyUsage);
|
GetASN_Buffer(&dataASN[KEYUSAGEASN_IDX_STR], keyUsage, &keyUsageSz);
|
||||||
/* Parse key usage. */
|
/* Parse key usage. */
|
||||||
return GetASN_Items(keyUsageASN, dataASN, keyUsageASN_Length, 0, input,
|
ret = GetASN_Items(keyUsageASN, dataASN, keyUsageASN_Length, 0, input,
|
||||||
&idx, sz);
|
&idx, sz);
|
||||||
|
if (ret == 0) {
|
||||||
|
/* Decode the bit string number as LE */
|
||||||
|
cert->extKeyUsage = (word16)(keyUsage[0]);
|
||||||
|
if (keyUsageSz == 2)
|
||||||
|
cert->extKeyUsage |= (word16)(keyUsage[1] << 8);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
#endif /* WOLFSSL_ASN_TEMPLATE */
|
#endif /* WOLFSSL_ASN_TEMPLATE */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user