@@ -2768,7 +2768,7 @@ int GetASNInt(const byte* input, word32* inOutIdx, int* len,
27682768}
27692769
27702770#ifndef WOLFSSL_ASN_TEMPLATE
2771- #ifndef NO_CERTS
2771+ #if !defined( NO_CERTS) && defined(WOLFSSL_CUSTOM_CURVES)
27722772/* Get the DER/BER encoding of an ASN.1 INTEGER that has a value of no more than
27732773 * 7 bits.
27742774 *
@@ -2800,7 +2800,7 @@ static int GetInteger7Bit(const byte* input, word32* inOutIdx, word32 maxIdx)
28002800}
28012801#endif /* !NO_CERTS */
28022802
2803- #if defined(WC_RSA_PSS) && !defined(NO_RSA)
2803+ #if (( defined(WC_RSA_PSS) && !defined(NO_RSA)) || !defined(NO_CERTS) )
28042804/* Get the DER/BER encoding of an ASN.1 INTEGER that has a value of no more than
28052805 * 16 bits.
28062806 *
@@ -20640,10 +20640,15 @@ static int DecodeBasicCaConstraint(const byte* input, int sz, DecodedCert* cert)
2064020640 return 0;
2064120641 }
2064220642
20643- ret = GetInteger7Bit (input, &idx, (word32)sz);
20643+ ret = GetInteger16Bit (input, &idx, (word32)sz);
2064420644 if (ret < 0)
2064520645 return ret;
20646- cert->pathLength = (byte)ret;
20646+ else if (ret > WOLFSSL_MAX_PATH_LEN) {
20647+ WOLFSSL_ERROR_VERBOSE(ASN_PATHLEN_SIZE_E);
20648+ return ASN_PATHLEN_SIZE_E;
20649+ }
20650+
20651+ cert->pathLength = (word16)ret;
2064720652 cert->pathLengthSet = 1;
2064820653
2064920654 return 0;
@@ -20660,7 +20665,7 @@ static int DecodeBasicCaConstraint(const byte* input, int sz, DecodedCert* cert)
2066020665 if (ret == 0) {
2066120666 /* Get the CA boolean and path length when present. */
2066220667 GetASN_Boolean(&dataASN[BASICCONSASN_IDX_CA], &isCA);
20663- GetASN_Int8Bit (&dataASN[BASICCONSASN_IDX_PLEN], &cert->pathLength);
20668+ GetASN_Int16Bit (&dataASN[BASICCONSASN_IDX_PLEN], &cert->pathLength);
2066420669
2066520670 ret = GetASN_Items(basicConsASN, dataASN, basicConsASN_Length, 1, input,
2066620671 &idx, (word32)sz);
@@ -20677,11 +20682,6 @@ static int DecodeBasicCaConstraint(const byte* input, int sz, DecodedCert* cert)
2067720682 ret = ASN_PARSE_E;
2067820683 }
2067920684#endif
20680- /* Path length must be a 7-bit value. */
20681- if ((ret == 0) && (cert->pathLength >= (1 << 7))) {
20682- WOLFSSL_ERROR_VERBOSE(ASN_PARSE_E);
20683- ret = ASN_PARSE_E;
20684- }
2068520685 if ((ret == 0) && cert->pathLength > WOLFSSL_MAX_PATH_LEN) {
2068620686 WOLFSSL_ERROR_VERBOSE(ASN_PATHLEN_SIZE_E);
2068720687 ret = ASN_PATHLEN_SIZE_E;
0 commit comments