Skip to content

Commit

Permalink
Use GetShortInt instead for CRL number extension parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ColtonWilley committed Sep 26, 2024
1 parent 720e242 commit 3d9a4cc
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -38280,42 +38280,6 @@ static int ParseCRL_AuthKeyIdExt(const byte* input, int sz, DecodedCRL* dcrl)
}
#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
static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf,
word32* inOutIdx, word32 sz)
Expand Down Expand Up @@ -38510,9 +38474,11 @@ static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf, word32 idx,
else if (oid == CRL_NUMBER_OID) {
/* Parse CRL Number extension.
* idx is at start of OCTET_STRING data. */
ret = ParseCRL_CrlNumExt(buf + idx, length, dcrl);
if (ret != 0) {
if (GetShortInt(buf,
&idx, &dcrl->crlNumber, maxIdx) < 0) {
WOLFSSL_MSG("\tcouldn't parse CRL Number extension");
ret = ASN_PARSE_E;
break;
}
}
/* TODO: check criticality */
Expand Down

0 comments on commit 3d9a4cc

Please sign in to comment.