Skip to content

Commit 4d842f0

Browse files
authored
Merge pull request #7199 from lealem47/defaultASN
Default to ASN TEMPLATE library
2 parents 86b1aae + d36bd47 commit 4d842f0

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# wolfSSL Release X.Y.Z (TBD)
2+
3+
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.
4+
15
# wolfSSL Release 5.6.6 (Dec 19, 2023)
26

37
Release 5.6.6 has been developed according to wolfSSL's development and QA

wolfcrypt/src/asn.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,9 +1384,8 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete,
13841384
int len;
13851385
/* Current index into buffer. */
13861386
word32 idx = *inOutIdx;
1387-
/* Initialize the end index at each depth to be the length. */
1388-
word32 endIdx[GET_ASN_MAX_DEPTH] = { length, length, length, length, length,
1389-
length, length };
1387+
/* Declare the end index array. */
1388+
word32 endIdx[GET_ASN_MAX_DEPTH];
13901389
/* Set choices to -1 to indicate they haven't been seen or found. */
13911390
signed char choiceMet[GET_ASN_MAX_CHOICES] = { -1, -1 };
13921391
/* Not matching a choice right now. */
@@ -1402,6 +1401,11 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete,
14021401
WOLFSSL_ENTER("GetASN_Items");
14031402
#endif
14041403

1404+
/* Set the end index at each depth to be the length. */
1405+
for (i=0; i<GET_ASN_MAX_DEPTH; i++) {
1406+
endIdx[i] = length;
1407+
}
1408+
14051409
/* Start depth at first items depth. */
14061410
minDepth = depth = asn[0].depth;
14071411
/* Check every ASN.1 item. */
@@ -3014,7 +3018,7 @@ int GetMyVersion(const byte* input, word32* inOutIdx,
30143018
#else
30153019
ASNGetData dataASN[intASN_Length];
30163020
int ret;
3017-
byte num;
3021+
byte num = 0;
30183022

30193023
/* Clear dynamic data and set the version number variable. */
30203024
XMEMSET(dataASN, 0, sizeof(dataASN));
@@ -3081,7 +3085,7 @@ int GetShortInt(const byte* input, word32* inOutIdx, int* number, word32 maxIdx)
30813085
#else
30823086
ASNGetData dataASN[intASN_Length];
30833087
int ret;
3084-
word32 num;
3088+
word32 num = 0;
30853089

30863090
/* Clear dynamic data and set the 32-bit number variable. */
30873091
XMEMSET(dataASN, 0, sizeof(dataASN));
@@ -6827,7 +6831,7 @@ int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, word32 sz,
68276831
DECL_ASNGETDATA(dataASN, pkcs8KeyASN_Length);
68286832
int ret = 0;
68296833
word32 oid = 9;
6830-
byte version;
6834+
byte version = 0;
68316835
word32 idx;
68326836

68336837
/* Check validity of parameters. */
@@ -8745,7 +8749,7 @@ int DecryptContent(byte* input, word32 sz, const char* password, int passwordSz)
87458749
int version;
87468750
word32 idx = 0;
87478751
word32 pIdx = 0;
8748-
word32 iterations;
8752+
word32 iterations = 0;
87498753
word32 keySz = 0;
87508754
word32 saltSz = 0;
87518755
word32 shaOid = 0;
@@ -19652,7 +19656,7 @@ enum {
1965219656
static int DecodeSubtreeGeneralName(const byte* input, word32 sz, byte tag,
1965319657
Base_entry** head, void* heap)
1965419658
{
19655-
Base_entry* entry;
19659+
Base_entry* entry = NULL;
1965619660
word32 nameIdx = 0;
1965719661
word32 len = sz;
1965819662
int strLen;
@@ -33178,7 +33182,7 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key,
3317833182
return ret;
3317933183
#else
3318033184
DECL_ASNGETDATA(dataASN, eccKeyASN_Length);
33181-
byte version;
33185+
byte version = 0;
3318233186
int ret = 0;
3318333187
int curve_id = ECC_CURVE_DEF;
3318433188
#if defined(HAVE_PKCS8) || defined(HAVE_PKCS12) || defined(SM2)
@@ -36210,7 +36214,7 @@ int OcspResponseDecode(OcspResponse* resp, void* cm, void* heap, int noVerify)
3621036214
int ret = 0;
3621136215
word32 idx = 0, size = resp->maxIdx;
3621236216
byte* source = resp->source;
36213-
byte status;
36217+
byte status = 0;
3621436218
byte* basic;
3621536219
word32 basicSz;
3621636220

wolfssl/wolfcrypt/settings.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,14 @@ extern void uITRON4_free(void *p) ;
27352735
#define WOLFSSL_IPV6
27362736
#endif
27372737

2738+
/* ---------------------------------------------------------------------------
2739+
* ASN Library Selection (default to ASN_TEMPLATE)
2740+
* ---------------------------------------------------------------------------
2741+
*/
2742+
#if !defined(WOLFSSL_ASN_TEMPLATE) && !defined(WOLFSSL_ASN_ORIGINAL) && \
2743+
!defined(NO_ASN)
2744+
#define WOLFSSL_ASN_TEMPLATE
2745+
#endif
27382746

27392747
#ifdef WOLFSSL_LINUXKM
27402748
#ifdef HAVE_CONFIG_H

0 commit comments

Comments
 (0)