From 8dee048b04ab3a52075d96a387d69d748f16c990 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Thu, 28 May 2020 08:50:21 +1000 Subject: [PATCH] Define to allow badly formed ASN integers Define: WOLFSSL_ASN_INT_LEAD_0_ANY Allows positive integers to have a leading 0 byte. DER/BER encoding specifies that leding 0 only on negative numbers (highest bit of first octet set). --- wolfcrypt/src/asn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 226278441..67f25bff1 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -460,8 +460,10 @@ static int GetASNInt(const byte* input, word32* inOutIdx, int* len, (*inOutIdx)++; (*len)--; +#ifndef WOLFSSL_ASN_INT_LEAD_0_ANY if (*len > 0 && (input[*inOutIdx] & 0x80) == 0) return ASN_PARSE_E; +#endif } }