Use GetShortInt instead for CRL number extension parsing

This commit is contained in:
Colton Willey
2024-09-26 15:43:30 -07:00
parent 720e24209a
commit 3d9a4ccddc

View File

@@ -38280,42 +38280,6 @@ static int ParseCRL_AuthKeyIdExt(const byte* input, int sz, DecodedCRL* dcrl)
} }
#endif #endif
#ifdef WOLFSSL_ASN_TEMPLATE
static const ASNItem crlNumASN[] = {
/* CRL NUM */ {0, ASN_INTEGER, 0, 0, 0 },
};
enum {
CRLNUMASN_IDX_CRL_NUM = 0
};
/* Number of items in ASN.1 template for CrlNumber. */
#define crlNumASN_Length (sizeof(crlNumASN) / sizeof(ASNItem))
static int ParseCRL_CrlNumExt(const byte* input, int sz, DecodedCRL* dcrl)
{
DECL_ASNGETDATA(dataASN, crlNumASN_Length);
int ret = 0;
word32 idx = 0;
WOLFSSL_ENTER("ParseCRL_CrlNumExt");
CALLOC_ASNGETDATA(dataASN, crlNumASN_Length, ret, dcrl->heap);
if (ret == 0) {
GetASN_Int32Bit(&dataASN[CRLNUMASN_IDX_CRL_NUM], (word32 *)&dcrl->crlNumber);
/* Parse a CRL number. */
ret = GetASN_Items(crlNumASN, dataASN, crlNumASN_Length, 0, input,
&idx, (word32)sz);
}
FREE_ASNGETDATA(dataASN, dcrl->heap);
return ret;
}
#endif /* WOLFSSL_ASN_TEMPLATE */
#ifndef WOLFSSL_ASN_TEMPLATE #ifndef WOLFSSL_ASN_TEMPLATE
static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf, static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf,
word32* inOutIdx, word32 sz) word32* inOutIdx, word32 sz)
@@ -38510,9 +38474,11 @@ static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf, word32 idx,
else if (oid == CRL_NUMBER_OID) { else if (oid == CRL_NUMBER_OID) {
/* Parse CRL Number extension. /* Parse CRL Number extension.
* idx is at start of OCTET_STRING data. */ * idx is at start of OCTET_STRING data. */
ret = ParseCRL_CrlNumExt(buf + idx, length, dcrl); if (GetShortInt(buf,
if (ret != 0) { &idx, &dcrl->crlNumber, maxIdx) < 0) {
WOLFSSL_MSG("\tcouldn't parse CRL Number extension"); WOLFSSL_MSG("\tcouldn't parse CRL Number extension");
ret = ASN_PARSE_E;
break;
} }
} }
/* TODO: check criticality */ /* TODO: check criticality */