From 6665f240e0a096dc680c8d503080d33ac400a6b9 Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Wed, 6 Sep 2023 18:17:42 -0400 Subject: [PATCH 1/2] Expose GetASNInt as part of WOLFSSL_ASN_API --- wolfcrypt/src/asn.c | 2 +- wolfssl/wolfcrypt/asn.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 483a659f2..ea12f9798 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -2562,7 +2562,7 @@ int GetOctetString(const byte* input, word32* inOutIdx, int* len, word32 maxIdx) * or invalid use of or missing leading zero. * Otherwise, 0 to indicate success. */ -static int GetASNInt(const byte* input, word32* inOutIdx, int* len, +int GetASNInt(const byte* input, word32* inOutIdx, int* len, word32 maxIdx) { int ret; diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index a643e9f3a..b0127e20f 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -2194,6 +2194,11 @@ WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx, WOLFSSL_LOCAL int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx, word32 maxIdx); +#ifndef WOLFSSL_ASN_TEMPLATE +WOLFSSL_ASN_API int GetASNInt(const byte* input, word32* inOutIdx, int* len, + word32 maxIdx); +#endif + #ifdef HAVE_OID_ENCODING WOLFSSL_API int wc_EncodeObjectId(const word16* in, word32 inSz, byte* out, word32* outSz); From fddda8f5821879118684fa314257b1ac929125ec Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Thu, 7 Sep 2023 09:52:27 -0400 Subject: [PATCH 2/2] Expose GetASNHeader in both template and original. --- wolfcrypt/src/asn.c | 2 +- wolfssl/wolfcrypt/asn.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index ea12f9798..6fb4d741e 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -2548,7 +2548,6 @@ int GetOctetString(const byte* input, word32* inOutIdx, int* len, word32 maxIdx) return GetASNHeader(input, ASN_OCTET_STRING, inOutIdx, len, maxIdx); } -#ifndef WOLFSSL_ASN_TEMPLATE /* Get the DER/BER encoding of an ASN.1 INTEGER header. * * Removes the leading zero byte when found. @@ -2598,6 +2597,7 @@ int GetASNInt(const byte* input, word32* inOutIdx, int* len, return 0; } +#ifndef WOLFSSL_ASN_TEMPLATE #ifndef NO_CERTS /* Get the DER/BER encoding of an ASN.1 INTEGER that has a value of no more than * 7 bits. diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index b0127e20f..0c10d1399 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -2193,11 +2193,8 @@ WOLFSSL_LOCAL int GetMyVersion(const byte* input, word32* inOutIdx, int* version, word32 maxIdx); WOLFSSL_LOCAL int GetInt(mp_int* mpi, const byte* input, word32* inOutIdx, word32 maxIdx); - -#ifndef WOLFSSL_ASN_TEMPLATE WOLFSSL_ASN_API int GetASNInt(const byte* input, word32* inOutIdx, int* len, word32 maxIdx); -#endif #ifdef HAVE_OID_ENCODING WOLFSSL_API int wc_EncodeObjectId(const word16* in, word32 inSz,