mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Merge pull request #6186 from SparkiDev/asn_template_leading_zero
ASN template: compile option to allow leading zeros
This commit is contained in:
@ -1027,27 +1027,25 @@ static int GetASN_Integer(const byte* input, word32 idx, int length,
|
|||||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))
|
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))
|
||||||
/* Check contents consist of one or more octets. */
|
/* Check contents consist of one or more octets. */
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
#ifdef WOLFSSL_DEBUG_ASN_TEMPLATE
|
|
||||||
WOLFSSL_MSG("Zero length INTEGER not allowed");
|
WOLFSSL_MSG("Zero length INTEGER not allowed");
|
||||||
#endif
|
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (input[idx] == 0) {
|
if (input[idx] == 0) {
|
||||||
/* Check leading zero byte required. */
|
/* Check leading zero byte required. */
|
||||||
if ((length > 1) && ((input[idx + 1] & 0x80) == 0)) {
|
if ((length > 1) && ((input[idx + 1] & 0x80) == 0)) {
|
||||||
#ifdef WOLFSSL_DEBUG_ASN_TEMPLATE
|
|
||||||
WOLFSSL_MSG("Zero not required on INTEGER");
|
WOLFSSL_MSG("Zero not required on INTEGER");
|
||||||
#endif
|
#ifndef WOLFSSL_ASN_INT_LEAD_0_ANY
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Check whether a leading zero byte was required. */
|
/* Check whether a leading zero byte was required. */
|
||||||
else if (positive && (input[idx] & 0x80)) {
|
else if (positive && (input[idx] & 0x80)) {
|
||||||
#ifdef WOLFSSL_DEBUG_ASN_TEMPLATE
|
|
||||||
WOLFSSL_MSG("INTEGER is negative");
|
WOLFSSL_MSG("INTEGER is negative");
|
||||||
#endif
|
#ifndef WOLFSSL_ASN_INT_LEAD_0_ANY
|
||||||
return ASN_EXPECT_0_E;
|
return ASN_EXPECT_0_E;
|
||||||
|
#endif /* WOLFSSL_ASN_INT_LEAD_0_ANY */
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user