Hi Anika,
wolfCrypt's CMS/PKCS#7 API's do not currently have the ability to extract signer certificates without calling wc_PKCS7_VerifySignedData() first. This API parses the CMS/PKCS#7 bundle ASN.1 and extracts details into our own wolfCrypt structure, in addition to then trying to verify the signature. If you did not care about the verification result, you could call this API, check/ignore the return value of SIG_VERIFY_E, then proceed to get the signer certificates from the pkcs7->certs[] array, using the pkcs7->certSz[] size array for array sizes.
Pseudocode would look something similar to:
ret = wc_PKCS7_VerifySignedData(pkcs7, in, inSz);
if (ret < 0 && ret != SIG_VERIFY_E) {
/* other error, parsing, etc */
}
/* loop over pkcs7->cert[], where pkcs7->certSz[] holds sizes for each cert */
for (i = 0; i < MAX_PKCS7_CERTS; i++) {
if (pkcs7->certSz[i] > 0) {
/* pkcs7->cert[i] holds ith cert from SignedData bundle */
}
}
Best Regards,
Chris