From 9486721bb8d2b2d299ea9d099c321a5cf25efd24 Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Wed, 26 Oct 2022 12:11:55 -0400 Subject: [PATCH 1/2] Prevent WOLFSSL_NO_MALLOC from breaking RSA certificate verfication --- wolfcrypt/src/asn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 5ad446442..a5a8a8fe0 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -20804,7 +20804,7 @@ static int DecodeCertReq(DecodedCert* cert, int* criticalExt) int ParseCert(DecodedCert* cert, int type, int verify, void* cm) { int ret; -#if !defined(WOLFSSL_NO_MALLOC) || defined(WOLFSSL_DYN_CERT) +#if !defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY) char* ptr; #endif @@ -20812,7 +20812,7 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm) if (ret < 0) return ret; -#if !defined(WOLFSSL_NO_MALLOC) || defined(WOLFSSL_DYN_CERT) +#if !defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY) /* cert->subjectCN not stored as copy of WOLFSSL_NO_MALLOC defind */ if (cert->subjectCNLen > 0) { ptr = (char*) XMALLOC(cert->subjectCNLen + 1, cert->heap, @@ -20826,7 +20826,7 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm) } #endif -#if !defined(WOLFSSL_NO_MALLOC) || defined(WOLFSSL_DYN_CERT) +#if !defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY) /* cert->publicKey not stored as copy if WOLFSSL_NO_MALLOC defined */ if ((cert->keyOID == RSAk #ifdef WC_RSA_PSS From 0158c8248706a122abce0e241b0f63070b239101 Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Fri, 28 Oct 2022 13:37:55 -0400 Subject: [PATCH 2/2] Keep WOLFSSL_DYN_CERT --- wolfcrypt/src/asn.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index a5a8a8fe0..6ab8099b1 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -20804,7 +20804,8 @@ static int DecodeCertReq(DecodedCert* cert, int* criticalExt) int ParseCert(DecodedCert* cert, int type, int verify, void* cm) { int ret; -#if !defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY) +#if (!defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ + defined(WOLFSSL_DYN_CERT) char* ptr; #endif @@ -20812,7 +20813,8 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm) if (ret < 0) return ret; -#if !defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY) +#if (!defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ + defined(WOLFSSL_DYN_CERT) /* cert->subjectCN not stored as copy of WOLFSSL_NO_MALLOC defind */ if (cert->subjectCNLen > 0) { ptr = (char*) XMALLOC(cert->subjectCNLen + 1, cert->heap, @@ -20826,7 +20828,8 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm) } #endif -#if !defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY) +#if (!defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ + defined(WOLFSSL_DYN_CERT) /* cert->publicKey not stored as copy if WOLFSSL_NO_MALLOC defined */ if ((cert->keyOID == RSAk #ifdef WC_RSA_PSS