From 33f0e2eda56d8d8749b76509d100d00ed2ec5d23 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 12 Jan 2022 11:15:48 -0800 Subject: [PATCH 1/2] In the wolfCrypt test, fix a few filenames to use the VPATH versions. --- wolfcrypt/test/test.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 135740ef9..cd96e0b73 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -12223,6 +12223,16 @@ WOLFSSL_TEST_SUBROUTINE int memory_test(void) #endif #endif /* !USE_CERT_BUFFER_* */ +#if !defined(NO_ASN_TIME) && !defined(NO_RSA) && defined(WOLFSSL_TEST_CERT) && \ + !defined(NO_FILESYSTEM) + static const char* certExtNc = + CERT_ROOT "test" CERT_PATH_SEP "cert-ext-nc.der"; + static const char* certExtIa = + CERT_ROOT "test" CERT_PATH_SEP "cert-ext-ia.der"; + static const char* certExtNct = + CERT_ROOT "test" CERT_PATH_SEP "cert-ext-nct.der"; +#endif + #ifndef NO_WRITE_TEMP_FILES #ifdef HAVE_ECC #ifdef WOLFSSL_CERT_GEN @@ -12480,11 +12490,7 @@ WOLFSSL_TEST_SUBROUTINE int cert_test(void) return -7400; /* Certificate with Name Constraints extension. */ -#ifdef FREESCALE_MQX - file = XFOPEN(".\\certs\\test\\cert-ext-nc.der", "rb"); -#else - file = XFOPEN("./certs/test/cert-ext-nc.der", "rb"); -#endif + file = XFOPEN(certExtNc, "rb"); if (!file) { ERROR_OUT(-7401, done); } @@ -12498,11 +12504,7 @@ WOLFSSL_TEST_SUBROUTINE int cert_test(void) FreeDecodedCert(&cert); /* Certificate with Inhibit Any Policy extension. */ -#ifdef FREESCALE_MQX - file = XFOPEN(".\\certs\\test\\cert-ext-ia.der", "rb"); -#else - file = XFOPEN("./certs/test/cert-ext-ia.der", "rb"); -#endif + file = XFOPEN(certExtIa, "rb"); if (!file) { ERROR_OUT(-7403, done); } @@ -12516,11 +12518,7 @@ WOLFSSL_TEST_SUBROUTINE int cert_test(void) FreeDecodedCert(&cert); /* Certificate with Netscape Certificate Type extension. */ -#ifdef FREESCALE_MQX - file = XFOPEN(".\\certs\\test\\cert-ext-nct.der", "rb"); -#else - file = XFOPEN("./certs/test/cert-ext-nct.der", "rb"); -#endif + file = XFOPEN(certExtNct, "rb"); if (!file) { ERROR_OUT(-7405, done); } @@ -23047,7 +23045,7 @@ static int ecc_def_curve_test(WC_RNG *rng) sizeof_ecc_key_der_256); #else { - XFILE file = XFOPEN("./certs/ecc-key.der", "rb"); + XFILE file = XFOPEN(eccKeyDerFile, "rb"); byte der[128]; word32 derSz; if (!file) { From 15c5ac880e7ac66cead05aba7a54169874e1137e Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 12 Jan 2022 14:40:46 -0800 Subject: [PATCH 2/2] PKCS7 Test Output When running the test with PKCS7 enabled, there's an additional option that will save to disk the generated PKCS7 blobs for by-hand review. (PKCS7_OUTPUT_TEST_BUNDLES) Fixed a couple compile errors that were missed with that option enabled. --- wolfcrypt/test/test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index cd96e0b73..bf7db60b1 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -33702,6 +33702,7 @@ static int pkcs7signed_run_vectors( file = XFOPEN(testVectors[i].outFileName, "wb"); if (!file) { ERROR_OUT(-12523, out); + } ret = (int)XFWRITE(out, 1, encodedSz, file); XFCLOSE(file); if (ret != (int)encodedSz) @@ -34202,7 +34203,7 @@ static int pkcs7signed_run_SingleShotVectors( XFCLOSE(file); file = NULL; if (ret != (int)encodedSz) - ERROR_OUT(-12553); + ERROR_OUT(-12553, out); #endif /* PKCS7_OUTPUT_TEST_BUNDLES */ wc_PKCS7_Free(pkcs7);