add store of PKCS7 cert used for verify

This commit is contained in:
Jacob Barthelmeh 2022-04-22 11:26:34 -06:00
parent 4a4b019e30
commit d5927a58dd
3 changed files with 15 additions and 1 deletions

View File

@ -47528,6 +47528,14 @@ static void test_wolfSSL_PKCS7_sign(void)
AssertNotNull(p7Ver = wc_PKCS7_New(HEAP_HINT, devId));
AssertIntEQ(wc_PKCS7_Init(p7Ver, HEAP_HINT, INVALID_DEVID), 0);
AssertIntEQ(wc_PKCS7_VerifySignedData(p7Ver, out, outLen), 0);
/* compare the signer found to expected signer */
AssertIntNE(p7Ver->verifyCertSz, 0);
tmpPtr = NULL;
AssertIntEQ(i2d_X509(signCert, &tmpPtr), p7Ver->verifyCertSz);
AssertIntEQ(XMEMCMP(tmpPtr, p7Ver->verifyCert, p7Ver->verifyCertSz), 0);
free(tmpPtr);
wc_PKCS7_Free(p7Ver);
AssertNotNull(out);

View File

@ -3409,6 +3409,8 @@ static int wc_PKCS7_RsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
if (XMEMCMP(digest, hash, hashSz) == 0) {
/* found signer that successfully verified signature */
verified = 1;
pkcs7->verifyCert = pkcs7->cert[i];
pkcs7->verifyCertSz = pkcs7->certSz[i];
break;
}
}
@ -3532,6 +3534,8 @@ static int wc_PKCS7_EcdsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
if (ret == 0 && res == 1) {
/* found signer that successfully verified signature */
verified = 1;
pkcs7->verifyCert = pkcs7->cert[i];
pkcs7->verifyCertSz = pkcs7->certSz[i];
break;
}
}

View File

@ -241,7 +241,9 @@ struct PKCS7 {
byte* der; /* DER encoded version of message */
word32 derSz;
#endif
byte* cert[MAX_PKCS7_CERTS];
byte* cert[MAX_PKCS7_CERTS]; /* array of certs parsed from bundle */
byte* verifyCert; /* cert from array used for verify */
word32 verifyCertSz;
/* Encrypted-data Content Type */
byte* encryptionKey; /* block cipher encryption key */