Merge pull request #7199 from lealem47/defaultASN

Default to ASN TEMPLATE library
This commit is contained in:
Daniel Pouzzner
2024-02-05 22:32:57 -05:00
committed by GitHub
3 changed files with 26 additions and 10 deletions

View File

@@ -1,3 +1,7 @@
# wolfSSL Release X.Y.Z (TBD)
NOTE: This release switches the default ASN.1 parser to the new ASN template code. If the original ASN.1 code is preferred define `WOLFSSL_ASN_ORIGINAL` to use it. See PR #7199.
# wolfSSL Release 5.6.6 (Dec 19, 2023) # wolfSSL Release 5.6.6 (Dec 19, 2023)
Release 5.6.6 has been developed according to wolfSSL's development and QA Release 5.6.6 has been developed according to wolfSSL's development and QA

View File

@@ -1384,9 +1384,8 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete,
int len; int len;
/* Current index into buffer. */ /* Current index into buffer. */
word32 idx = *inOutIdx; word32 idx = *inOutIdx;
/* Initialize the end index at each depth to be the length. */ /* Declare the end index array. */
word32 endIdx[GET_ASN_MAX_DEPTH] = { length, length, length, length, length, word32 endIdx[GET_ASN_MAX_DEPTH];
length, length };
/* Set choices to -1 to indicate they haven't been seen or found. */ /* Set choices to -1 to indicate they haven't been seen or found. */
signed char choiceMet[GET_ASN_MAX_CHOICES] = { -1, -1 }; signed char choiceMet[GET_ASN_MAX_CHOICES] = { -1, -1 };
/* Not matching a choice right now. */ /* Not matching a choice right now. */
@@ -1402,6 +1401,11 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete,
WOLFSSL_ENTER("GetASN_Items"); WOLFSSL_ENTER("GetASN_Items");
#endif #endif
/* Set the end index at each depth to be the length. */
for (i=0; i<GET_ASN_MAX_DEPTH; i++) {
endIdx[i] = length;
}
/* Start depth at first items depth. */ /* Start depth at first items depth. */
minDepth = depth = asn[0].depth; minDepth = depth = asn[0].depth;
/* Check every ASN.1 item. */ /* Check every ASN.1 item. */
@@ -3014,7 +3018,7 @@ int GetMyVersion(const byte* input, word32* inOutIdx,
#else #else
ASNGetData dataASN[intASN_Length]; ASNGetData dataASN[intASN_Length];
int ret; int ret;
byte num; byte num = 0;
/* Clear dynamic data and set the version number variable. */ /* Clear dynamic data and set the version number variable. */
XMEMSET(dataASN, 0, sizeof(dataASN)); XMEMSET(dataASN, 0, sizeof(dataASN));
@@ -3081,7 +3085,7 @@ int GetShortInt(const byte* input, word32* inOutIdx, int* number, word32 maxIdx)
#else #else
ASNGetData dataASN[intASN_Length]; ASNGetData dataASN[intASN_Length];
int ret; int ret;
word32 num; word32 num = 0;
/* Clear dynamic data and set the 32-bit number variable. */ /* Clear dynamic data and set the 32-bit number variable. */
XMEMSET(dataASN, 0, sizeof(dataASN)); XMEMSET(dataASN, 0, sizeof(dataASN));
@@ -6827,7 +6831,7 @@ int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz,
DECL_ASNGETDATA(dataASN, pkcs8KeyASN_Length); DECL_ASNGETDATA(dataASN, pkcs8KeyASN_Length);
int ret = 0; int ret = 0;
word32 oid = 9; word32 oid = 9;
byte version; byte version = 0;
word32 idx; word32 idx;
/* Check validity of parameters. */ /* Check validity of parameters. */
@@ -8745,7 +8749,7 @@ exit_dc:
int version; int version;
word32 idx = 0; word32 idx = 0;
word32 pIdx = 0; word32 pIdx = 0;
word32 iterations; word32 iterations = 0;
word32 keySz = 0; word32 keySz = 0;
word32 saltSz = 0; word32 saltSz = 0;
word32 shaOid = 0; word32 shaOid = 0;
@@ -19652,7 +19656,7 @@ enum {
static int DecodeSubtreeGeneralName(const byte* input, word32 sz, byte tag, static int DecodeSubtreeGeneralName(const byte* input, word32 sz, byte tag,
Base_entry** head, void* heap) Base_entry** head, void* heap)
{ {
Base_entry* entry; Base_entry* entry = NULL;
word32 nameIdx = 0; word32 nameIdx = 0;
word32 len = sz; word32 len = sz;
int strLen; int strLen;
@@ -33178,7 +33182,7 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key,
return ret; return ret;
#else #else
DECL_ASNGETDATA(dataASN, eccKeyASN_Length); DECL_ASNGETDATA(dataASN, eccKeyASN_Length);
byte version; byte version = 0;
int ret = 0; int ret = 0;
int curve_id = ECC_CURVE_DEF; int curve_id = ECC_CURVE_DEF;
#if defined(HAVE_PKCS8) || defined(HAVE_PKCS12) || defined(SM2) #if defined(HAVE_PKCS8) || defined(HAVE_PKCS12) || defined(SM2)
@@ -36210,7 +36214,7 @@ int OcspResponseDecode(OcspResponse* resp, void* cm, void* heap, int noVerify)
int ret = 0; int ret = 0;
word32 idx = 0, size = resp->maxIdx; word32 idx = 0, size = resp->maxIdx;
byte* source = resp->source; byte* source = resp->source;
byte status; byte status = 0;
byte* basic; byte* basic;
word32 basicSz; word32 basicSz;

View File

@@ -2735,6 +2735,14 @@ extern void uITRON4_free(void *p) ;
#define WOLFSSL_IPV6 #define WOLFSSL_IPV6
#endif #endif
/* ---------------------------------------------------------------------------
* ASN Library Selection (default to ASN_TEMPLATE)
* ---------------------------------------------------------------------------
*/
#if !defined(WOLFSSL_ASN_TEMPLATE) && !defined(WOLFSSL_ASN_ORIGINAL) && \
!defined(NO_ASN)
#define WOLFSSL_ASN_TEMPLATE
#endif
#ifdef WOLFSSL_LINUXKM #ifdef WOLFSSL_LINUXKM
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H