From 63f7298be26ef4292da48ebd5f6121aac53627fb Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Thu, 1 Feb 2024 14:52:06 -0700 Subject: [PATCH 1/2] Default to ASN TEMPLATE library --- ChangeLog.md | 4 ++++ wolfcrypt/src/asn.c | 12 ++++++++---- wolfssl/wolfcrypt/settings.h | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 586adaa45..140d73063 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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) Release 5.6.6 has been developed according to wolfSSL's development and QA diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 3b61f6fb5..40ab40300 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -1384,9 +1384,8 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete, int len; /* Current index into buffer. */ word32 idx = *inOutIdx; - /* Initialize the end index at each depth to be the length. */ - word32 endIdx[GET_ASN_MAX_DEPTH] = { length, length, length, length, length, - length, length }; + /* Declare the end index array. */ + word32 endIdx[GET_ASN_MAX_DEPTH]; /* Set choices to -1 to indicate they haven't been seen or found. */ signed char choiceMet[GET_ASN_MAX_CHOICES] = { -1, -1 }; /* 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"); #endif + /* Set the end index at each depth to be the length. */ + for (i=0; i Date: Mon, 5 Feb 2024 15:09:05 -0700 Subject: [PATCH 2/2] For cppcheck: Explicitly initialize some variables --- wolfcrypt/src/asn.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 40ab40300..e5d5df172 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -3018,7 +3018,7 @@ int GetMyVersion(const byte* input, word32* inOutIdx, #else ASNGetData dataASN[intASN_Length]; int ret; - byte num; + byte num = 0; /* Clear dynamic data and set the version number variable. */ XMEMSET(dataASN, 0, sizeof(dataASN)); @@ -3085,7 +3085,7 @@ int GetShortInt(const byte* input, word32* inOutIdx, int* number, word32 maxIdx) #else ASNGetData dataASN[intASN_Length]; int ret; - word32 num; + word32 num = 0; /* Clear dynamic data and set the 32-bit number variable. */ XMEMSET(dataASN, 0, sizeof(dataASN)); @@ -6767,7 +6767,7 @@ int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz, DECL_ASNGETDATA(dataASN, pkcs8KeyASN_Length); int ret = 0; word32 oid = 9; - byte version; + byte version = 0; word32 idx; /* Check validity of parameters. */ @@ -8685,7 +8685,7 @@ exit_dc: int version; word32 idx = 0; word32 pIdx = 0; - word32 iterations; + word32 iterations = 0; word32 keySz = 0; word32 saltSz = 0; word32 shaOid = 0; @@ -33081,7 +33081,7 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, return ret; #else DECL_ASNGETDATA(dataASN, eccKeyASN_Length); - byte version; + byte version = 0; int ret = 0; int curve_id = ECC_CURVE_DEF; #if defined(HAVE_PKCS8) || defined(HAVE_PKCS12) || defined(SM2) @@ -36113,7 +36113,7 @@ int OcspResponseDecode(OcspResponse* resp, void* cm, void* heap, int noVerify) int ret = 0; word32 idx = 0, size = resp->maxIdx; byte* source = resp->source; - byte status; + byte status = 0; byte* basic; word32 basicSz;