@@ -1498,6 +1498,8 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete,
14981498 int minDepth;
14991499 /* Integer had a zero prepended. */
15001500 int zeroPadded;
1501+ word32 tmpW32Val;
1502+ signed char tmpScharVal;
15011503
15021504#ifdef WOLFSSL_DEBUG_ASN_TEMPLATE
15031505 WOLFSSL_ENTER("GetASN_Items");
@@ -1536,14 +1538,18 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete,
15361538 /* Check if first of numbered choice. */
15371539 if (choice == 0 && asn[i].optional > 1) {
15381540 choice = asn[i].optional;
1539- if (choiceMet[choice - 2] == -1) {
1541+ tmpScharVal = choiceMet[choice - 2];
1542+ XFENCE(); /* Prevent memory access */
1543+ if (tmpScharVal == -1) {
15401544 /* Choice seen but not found a match yet. */
15411545 choiceMet[choice - 2] = 0;
15421546 }
15431547 }
15441548
15451549 /* Check for end of data or not a choice and tag not matching. */
1546- if (idx == endIdx[depth] || (data[i].dataType != ASN_DATA_TYPE_CHOICE &&
1550+ tmpW32Val = endIdx[depth];
1551+ XFENCE(); /* Prevent memory access */
1552+ if (idx == tmpW32Val || (data[i].dataType != ASN_DATA_TYPE_CHOICE &&
15471553 (input[idx] & ~ASN_CONSTRUCTED) != asn[i].tag)) {
15481554 if (asn[i].optional) {
15491555 /* Skip over ASN.1 items underneath this optional item. */
@@ -1611,6 +1617,7 @@ int GetASN_Items(const ASNItem* asn, ASNGetData *data, int count, int complete,
16111617
16121618 /* Store found tag in data. */
16131619 data[i].tag = input[idx];
1620+ XFENCE(); /* Prevent memory access */
16141621 if (data[i].dataType != ASN_DATA_TYPE_CHOICE) {
16151622 int constructed = (input[idx] & ASN_CONSTRUCTED) == ASN_CONSTRUCTED;
16161623 /* Check constructed match expected for non-choice ASN.1 item. */
0 commit comments