mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-04 21:24:43 +02:00
update test.c error returns for PKCS7
This commit is contained in:
committed by
David Garske
parent
06a6f8400b
commit
4315384051
@@ -19225,14 +19225,14 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (pkcs7 == NULL)
|
if (pkcs7 == NULL)
|
||||||
return -9214;
|
return -9310;
|
||||||
|
|
||||||
if (testVectors[i].secretKey != NULL) {
|
if (testVectors[i].secretKey != NULL) {
|
||||||
/* KEKRI recipient type */
|
/* KEKRI recipient type */
|
||||||
|
|
||||||
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return -9215;
|
return -9311;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->content = (byte*)testVectors[i].content;
|
pkcs7->content = (byte*)testVectors[i].content;
|
||||||
@@ -19251,7 +19251,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9216;
|
return -9313;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set key, for decryption */
|
/* set key, for decryption */
|
||||||
@@ -19260,7 +19260,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9217;
|
return -9314;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (testVectors[i].password != NULL) {
|
} else if (testVectors[i].password != NULL) {
|
||||||
@@ -19268,7 +19268,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return -9218;
|
return -9315;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->content = (byte*)testVectors[i].content;
|
pkcs7->content = (byte*)testVectors[i].content;
|
||||||
@@ -19287,7 +19287,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9219;
|
return -9316;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set password, for decryption */
|
/* set password, for decryption */
|
||||||
@@ -19296,7 +19296,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9220;
|
return -9317;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (testVectors[i].isOri == 1) {
|
} else if (testVectors[i].isOri == 1) {
|
||||||
@@ -19304,7 +19304,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return -9221;
|
return -9318;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->content = (byte*)testVectors[i].content;
|
pkcs7->content = (byte*)testVectors[i].content;
|
||||||
@@ -19317,7 +19317,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9222;
|
return -9319;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set decrypt callback for decryption */
|
/* set decrypt callback for decryption */
|
||||||
@@ -19325,7 +19325,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9223;
|
return -9320;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -19335,7 +19335,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
(word32)testVectors[i].certSz);
|
(word32)testVectors[i].certSz);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9224;
|
return -9321;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->keyWrapOID = testVectors[i].keyWrapOID;
|
pkcs7->keyWrapOID = testVectors[i].keyWrapOID;
|
||||||
@@ -19355,7 +19355,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
ret = wc_PKCS7_SetSignerIdentifierType(pkcs7, CMS_SKID);
|
ret = wc_PKCS7_SetSignerIdentifierType(pkcs7, CMS_SKID);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9225;
|
return -9322;
|
||||||
}
|
}
|
||||||
} else if (testVectors[i].ktriOptions &
|
} else if (testVectors[i].ktriOptions &
|
||||||
CMS_ISSUER_AND_SERIAL_NUMBER) {
|
CMS_ISSUER_AND_SERIAL_NUMBER) {
|
||||||
@@ -19364,7 +19364,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
CMS_ISSUER_AND_SERIAL_NUMBER);
|
CMS_ISSUER_AND_SERIAL_NUMBER);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9225;
|
return -9323;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19374,7 +19374,7 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
sizeof(enveloped));
|
sizeof(enveloped));
|
||||||
if (envelopedSz <= 0) {
|
if (envelopedSz <= 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9225;
|
return -9324;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode envelopedData */
|
/* decode envelopedData */
|
||||||
@@ -19382,13 +19382,13 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
decoded, sizeof(decoded));
|
decoded, sizeof(decoded));
|
||||||
if (decodedSz <= 0) {
|
if (decodedSz <= 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9226;
|
return -9325;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test decode result */
|
/* test decode result */
|
||||||
if (XMEMCMP(decoded, data, sizeof(data)) != 0){
|
if (XMEMCMP(decoded, data, sizeof(data)) != 0){
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9227;
|
return -9326;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
||||||
@@ -19396,14 +19396,14 @@ static int pkcs7enveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
pkcs7File = fopen(testVectors[i].outFileName, "wb");
|
pkcs7File = fopen(testVectors[i].outFileName, "wb");
|
||||||
if (!pkcs7File) {
|
if (!pkcs7File) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9228;
|
return -9327;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (int)fwrite(enveloped, 1, envelopedSz, pkcs7File);
|
ret = (int)fwrite(enveloped, 1, envelopedSz, pkcs7File);
|
||||||
fclose(pkcs7File);
|
fclose(pkcs7File);
|
||||||
if (ret != envelopedSz) {
|
if (ret != envelopedSz) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9229;
|
return -9328;
|
||||||
}
|
}
|
||||||
#endif /* PKCS7_OUTPUT_TEST_BUNDLES */
|
#endif /* PKCS7_OUTPUT_TEST_BUNDLES */
|
||||||
|
|
||||||
@@ -19497,7 +19497,7 @@ int pkcs7enveloped_test(void)
|
|||||||
XFREE(eccCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(eccCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(eccPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(eccPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return -9304;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pkcs7enveloped_run_vectors(rsaCert, (word32)rsaCertSz,
|
ret = pkcs7enveloped_run_vectors(rsaCert, (word32)rsaCertSz,
|
||||||
@@ -19742,14 +19742,14 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if (pkcs7 == NULL)
|
if (pkcs7 == NULL)
|
||||||
return -9214;
|
return -9370;
|
||||||
|
|
||||||
if (testVectors[i].secretKey != NULL) {
|
if (testVectors[i].secretKey != NULL) {
|
||||||
/* KEKRI recipient type */
|
/* KEKRI recipient type */
|
||||||
|
|
||||||
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return -9215;
|
return -9371;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->content = (byte*)testVectors[i].content;
|
pkcs7->content = (byte*)testVectors[i].content;
|
||||||
@@ -19768,7 +19768,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9216;
|
return -9372;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set key, for decryption */
|
/* set key, for decryption */
|
||||||
@@ -19777,7 +19777,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9217;
|
return -9373;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (testVectors[i].password != NULL) {
|
} else if (testVectors[i].password != NULL) {
|
||||||
@@ -19785,7 +19785,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return -9218;
|
return -9374;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->content = (byte*)testVectors[i].content;
|
pkcs7->content = (byte*)testVectors[i].content;
|
||||||
@@ -19804,7 +19804,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9219;
|
return -9375;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set password, for decryption */
|
/* set password, for decryption */
|
||||||
@@ -19813,7 +19813,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9220;
|
return -9376;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (testVectors[i].isOri == 1) {
|
} else if (testVectors[i].isOri == 1) {
|
||||||
@@ -19821,7 +19821,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
ret = wc_PKCS7_Init(pkcs7, pkcs7->heap, pkcs7->devId);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return -9221;
|
return -9377;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->content = (byte*)testVectors[i].content;
|
pkcs7->content = (byte*)testVectors[i].content;
|
||||||
@@ -19834,7 +19834,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9222;
|
return -9378;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set decrypt callback for decryption */
|
/* set decrypt callback for decryption */
|
||||||
@@ -19842,7 +19842,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9223;
|
return -9379;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -19852,7 +19852,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
(word32)testVectors[i].certSz);
|
(word32)testVectors[i].certSz);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9224;
|
return -9380;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkcs7->keyWrapOID = testVectors[i].keyWrapOID;
|
pkcs7->keyWrapOID = testVectors[i].keyWrapOID;
|
||||||
@@ -19872,7 +19872,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
ret = wc_PKCS7_SetSignerIdentifierType(pkcs7, CMS_SKID);
|
ret = wc_PKCS7_SetSignerIdentifierType(pkcs7, CMS_SKID);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9225;
|
return -9381;
|
||||||
}
|
}
|
||||||
} else if (testVectors[i].ktriOptions &
|
} else if (testVectors[i].ktriOptions &
|
||||||
CMS_ISSUER_AND_SERIAL_NUMBER) {
|
CMS_ISSUER_AND_SERIAL_NUMBER) {
|
||||||
@@ -19881,7 +19881,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
CMS_ISSUER_AND_SERIAL_NUMBER);
|
CMS_ISSUER_AND_SERIAL_NUMBER);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9225;
|
return -9382;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19891,7 +19891,7 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
sizeof(enveloped));
|
sizeof(enveloped));
|
||||||
if (envelopedSz <= 0) {
|
if (envelopedSz <= 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9226;
|
return -9383;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode envelopedData */
|
/* decode envelopedData */
|
||||||
@@ -19900,13 +19900,13 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
sizeof(decoded));
|
sizeof(decoded));
|
||||||
if (decodedSz <= 0) {
|
if (decodedSz <= 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9226;
|
return -9384;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test decode result */
|
/* test decode result */
|
||||||
if (XMEMCMP(decoded, data, sizeof(data)) != 0){
|
if (XMEMCMP(decoded, data, sizeof(data)) != 0){
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9227;
|
return -9385;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
||||||
@@ -19914,14 +19914,14 @@ static int pkcs7authenveloped_run_vectors(byte* rsaCert, word32 rsaCertSz,
|
|||||||
pkcs7File = fopen(testVectors[i].outFileName, "wb");
|
pkcs7File = fopen(testVectors[i].outFileName, "wb");
|
||||||
if (!pkcs7File) {
|
if (!pkcs7File) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9228;
|
return -9386;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (int)fwrite(enveloped, 1, envelopedSz, pkcs7File);
|
ret = (int)fwrite(enveloped, 1, envelopedSz, pkcs7File);
|
||||||
fclose(pkcs7File);
|
fclose(pkcs7File);
|
||||||
if (ret != envelopedSz) {
|
if (ret != envelopedSz) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9229;
|
return -9387;
|
||||||
}
|
}
|
||||||
#endif /* PKCS7_OUTPUT_TEST_BUNDLES */
|
#endif /* PKCS7_OUTPUT_TEST_BUNDLES */
|
||||||
|
|
||||||
@@ -19965,12 +19965,12 @@ int pkcs7authenveloped_test(void)
|
|||||||
/* read client RSA cert and key in DER format */
|
/* read client RSA cert and key in DER format */
|
||||||
rsaCert = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
rsaCert = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (rsaCert == NULL)
|
if (rsaCert == NULL)
|
||||||
return -9300;
|
return -9360;
|
||||||
|
|
||||||
rsaPrivKey = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
rsaPrivKey = (byte*)XMALLOC(FOURK_BUF, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (rsaPrivKey == NULL) {
|
if (rsaPrivKey == NULL) {
|
||||||
XFREE(rsaCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(rsaCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
return -9301;
|
return -9361;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsaCertSz = FOURK_BUF;
|
rsaCertSz = FOURK_BUF;
|
||||||
@@ -19985,7 +19985,7 @@ int pkcs7authenveloped_test(void)
|
|||||||
XFREE(rsaCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(rsaCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(rsaPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(rsaPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
return -9302;
|
return -9362;
|
||||||
}
|
}
|
||||||
|
|
||||||
eccPrivKey =(byte*)XMALLOC(FOURK_BUF, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
eccPrivKey =(byte*)XMALLOC(FOURK_BUF, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
@@ -19995,7 +19995,7 @@ int pkcs7authenveloped_test(void)
|
|||||||
XFREE(rsaPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(rsaPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
XFREE(eccCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(eccCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
return -9303;
|
return -9363;
|
||||||
}
|
}
|
||||||
|
|
||||||
eccCertSz = FOURK_BUF;
|
eccCertSz = FOURK_BUF;
|
||||||
@@ -20015,7 +20015,7 @@ int pkcs7authenveloped_test(void)
|
|||||||
XFREE(eccCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(eccCert, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(eccPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(eccPrivKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return -9364;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pkcs7authenveloped_run_vectors(rsaCert, (word32)rsaCertSz,
|
ret = pkcs7authenveloped_run_vectors(rsaCert, (word32)rsaCertSz,
|
||||||
@@ -20314,7 +20314,7 @@ int pkcs7compressed_test(void)
|
|||||||
for (i = 0; i < testSz; i++) {
|
for (i = 0; i < testSz; i++) {
|
||||||
pkcs7 = wc_PKCS7_New(HEAP_HINT, devId);
|
pkcs7 = wc_PKCS7_New(HEAP_HINT, devId);
|
||||||
if (pkcs7 == NULL)
|
if (pkcs7 == NULL)
|
||||||
return -9400;
|
return -9450;
|
||||||
|
|
||||||
pkcs7->content = (byte*)testVectors[i].content;
|
pkcs7->content = (byte*)testVectors[i].content;
|
||||||
pkcs7->contentSz = testVectors[i].contentSz;
|
pkcs7->contentSz = testVectors[i].contentSz;
|
||||||
@@ -20325,7 +20325,7 @@ int pkcs7compressed_test(void)
|
|||||||
sizeof(compressed));
|
sizeof(compressed));
|
||||||
if (compressedSz <= 0) {
|
if (compressedSz <= 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9408;
|
return -9451;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode compressedData */
|
/* decode compressedData */
|
||||||
@@ -20334,26 +20334,26 @@ int pkcs7compressed_test(void)
|
|||||||
sizeof(decoded));
|
sizeof(decoded));
|
||||||
if (decodedSz <= 0){
|
if (decodedSz <= 0){
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9409;
|
return -9452;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test decode result */
|
/* test decode result */
|
||||||
if (XMEMCMP(decoded, testVectors[i].content,
|
if (XMEMCMP(decoded, testVectors[i].content,
|
||||||
testVectors[i].contentSz) != 0) {
|
testVectors[i].contentSz) != 0) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9410;
|
return -9453;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure content type is the same */
|
/* make sure content type is the same */
|
||||||
if (testVectors[i].contentOID != pkcs7->contentOID)
|
if (testVectors[i].contentOID != pkcs7->contentOID)
|
||||||
return -9411;
|
return -9454;
|
||||||
|
|
||||||
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
||||||
/* output pkcs7 compressedData for external testing */
|
/* output pkcs7 compressedData for external testing */
|
||||||
pkcs7File = fopen(testVectors[i].outFileName, "wb");
|
pkcs7File = fopen(testVectors[i].outFileName, "wb");
|
||||||
if (!pkcs7File) {
|
if (!pkcs7File) {
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9412;
|
return -9455;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (int)fwrite(compressed, compressedSz, 1, pkcs7File);
|
ret = (int)fwrite(compressed, compressedSz, 1, pkcs7File);
|
||||||
@@ -20593,14 +20593,14 @@ static int pkcs7signed_run_vectors(
|
|||||||
outSz = FOURK_BUF;
|
outSz = FOURK_BUF;
|
||||||
out = (byte*)XMALLOC(outSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
out = (byte*)XMALLOC(outSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return -9413;
|
return -9510;
|
||||||
|
|
||||||
XMEMSET(out, 0, outSz);
|
XMEMSET(out, 0, outSz);
|
||||||
|
|
||||||
ret = wc_PKCS7_PadData((byte*)data, sizeof(data), out, outSz, 16);
|
ret = wc_PKCS7_PadData((byte*)data, sizeof(data), out, outSz, 16);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
return -9414;
|
return -9511;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_FIPS
|
#ifndef HAVE_FIPS
|
||||||
@@ -20610,13 +20610,13 @@ static int pkcs7signed_run_vectors(
|
|||||||
#endif
|
#endif
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
return -9415;
|
return -9512;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < testSz; i++) {
|
for (i = 0; i < testSz; i++) {
|
||||||
pkcs7 = wc_PKCS7_New(HEAP_HINT, INVALID_DEVID);
|
pkcs7 = wc_PKCS7_New(HEAP_HINT, INVALID_DEVID);
|
||||||
if (pkcs7 == NULL)
|
if (pkcs7 == NULL)
|
||||||
return -9416;
|
return -9513;
|
||||||
|
|
||||||
pkcs7->heap = HEAP_HINT;
|
pkcs7->heap = HEAP_HINT;
|
||||||
pkcs7->devId = INVALID_DEVID;
|
pkcs7->devId = INVALID_DEVID;
|
||||||
@@ -20626,7 +20626,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9417;
|
return -9514;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load CA certificate, if present */
|
/* load CA certificate, if present */
|
||||||
@@ -20636,7 +20636,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9418;
|
return -9515;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20659,7 +20659,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9419;
|
return -9516;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20670,7 +20670,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9420;
|
return -9517;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20683,7 +20683,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9421;
|
return -9518;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20706,7 +20706,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9422;
|
return -9519;
|
||||||
}
|
}
|
||||||
wc_ShaUpdate(&sha, pkcs7->publicKey, pkcs7->publicKeySz);
|
wc_ShaUpdate(&sha, pkcs7->publicKey, pkcs7->publicKeySz);
|
||||||
wc_ShaFinal(&sha, digest);
|
wc_ShaFinal(&sha, digest);
|
||||||
@@ -20716,7 +20716,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9423;
|
return -9520;
|
||||||
}
|
}
|
||||||
wc_Sha256Update(&sha, pkcs7->publicKey, pkcs7->publicKeySz);
|
wc_Sha256Update(&sha, pkcs7->publicKey, pkcs7->publicKeySz);
|
||||||
wc_Sha256Final(&sha, digest);
|
wc_Sha256Final(&sha, digest);
|
||||||
@@ -20732,7 +20732,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (encodedSz < 0) {
|
if (encodedSz < 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9424;
|
return -9521;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
#ifdef PKCS7_OUTPUT_TEST_BUNDLES
|
||||||
@@ -20741,14 +20741,14 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (!file) {
|
if (!file) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9425;
|
return -9522;
|
||||||
}
|
}
|
||||||
ret = (int)fwrite(out, 1, encodedSz, file);
|
ret = (int)fwrite(out, 1, encodedSz, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
if (ret != (int)encodedSz) {
|
if (ret != (int)encodedSz) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9426;
|
return -9526;
|
||||||
}
|
}
|
||||||
#endif /* PKCS7_OUTPUT_TEST_BUNDLES */
|
#endif /* PKCS7_OUTPUT_TEST_BUNDLES */
|
||||||
|
|
||||||
@@ -20756,30 +20756,30 @@ static int pkcs7signed_run_vectors(
|
|||||||
|
|
||||||
pkcs7 = wc_PKCS7_New(HEAP_HINT, INVALID_DEVID);
|
pkcs7 = wc_PKCS7_New(HEAP_HINT, INVALID_DEVID);
|
||||||
if (pkcs7 == NULL)
|
if (pkcs7 == NULL)
|
||||||
return -9427;
|
return -9527;
|
||||||
wc_PKCS7_InitWithCert(pkcs7, NULL, 0);
|
wc_PKCS7_InitWithCert(pkcs7, NULL, 0);
|
||||||
|
|
||||||
ret = wc_PKCS7_VerifySignedData(pkcs7, out, outSz);
|
ret = wc_PKCS7_VerifySignedData(pkcs7, out, outSz);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9428;
|
return -9528;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* verify contentType extracted successfully for custom content types */
|
/* verify contentType extracted successfully for custom content types */
|
||||||
if (testVectors[i].contentTypeSz > 0) {
|
if (testVectors[i].contentTypeSz > 0) {
|
||||||
if (pkcs7->contentTypeSz != testVectors[i].contentTypeSz) {
|
if (pkcs7->contentTypeSz != testVectors[i].contentTypeSz) {
|
||||||
return -9429;
|
return -9529;
|
||||||
} else if (XMEMCMP(pkcs7->contentType, testVectors[i].contentType,
|
} else if (XMEMCMP(pkcs7->contentType, testVectors[i].contentType,
|
||||||
pkcs7->contentTypeSz) != 0) {
|
pkcs7->contentTypeSz) != 0) {
|
||||||
return -9430;
|
return -9530;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pkcs7->singleCert == NULL || pkcs7->singleCertSz == 0) {
|
if (pkcs7->singleCert == NULL || pkcs7->singleCertSz == 0) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9431;
|
return -9531;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -20798,13 +20798,13 @@ static int pkcs7signed_run_vectors(
|
|||||||
NULL, (word32*)&bufSz) != LENGTH_ONLY_E) {
|
NULL, (word32*)&bufSz) != LENGTH_ONLY_E) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9432;
|
return -9532;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufSz > (int)sizeof(buf)) {
|
if (bufSz > (int)sizeof(buf)) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9433;
|
return -9533;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufSz = wc_PKCS7_GetAttributeValue(pkcs7, oidPt, oidSz,
|
bufSz = wc_PKCS7_GetAttributeValue(pkcs7, oidPt, oidSz,
|
||||||
@@ -20813,7 +20813,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
(testVectors[i].signedAttribs == NULL && bufSz > 0)) {
|
(testVectors[i].signedAttribs == NULL && bufSz > 0)) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9434;
|
return -9534;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20822,7 +20822,7 @@ static int pkcs7signed_run_vectors(
|
|||||||
if (!file) {
|
if (!file) {
|
||||||
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(out, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
wc_PKCS7_Free(pkcs7);
|
wc_PKCS7_Free(pkcs7);
|
||||||
return -9435;
|
return -9535;
|
||||||
}
|
}
|
||||||
ret = (int)fwrite(pkcs7->singleCert, 1, pkcs7->singleCertSz, file);
|
ret = (int)fwrite(pkcs7->singleCert, 1, pkcs7->singleCertSz, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@@ -20978,7 +20978,7 @@ int pkcs7signed_test(void)
|
|||||||
XFREE(rsaClientPrivKeyBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(rsaClientPrivKeyBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(eccClientCertBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(eccClientCertBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(eccClientPrivKeyBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(eccClientPrivKeyBuf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
return ret;
|
return -9508;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pkcs7signed_run_vectors(rsaClientCertBuf, (word32)rsaClientCertBufSz,
|
ret = pkcs7signed_run_vectors(rsaClientCertBuf, (word32)rsaClientCertBufSz,
|
||||||
|
Reference in New Issue
Block a user