Is it possible to parse and retrieve information from a PKCS #7 Enveloped Data without having access to the private key (corresponding to the certificate used for encryption) ?
I would like to see information like:
  RecipientInfo.issuerAndSerialNumber
  RecipientInfo.KeyEncryptionAlgorithmIdentifier
  RecipientInfo.EncryptedKey
  EncryptedContentInfo.ContentEncryptionAlgorithm
  ...
contained in the PKCS #7 structure.
 

Here is a part of my code:
    (derData is a SECItem structure containing the PKCS #7 Enveloped Data)

SEC_PKCS7ContentInfo *cinfo = NULL;
SEC_PKCS7DecoderContext *dcx = NULL;
SECStatus rv;

dcx = SEC_PKCS7DecoderStart(CallBackFunc, &CallBackArgs, NULL, NULL, NULL, NULL, DecryptionAllowed);
if (dcx == NULL)
{
    exit�
}

rv = SEC_PKCS7DecoderUpdate(dcx, (const char *)derData.data, derData.len);
if (rv != SECSuccess)
{
    exit�
}

cinfo = SEC_PKCS7DecoderFinish(dcx);
if (cinfo == NULL)
{
    exit�
}

with:
    PRBool DecryptionAllowed(SECAlgorithmID *a_AlgID, PK11SymKey *a_pKey)
    {
        return PR_TRUE;
    }
 
 

SEC_PKCS7DecoderStart is OK.
SEC_PKCS7DecoderUpdate returns SECFailure (dcx.error = -8147 / SEC_ERROR_NOT_A_RECIPIENT)
 

Any idea ?  How to do/solve that ?

Thanks in advance,
J.

Reply via email to