Skip to content

Commit abfcda8

Browse files
committed
Decode the key usage extension as LE not BE
1 parent e85901c commit abfcda8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19247,14 +19247,24 @@ static int DecodeKeyUsage(const byte* input, word32 sz, DecodedCert* cert)
1924719247
#else
1924819248
ASNGetData dataASN[keyUsageASN_Length];
1924919249
word32 idx = 0;
19250+
byte keyUsage[OPAQUE16_LEN];
19251+
word32 keyUsageSz = sizeof(keyUsage);
19252+
int ret;
1925019253
WOLFSSL_ENTER("DecodeKeyUsage");
1925119254

1925219255
/* Clear dynamic data and set where to store extended key usage. */
1925319256
XMEMSET(dataASN, 0, sizeof(dataASN));
19254-
GetASN_Int16Bit(&dataASN[KEYUSAGEASN_IDX_STR], &cert->extKeyUsage);
19257+
GetASN_Buffer(&dataASN[KEYUSAGEASN_IDX_STR], keyUsage, &keyUsageSz);
1925519258
/* Parse key usage. */
19256-
return GetASN_Items(keyUsageASN, dataASN, keyUsageASN_Length, 0, input,
19259+
ret = GetASN_Items(keyUsageASN, dataASN, keyUsageASN_Length, 0, input,
1925719260
&idx, sz);
19261+
if (ret == 0) {
19262+
/* Decode the bit string number as LE */
19263+
cert->extKeyUsage = (word16)(keyUsage[0]);
19264+
if (keyUsageSz == 2)
19265+
cert->extKeyUsage |= (word16)(keyUsage[1] << 8);
19266+
}
19267+
return ret;
1925819268
#endif /* WOLFSSL_ASN_TEMPLATE */
1925919269
}
1926019270

0 commit comments

Comments
 (0)