Skip to content

Commit eb53a95

Browse files
committed
wolfcrypt/src/asn.c:DecodeSingleResponse(): fix gating for "at" working var, by refactoring gating for WOLFSSL_OCSP_PARSE_STATUS sections for clarity.
1 parent 3fac3b7 commit eb53a95

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36028,7 +36028,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
3602836028
*ioIndex = idx;
3602936029

3603036030
return 0;
36031-
#else
36031+
#else /* WOLFSSL_ASN_TEMPLATE */
3603236032
DECL_ASNGETDATA(dataASN, singleResponseASN_Length);
3603336033
int ret = 0;
3603436034
word32 ocspDigestSize = OCSP_DIGEST_SIZE;
@@ -36038,10 +36038,6 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
3603836038
word32 issuerKeyHashLen;
3603936039
word32 thisDateLen;
3604036040
word32 nextDateLen;
36041-
#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \
36042-
defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY)
36043-
WOLFSSL_ASN1_TIME *at;
36044-
#endif
3604536041

3604636042
(void)wrapperSz;
3604736043

@@ -36119,19 +36115,20 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
3611936115
if (!XVALIDATE_DATE(cs->thisDate, ASN_GENERALIZED_TIME, ASN_BEFORE)) {
3612036116
ret = ASN_BEFORE_DATE_E;
3612136117
}
36118+
#endif /* !NO_ASN_TIME_CHECK && !WOLFSSL_NO_OCSP_DATE_CHECK */
3612236119
}
36120+
#ifdef WOLFSSL_OCSP_PARSE_STATUS
3612336121
if (ret == 0) {
36124-
#endif
36125-
#ifdef WOLFSSL_OCSP_PARSE_STATUS
3612636122
/* Store ASN.1 version of thisDate. */
36123+
WOLFSSL_ASN1_TIME *at;
3612736124
cs->thisDateAsn = GetASNItem_Addr(
3612836125
dataASN[SINGLERESPONSEASN_IDX_THISUPDATE_GT], source);
3612936126
at = &cs->thisDateParsed;
3613036127
at->type = ASN_GENERALIZED_TIME;
3613136128
XMEMCPY(at->data, cs->thisDate, thisDateLen);
3613236129
at->length = (int)thisDateLen;
36133-
#endif
3613436130
}
36131+
#endif
3613536132
if ((ret == 0) &&
3613636133
(dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0)) {
3613736134
/* Store the nextDate format - only one possible. */
@@ -36141,28 +36138,30 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
3614136138
if (!XVALIDATE_DATE(cs->nextDate, ASN_GENERALIZED_TIME, ASN_AFTER)) {
3614236139
ret = ASN_AFTER_DATE_E;
3614336140
}
36141+
#endif /* !NO_ASN_TIME_CHECK && !WOLFSSL_NO_OCSP_DATE_CHECK */
3614436142
}
36143+
#ifdef WOLFSSL_OCSP_PARSE_STATUS
3614536144
if ((ret == 0) &&
36146-
(dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0)) {
36147-
#endif
36148-
#ifdef WOLFSSL_OCSP_PARSE_STATUS
36145+
(dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT].tag != 0))
36146+
{
3614936147
/* Store ASN.1 version of thisDate. */
36148+
WOLFSSL_ASN1_TIME *at;
3615036149
cs->nextDateAsn = GetASNItem_Addr(
3615136150
dataASN[SINGLERESPONSEASN_IDX_NEXTUPDATE_GT], source);
3615236151
at = &cs->nextDateParsed;
3615336152
at->type = ASN_GENERALIZED_TIME;
3615436153
XMEMCPY(at->data, cs->nextDate, nextDateLen);
3615536154
at->length = (int)nextDateLen;
36156-
#endif
3615736155
}
36156+
#endif
3615836157
if (ret == 0) {
3615936158
/* OcspEntry now used. */
3616036159
single->used = 1;
3616136160
}
3616236161

3616336162
FREE_ASNGETDATA(dataASN, NULL);
3616436163
return ret;
36165-
#endif
36164+
#endif /* WOLFSSL_ASN_TEMPLATE */
3616636165
}
3616736166

3616836167
#ifdef WOLFSSL_ASN_TEMPLATE

0 commit comments

Comments
 (0)