mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
Merge pull request #3326 from ethanlooney/25th_branch
Added unit tests for PKCS7
This commit is contained in:
72
tests/api.c
72
tests/api.c
@ -23725,7 +23725,75 @@ static void test_PKCS7_signed_enveloped(void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
static void test_wc_PKCS7_NoDefaultSignedAttribs (void)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \
|
||||||
|
&& !defined(NO_AES)
|
||||||
|
PKCS7* pkcs7;
|
||||||
|
void* heap = NULL;
|
||||||
|
|
||||||
|
printf(testingFmt, "wc_PKCS7_NoDefaultSignedAttribs()");
|
||||||
|
|
||||||
|
pkcs7 = wc_PKCS7_New(heap, devId);
|
||||||
|
AssertNotNull(pkcs7);
|
||||||
|
AssertIntEQ(wc_PKCS7_Init(pkcs7, heap, devId), 0);
|
||||||
|
|
||||||
|
AssertIntEQ(wc_PKCS7_NoDefaultSignedAttribs(NULL), BAD_FUNC_ARG);
|
||||||
|
|
||||||
|
AssertIntEQ(wc_PKCS7_NoDefaultSignedAttribs(pkcs7), 0);
|
||||||
|
|
||||||
|
wc_PKCS7_Free(pkcs7);
|
||||||
|
|
||||||
|
printf(resultFmt, passed);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
static void test_wc_PKCS7_SetOriEncryptCtx (void)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \
|
||||||
|
&& !defined(NO_AES)
|
||||||
|
PKCS7* pkcs7;
|
||||||
|
void* heap = NULL;
|
||||||
|
WOLFSSL_CTX* ctx;
|
||||||
|
ctx = NULL;
|
||||||
|
|
||||||
|
printf(testingFmt, "wc_PKCS7_SetOriEncryptCtx()");
|
||||||
|
|
||||||
|
pkcs7 = wc_PKCS7_New(heap, devId);
|
||||||
|
AssertNotNull(pkcs7);
|
||||||
|
AssertIntEQ(wc_PKCS7_Init(pkcs7, heap, devId), 0);
|
||||||
|
|
||||||
|
AssertIntEQ(wc_PKCS7_SetOriEncryptCtx(NULL, ctx), BAD_FUNC_ARG);
|
||||||
|
|
||||||
|
AssertIntEQ(wc_PKCS7_SetOriEncryptCtx(pkcs7, ctx), 0);
|
||||||
|
|
||||||
|
wc_PKCS7_Free(pkcs7);
|
||||||
|
|
||||||
|
printf(resultFmt, passed);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
static void test_wc_PKCS7_SetOriDecryptCtx (void)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_PKCS7) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) \
|
||||||
|
&& !defined(NO_AES)
|
||||||
|
PKCS7* pkcs7;
|
||||||
|
void* heap = NULL;
|
||||||
|
WOLFSSL_CTX* ctx;
|
||||||
|
ctx = NULL;
|
||||||
|
|
||||||
|
printf(testingFmt, "wc_PKCS7_SetOriDecryptCtx()");
|
||||||
|
|
||||||
|
pkcs7 = wc_PKCS7_New(heap, devId);
|
||||||
|
AssertNotNull(pkcs7);
|
||||||
|
AssertIntEQ(wc_PKCS7_Init(pkcs7, heap, devId), 0);
|
||||||
|
|
||||||
|
AssertIntEQ(wc_PKCS7_SetOriDecryptCtx(NULL, ctx), BAD_FUNC_ARG);
|
||||||
|
|
||||||
|
AssertIntEQ(wc_PKCS7_SetOriDecryptCtx(pkcs7, ctx), 0);
|
||||||
|
|
||||||
|
wc_PKCS7_Free(pkcs7);
|
||||||
|
printf(resultFmt, passed);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
static void test_wc_i2d_PKCS12(void)
|
static void test_wc_i2d_PKCS12(void)
|
||||||
{
|
{
|
||||||
#if !defined(NO_ASN) && !defined(NO_PWDBASED) && defined(HAVE_PKCS12) \
|
#if !defined(NO_ASN) && !defined(NO_PWDBASED) && defined(HAVE_PKCS12) \
|
||||||
@ -37541,6 +37609,10 @@ void ApiTest(void)
|
|||||||
test_wc_PKCS7_Degenerate();
|
test_wc_PKCS7_Degenerate();
|
||||||
test_wc_PKCS7_BER();
|
test_wc_PKCS7_BER();
|
||||||
test_PKCS7_signed_enveloped();
|
test_PKCS7_signed_enveloped();
|
||||||
|
test_wc_PKCS7_NoDefaultSignedAttribs();
|
||||||
|
test_wc_PKCS7_SetOriEncryptCtx();
|
||||||
|
test_wc_PKCS7_SetOriDecryptCtx();
|
||||||
|
|
||||||
|
|
||||||
test_wc_i2d_PKCS12();
|
test_wc_i2d_PKCS12();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user