diff --git a/ctaocrypt/src/pkcs7.c b/ctaocrypt/src/pkcs7.c index 48b5adf5f..b442dce30 100644 --- a/ctaocrypt/src/pkcs7.c +++ b/ctaocrypt/src/pkcs7.c @@ -177,6 +177,13 @@ int PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz) } +/* releases any memory allocated by a PKCS7 initializer */ +void PKCS7_Free(PKCS7* pkcs7) +{ + (void)pkcs7; +} + + /* build PKCS#7 data content type */ int PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz) { diff --git a/ctaocrypt/test/test.c b/ctaocrypt/test/test.c index 80fb90e06..b1fbaa6b5 100644 --- a/ctaocrypt/test/test.c +++ b/ctaocrypt/test/test.c @@ -4114,6 +4114,7 @@ int pkcs7enveloped_test(void) free(cert); free(privKey); + PKCS7_Free(&pkcs7); if (ret > 0) return 0; @@ -4233,6 +4234,10 @@ int pkcs7signed_test(void) } ret = PKCS7_EncodeSignedData(&msg, out, outSz); if (ret < 0) { + free(certDer); + free(keyDer); + free(out); + PKCS7_Free(&msg); return -210; } else @@ -4244,6 +4249,7 @@ int pkcs7signed_test(void) free(certDer); free(keyDer); free(out); + PKCS7_Free(&msg); return -211; } ret = (int)fwrite(out, outSz, 1, file); @@ -4252,6 +4258,7 @@ int pkcs7signed_test(void) free(certDer); free(keyDer); free(out); + PKCS7_Free(&msg); if (ret > 0) return 0; diff --git a/cyassl/ctaocrypt/pkcs7.h b/cyassl/ctaocrypt/pkcs7.h index f060dc11d..0ea781774 100644 --- a/cyassl/ctaocrypt/pkcs7.h +++ b/cyassl/ctaocrypt/pkcs7.h @@ -99,6 +99,7 @@ CYASSL_LOCAL int CreateRecipientInfo(const byte* cert, word32 certSz, int* keyEncSz, byte* out, word32 outSz); CYASSL_API int PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz); +CYASSL_API void PKCS7_Free(PKCS7* pkcs7); CYASSL_API int PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz); CYASSL_API int PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz);