19 #ifndef __PKCS7_HEADER__ 20 #define __PKCS7_HEADER__ 29 #define PKCS7_EXTERNAL_SIGNATURES 0x01 39 enum encryptedContentType;
233 struct ASN1_ITEM* pSerialNumber,
234 struct ASN1_ITEM* pIssuerName,
235 struct AsymmetricKey* pKey);
284 struct ASN1_ITEM* pCertificate,
335 struct ASN1_ITEM* pSerialNumber,
336 struct ASN1_ITEM* pIssuerName,
337 ubyte** ppCertificate,
338 ubyte4* certificateLen);
361 #ifdef __ENABLE_MOCANA_PKCS7__ 410 struct ASN1_ITEM** ppFirstCertificate);
501 struct ASN1_ITEM* pSignedData, CStream s,
505 const void* callbackArg,
508 const ubyte* payLoad,
510 sbyte4* numKnownSigners);
600 struct ASN1_ITEM* pEnvelopedData, CStream s,
601 const void* callbackArg,
603 enum encryptedContentType* pType,
604 struct ASN1_ITEM** ppEncryptedContent,
654 struct ASN1_ITEM* pEnvelopedData, CStream s,
655 const void* callbackArg,
657 ubyte** decryptedInfo, sbyte4* decryptedInfoLen);
758 struct DER_ITEM* pStart,
759 struct DER_ITEM* pParent,
760 struct ASN1_ITEM* pCACertificatesParseRoots[],
763 const ubyte* encryptAlgoOID,
764 RNGFun rngFun,
void* rngFunArg,
765 const ubyte* pPayLoad, ubyte4 payLoadLen,
766 ubyte** ppEnveloped, ubyte4* pEnvelopedLen);
846 struct DER_ITEM* pStart,
847 struct DER_ITEM* pParent,
848 struct ASN1_ITEM* pCACertificatesParseRoots[],
851 const ubyte* encryptAlgoOID,
852 RNGFun rngFun,
void* rngFunArg,
853 ubyte isOaep, ubyte4 oaepHashAlgo, sbyte *pOaepLabel,
854 const ubyte* pPayLoad, ubyte4 payLoadLen,
855 ubyte** ppEnveloped, ubyte4* pEnvelopedLen);
995 struct DER_ITEM* pStart,
996 struct DER_ITEM* pParent,
997 struct ASN1_ITEM* pCACertificatesParseRoots[],
998 CStream pCAStreams[], sbyte4 numCACerts,
999 struct ASN1_ITEM* pCrlsParseRoots[],
1000 CStream pCrlStreams[], sbyte4 numCrls,
1001 signerInfoPtr *pSignerInfos,
1003 const ubyte* payLoadType,
1004 const ubyte* pPayLoad, ubyte4 payLoadLen,
1007 ubyte** ppSigned, ubyte4* pSignedLen);
1095 struct DER_ITEM* pStart,
1096 struct DER_ITEM* pParent,
1097 const ubyte* payLoadType,
1099 const ubyte* pPayLoad, ubyte4 payLoadLen,
1100 ubyte** ppDigested, ubyte4* pDigestedLen);
1266 struct ASN1_ITEM* *ppFirstSignedAttribute);
1310 struct ASN1_ITEM* *ppFirstUnsignedAttribute);
1319 confirmRequired = 5,
1324 typedef struct cmcSignerInfo {
1333 struct ASN1_ITEM* pSubjectKeyIdentifier;
1337 typedef struct CertsData
1343 typedef struct taggedContent
1349 typedef struct taggedAttribute
1352 ubyte *pAttributeTypeOid;
1353 taggedContent *pTaggedAttributeValues;
1354 ubyte4 numAttributeValues;
1357 typedef struct taggedContentInfo
1361 taggedContent *pTaggedContentInfo;
1362 } taggedContentInfo;
1364 typedef struct otherMsg
1367 ubyte *pOtherMsgTypeOid;
1369 taggedContent *pOtherMsgValue;
1372 typedef struct cmcSignerInfo *cmcSignerInfoPtr;
1375 CMC_createPKIDataEx(taggedAttribute pTaggedAttributes[], ubyte4 numTaggedAttrs, ubyte *pDerCertificateRequest, ubyte4 derCertificateReqLen, taggedContentInfo pTaggedContentInfos[], ubyte4 numTaggedContents, otherMsg pOtherMsgs[], ubyte4 numOtherMsgs, ubyte **ppBuffer, ubyte4 *pBufferLen);
1378 CMC_processCmsSequence(ASN1_ITEM *pPKIInputData, CStream stream, ubyte4 *pBodyPartsList, ubyte4 numBodyParts, byteBoolean isResponseData, ASN1_ITEMPTR **ppEnvelopDataItems, ubyte4 *pNumEnvelopDataItems);
1381 CMC_processControlSequence(ASN1_ITEM *pPKIInputData, CStream stream, ubyte *pBatchOID, ubyte4 **ppBodyPartIds, ubyte4 *pNumBodyPartIds);
1384 CMC_processOtherMsgSequence(ASN1_ITEM *pPKIInputData, CStream stream, ubyte **ppOutData, ubyte4 *pOutDataLen, byteBoolean isResponseData);
1387 CMC_verifyAttestationReqType(ASN1_ITEM *pPKIInputData, CStream stream, byteBoolean *pAttestFlow, ubyte **ppOid);
1390 CMC_createPKIData(ASN1_ITEMPTR pControlItem, CStream *controlStream, ASN1_ITEMPTR pReqItem, CStream *reqStream, ubyte **ppBuffer, ubyte4 *pBufferLen);
1393 CMC_getPKIResponse(ASN1_ITEM* pRootItem, CStream stream, ASN1_ITEM **ppPkiResponse);
1396 CMC_getPKIData(ASN1_ITEM* pRootItem, CStream stream, ASN1_ITEM **ppPkiRequest);
1397 #if defined(__ENABLE_MOCANA_AIDE_SERVER__) 1399 CMC_addCMCStatusInfoV2(CMCStatus status, sbyte4 referanceIds[], sbyte4 numRefIds, ubyte **ppBuffer, ubyte4 *pBufferLen);
1401 CMC_addTaggedAttribute(sbyte4 bodyPartID, ubyte *attrTypeOid, ubyte *attrValueData, ubyte4 attrValueLen, ubyte **ppBuffer, ubyte4 *pBufferLen);
1403 CMC_createSimplePKIMessage(CERTS_DATA *pCertsData, sbyte4 certDataLen, ubyte **ppPkiMessage, ubyte4 *pPkiMessageLen);
1405 CMC_createFullPKIMessage(ubyte* pSignerCertBytes, ubyte4 signerCertByteLen, AsymmetricKey *pSignerKey, CERTS_DATA *pCertsData, sbyte4 certDataLen, intBoolean isAttest, ubyte *pEkCertData, ubyte4 ekCertDataLen, ubyte *pOtherMsgData, ubyte4 otherMsgDataLen, ubyte **ppPkiMessage, ubyte4 *pPkiMessageLen);
1408 CMC_createCMSEnvelopForKekri(ubyte *encryptAlgoOID,
BulkEncryptionAlgo* pBulkEncryptionAlgo, sbyte4 keyLength,
1409 ubyte *decryptKeyIdentifierData, ubyte4 decryptKeyIdentifierDataLen,
1410 ubyte *pPreSharedKey, ubyte4 preSharedKeyLen,
1411 ubyte *pSecret, ubyte4 secretLen,
1412 ubyte *pPayload, ubyte4 payloadLen,
1413 ubyte** ppOutData, ubyte4 *pOutDataLen);
1416 CMC_createCMSEnvelopForKtri(ubyte *encryptAlgoOID,
1417 ubyte *pPreSharedCert, ubyte4 preSharedCertLen,
1418 ubyte *pPayload, ubyte4 payloadLen,
1419 ubyte** ppRetKeyData, ubyte4 *pRetKeyDataLen);
1552 struct DER_ITEM* pStart,
1553 struct DER_ITEM* pParent,
1554 struct ASN1_ITEM* pCACertificatesParseRoots[],
1555 CStream pCAStreams[], sbyte4 numCACerts,
1556 struct ASN1_ITEM* pCrlsParseRoots[],
1557 CStream pCrlStreams[], sbyte4 numCrls,
1558 cmcSignerInfoPtr *pCmcSignerInfos,
1560 const ubyte* payLoadType,
1561 const ubyte* pPayLoad, ubyte4 payLoadLen,
1564 ubyte** ppSigned, ubyte4* pSignedLen);
MOC_EXTERN MSTATUS PKCS7_GetSignerDigestAlgo(struct ASN1_ITEM *pSignerInfo, CStream cs, ubyte *hashAlgoId)
Get a SignerInfo object's digest hash function identifier.
AsymmetricKey * pKey
Pointer to AsymmetricKey structure that contains the signer's private key.
Definition: pkcs7.h:111
MOC_EXTERN MSTATUS PKCS7_DecryptEnvelopedDataAux(MOC_HW(hwAccelDescr hwAccelCtx) struct ASN1_ITEM *pEnvelopedData, CStream s, const void *callbackArg, PKCS7_GetPrivateKey getPrivateKeyFun, enum encryptedContentType *pType, struct ASN1_ITEM **ppEncryptedContent, BulkCtx *ppBulkCtx, const BulkEncryptionAlgo **ppBulkAlgo, ubyte iv[])
Decrypt an EnvelopedData object and get its encryption details.
MOC_EXTERN MSTATUS PKCS7_GetSignerSignatureAlgo(struct ASN1_ITEM *pSignerInfo, CStream cs, ubyte *pubKeyAlgoId)
Get a SignerInfo object's digest encryption algorithm identifier.
struct ASN1_ITEM * pSerialNumber
ASN1_ITEMPTR for the SerialNumber object in this signer's certificate.
Definition: pkcs7.h:101
MOC_EXTERN MSTATUS PKCS7_GetSignerUnsignedAttributes(struct ASN1_ITEM *pSignerInfo, struct ASN1_ITEM **ppFirstUnsignedAttribute)
Get the first unsigned attribute in a DER-encoded, ASN.1 SignerInfo object.
Information about a SignedData object's signer.
Definition: pkcs7.h:91
const ubyte * digestAlgoOID
Pointer to the OID for the message digest method to use for this signer.
Definition: pkcs7.h:121
MSTATUS(* PKCS7_ValidateRootCertificate)(const void *arg, CStream cs, struct ASN1_ITEM *pCertificate, sbyte4 chainLength)
Validate the certificates in a PKCS #7 message.
Definition: pkcs7.h:282
MOC_EXTERN MSTATUS PKCS7_GetSignerSignedAttributes(struct ASN1_ITEM *pSignerInfo, struct ASN1_ITEM **ppFirstSignedAttribute)
Get the first signed attribute in a DER-encoded, ASN.1 SignerInfo object.
MOC_EXTERN MSTATUS PKCS7_EnvelopData(MOC_HW(hwAccelDescr hwAccelCtx) struct DER_ITEM *pStart, struct DER_ITEM *pParent, struct ASN1_ITEM *pCACertificatesParseRoots[], CStream pStreams[], sbyte4 numCACerts, const ubyte *encryptAlgoOID, RNGFun rngFun, void *rngFunArg, const ubyte *pPayLoad, ubyte4 payLoadLen, ubyte **ppEnveloped, ubyte4 *pEnvelopedLen)
Create a DER-encoded, version 0, ASN.1 EnvelopedData object containing a given payload.
MOC_EXTERN MSTATUS PKCS7_DecryptEnvelopedData(MOC_HW(hwAccelDescr hwAccelCtx) struct ASN1_ITEM *pEnvelopedData, CStream s, const void *callbackArg, PKCS7_GetPrivateKey getPrivateKeyFun, ubyte **decryptedInfo, sbyte4 *decryptedInfoLen)
Extract and decrypt the encrypted content of an EnvelopedData object.
MOC_EXTERN MSTATUS PKCS7_SignData(MOC_ASYM(hwAccelDescr hwAccelCtx) ubyte4 flags, struct DER_ITEM *pStart, struct DER_ITEM *pParent, struct ASN1_ITEM *pCACertificatesParseRoots[], CStream pCAStreams[], sbyte4 numCACerts, struct ASN1_ITEM *pCrlsParseRoots[], CStream pCrlStreams[], sbyte4 numCrls, signerInfoPtr *pSignerInfos, ubyte4 numSigners, const ubyte *payLoadType, const ubyte *pPayLoad, ubyte4 payLoadLen, RNGFun rngFun, void *rngFunArg, ubyte **ppSigned, ubyte4 *pSignedLen)
Create a DER-encoded, version 1, ASN.1 SignedData object for data internal or external to the SignedD...
struct ASN1_ITEM * pIssuer
ASN1_ITEMPTR for the Issuer object in this signer's certificate.
Definition: pkcs7.h:96
MOC_EXTERN MSTATUS CMC_SignData(MOC_ASYM(hwAccelDescr hwAccelCtx) ubyte4 flags, struct DER_ITEM *pStart, struct DER_ITEM *pParent, struct ASN1_ITEM *pCACertificatesParseRoots[], CStream pCAStreams[], sbyte4 numCACerts, struct ASN1_ITEM *pCrlsParseRoots[], CStream pCrlStreams[], sbyte4 numCrls, cmcSignerInfoPtr *pCmcSignerInfos, ubyte4 numSigners, const ubyte *payLoadType, const ubyte *pPayLoad, ubyte4 payLoadLen, RNGFun rngFun, void *rngFunArg, ubyte **ppSigned, ubyte4 *pSignedLen)
Create a DER-encoded, version 1, ASN.1 SignedData object for data internal or external to the SignedD...
Information about an attribute of a SignedData object.
Definition: pkcs7.h:76
Attribute * pAuthAttrs
NULL or pointer to an Attributes structure for the signer's authenticated attributes.
Definition: pkcs7.h:137
CStream cs
CStream for the certificate referenced by pSerialNumber and pIssuer.
Definition: pkcs7.h:106
MSTATUS(* PKCS7_GetCertificate)(const void *arg, CStream cs, struct ASN1_ITEM *pSerialNumber, struct ASN1_ITEM *pIssuerName, ubyte **ppCertificate, ubyte4 *certificateLen)
Get a certificate for a given issuer name and serial number.
Definition: pkcs7.h:333
Pointers to PKCS #7 callback functions required by PKCS #12 functions.
Definition: pkcs7.h:352
MOC_EXTERN MSTATUS PKCS7_DigestData(MOC_HASH(hwAccelDescr hwAccelCtx) struct DER_ITEM *pStart, struct DER_ITEM *pParent, const ubyte *payLoadType, ubyte hashType, const ubyte *pPayLoad, ubyte4 payLoadLen, ubyte **ppDigested, ubyte4 *pDigestedLen)
Create a DER-encoded, ASN.1 DigestedData object for the given data.
ubyte4 authAttrsLen
Size of the authenticated attributes, pAuthAttrs.
Definition: pkcs7.h:141
MOC_EXTERN MSTATUS PKCS7_GetCertificates(struct ASN1_ITEM *pRootItem, CStream s, struct ASN1_ITEM **ppFirstCertificate)
If a given CStream contains a PKCS #7 SignedData object, get the first certificate.
Attribute * pUnauthAttrs
NULL or pointer to an Attributes structure for the signer's non-authenticated attributes.
Definition: pkcs7.h:153
ubyte4 unauthAttrsLen
Size of the authenticated attributes, pUnauthAttrs.
Definition: pkcs7.h:157
MOC_EXTERN MSTATUS PKCS7_VerifySignedData(MOC_ASYM(hwAccelDescr hwAccelCtx) struct ASN1_ITEM *pSignedData, CStream s, const void *callbackArg, PKCS7_GetCertificate getCertFun, PKCS7_ValidateRootCertificate valCertFun, const ubyte *payLoad, ubyte4 payLoadLen, sbyte4 *numKnownSigners)
Verify the signature of a SignedData object that contains the signed data.
MSTATUS(* PKCS7_GetPrivateKey)(const void *arg, CStream cs, struct ASN1_ITEM *pSerialNumber, struct ASN1_ITEM *pIssuerName, struct AsymmetricKey *pKey)
Get the private key associated with a given certificate in a PKCS #7 message (CMS message stream)...
Definition: pkcs7.h:231
MOC_EXTERN MSTATUS PKCS7_EnvelopDataWoaep(MOC_HW(hwAccelDescr hwAccelCtx) struct DER_ITEM *pStart, struct DER_ITEM *pParent, struct ASN1_ITEM *pCACertificatesParseRoots[], CStream pStreams[], sbyte4 numCACerts, const ubyte *encryptAlgoOID, RNGFun rngFun, void *rngFunArg, ubyte isOaep, ubyte4 oaepHashAlgo, sbyte *pOaepLabel, const ubyte *pPayLoad, ubyte4 payLoadLen, ubyte **ppEnveloped, ubyte4 *pEnvelopedLen)
Create a DER-encoded, version 0, ASN.1 EnvelopedData object containing a given payload.
Structure to hold function pointers to symmetric key cipher methods.
Definition: crypto.h:48
const ubyte * unused
For future use.
Definition: pkcs7.h:125