diff --git a/tests/unit-mcdc/test_asn_ext_whitebox.c b/tests/unit-mcdc/test_asn_ext_whitebox.c index 39f3413f01..b770ecd905 100644 --- a/tests/unit-mcdc/test_asn_ext_whitebox.c +++ b/tests/unit-mcdc/test_asn_ext_whitebox.c @@ -2745,7 +2745,7 @@ static void wb_decode_cert_req_version(void) { WB_NOTE("WOLFSSL_CERT_REQ off; sk * Section 26: ParseCert() RSA public key store [:23263-:23267] * (best-effort -- see file-header RESIDUAL note for operands 2/3). * ------------------------------------------------------------------------- */ -#if (!defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ +#if (!defined(WC_ASN_NO_HEAP) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ defined(WOLFSSL_DYN_CERT) static void wb_parse_cert_rsa_pubkey(void) { @@ -2769,7 +2769,7 @@ static void wb_parse_cert_rsa_pubkey(void) FreeDecodedCert(&cert); } #else -static void wb_parse_cert_rsa_pubkey(void) { WB_NOTE("WOLFSSL_NO_MALLOC build; ParseCert copy-out skipped"); } +static void wb_parse_cert_rsa_pubkey(void) { WB_NOTE("WC_ASN_NO_HEAP build; ParseCert copy-out skipped"); } #endif /* ------------------------------------------------------------------------- * diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index ba98f4b787..339e8357a8 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -24206,7 +24206,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(NO_WOLFSSL_CM_VERIFY)) || \ +#if (!defined(WC_ASN_NO_HEAP) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ defined(WOLFSSL_DYN_CERT) char* ptr; #endif @@ -24215,9 +24215,9 @@ 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(WC_ASN_NO_HEAP) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ defined(WOLFSSL_DYN_CERT) - /* cert->subjectCN not stored as copy of WOLFSSL_NO_MALLOC defined */ + /* cert->subjectCN not stored as a copy when there is no allocator */ if (cert->subjectCNLen > 0) { ptr = (char*)XMALLOC((size_t)cert->subjectCNLen + 1, cert->heap, DYNAMIC_TYPE_SUBJECT_CN); @@ -24230,9 +24230,12 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm) } #endif -#if (!defined(WOLFSSL_NO_MALLOC) && !defined(NO_WOLFSSL_CM_VERIFY)) || \ +/* WC_ASN_NO_HEAP, not WOLFSSL_NO_MALLOC: a static-memory build defines the + * latter but still has an allocator, and StoreKey() copies the non-RSA keys + * on the same condition. Skipping the copy here leaves Signer.publicKey NULL, + * so every chain verify under an RSA CA fails BAD_FUNC_ARG. */ +#if (!defined(WC_ASN_NO_HEAP) && !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 || cert->keyOID == RSAPSSk