andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: /* andre@0: * Interfaces of the CMS implementation. andre@0: */ andre@0: andre@0: #ifndef _CMS_H_ andre@0: #define _CMS_H_ andre@0: andre@0: #include "seccomon.h" andre@0: andre@0: #include "secoidt.h" andre@0: #include "certt.h" andre@0: #include "keyt.h" andre@0: #include "hasht.h" andre@0: #include "cmst.h" andre@0: andre@0: /************************************************************************/ andre@0: SEC_BEGIN_PROTOS andre@0: andre@0: /************************************************************************ andre@0: * cmsdecode.c - CMS decoding andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSDecoder_Start - set up decoding of a DER-encoded CMS message andre@0: * andre@0: * "poolp" - pointer to arena for message, or NULL if new pool should be created andre@0: * "cb", "cb_arg" - callback function and argument for delivery of inner content andre@0: * inner content will be stored in the message if cb is NULL. andre@0: * "pwfn", pwfn_arg" - callback function for getting token password andre@0: * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData andre@0: */ andre@0: extern NSSCMSDecoderContext * andre@0: NSS_CMSDecoder_Start(PLArenaPool *poolp, andre@0: NSSCMSContentCallback cb, void *cb_arg, andre@0: PK11PasswordFunc pwfn, void *pwfn_arg, andre@0: NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg); andre@0: andre@0: /* andre@0: * NSS_CMSDecoder_Update - feed DER-encoded data to decoder andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDecoder_Update(NSSCMSDecoderContext *p7dcx, const char *buf, unsigned long len); andre@0: andre@0: /* andre@0: * NSS_CMSDecoder_Cancel - cancel a decoding process andre@0: */ andre@0: extern void andre@0: NSS_CMSDecoder_Cancel(NSSCMSDecoderContext *p7dcx); andre@0: andre@0: /* andre@0: * NSS_CMSDecoder_Finish - mark the end of inner content and finish decoding andre@0: */ andre@0: extern NSSCMSMessage * andre@0: NSS_CMSDecoder_Finish(NSSCMSDecoderContext *p7dcx); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_CreateFromDER - decode a CMS message from DER encoded data andre@0: */ andre@0: extern NSSCMSMessage * andre@0: NSS_CMSMessage_CreateFromDER(SECItem *DERmessage, andre@0: NSSCMSContentCallback cb, void *cb_arg, andre@0: PK11PasswordFunc pwfn, void *pwfn_arg, andre@0: NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg); andre@0: andre@0: /************************************************************************ andre@0: * cmsencode.c - CMS encoding andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSEncoder_Start - set up encoding of a CMS message andre@0: * andre@0: * "cmsg" - message to encode andre@0: * "outputfn", "outputarg" - callback function for delivery of DER-encoded output andre@0: * will not be called if NULL. andre@0: * "dest" - if non-NULL, pointer to SECItem that will hold the DER-encoded output andre@0: * "destpoolp" - pool to allocate DER-encoded output in andre@0: * "pwfn", pwfn_arg" - callback function for getting token password andre@0: * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData andre@0: * "detached_digestalgs", "detached_digests" - digests from detached content andre@0: */ andre@0: extern NSSCMSEncoderContext * andre@0: NSS_CMSEncoder_Start(NSSCMSMessage *cmsg, andre@0: NSSCMSContentCallback outputfn, void *outputarg, andre@0: SECItem *dest, PLArenaPool *destpoolp, andre@0: PK11PasswordFunc pwfn, void *pwfn_arg, andre@0: NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg, andre@0: SECAlgorithmID **detached_digestalgs, SECItem **detached_digests); andre@0: andre@0: /* andre@0: * NSS_CMSEncoder_Update - take content data delivery from the user andre@0: * andre@0: * "p7ecx" - encoder context andre@0: * "data" - content data andre@0: * "len" - length of content data andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncoder_Update(NSSCMSEncoderContext *p7ecx, const char *data, unsigned long len); andre@0: andre@0: /* andre@0: * NSS_CMSEncoder_Cancel - stop all encoding andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncoder_Cancel(NSSCMSEncoderContext *p7ecx); andre@0: andre@0: /* andre@0: * NSS_CMSEncoder_Finish - signal the end of data andre@0: * andre@0: * we need to walk down the chain of encoders and the finish them from the innermost out andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncoder_Finish(NSSCMSEncoderContext *p7ecx); andre@0: andre@0: /************************************************************************ andre@0: * cmsmessage.c - CMS message object andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSMessage_Create - create a CMS message object andre@0: * andre@0: * "poolp" - arena to allocate memory from, or NULL if new arena should be created andre@0: */ andre@0: extern NSSCMSMessage * andre@0: NSS_CMSMessage_Create(PLArenaPool *poolp); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_SetEncodingParams - set up a CMS message object for encoding or decoding andre@0: * andre@0: * "cmsg" - message object andre@0: * "pwfn", pwfn_arg" - callback function for getting token password andre@0: * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData andre@0: * "detached_digestalgs", "detached_digests" - digests from detached content andre@0: * andre@0: * used internally. andre@0: */ andre@0: extern void andre@0: NSS_CMSMessage_SetEncodingParams(NSSCMSMessage *cmsg, andre@0: PK11PasswordFunc pwfn, void *pwfn_arg, andre@0: NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg, andre@0: SECAlgorithmID **detached_digestalgs, SECItem **detached_digests); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_Destroy - destroy a CMS message and all of its sub-pieces. andre@0: */ andre@0: extern void andre@0: NSS_CMSMessage_Destroy(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_Copy - return a copy of the given message. andre@0: * andre@0: * The copy may be virtual or may be real -- either way, the result needs andre@0: * to be passed to NSS_CMSMessage_Destroy later (as does the original). andre@0: */ andre@0: extern NSSCMSMessage * andre@0: NSS_CMSMessage_Copy(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_GetArena - return a pointer to the message's arena pool andre@0: */ andre@0: extern PLArenaPool * andre@0: NSS_CMSMessage_GetArena(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_GetContentInfo - return a pointer to the top level contentInfo andre@0: */ andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSMessage_GetContentInfo(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * Return a pointer to the actual content. andre@0: * In the case of those types which are encrypted, this returns the *plain* content. andre@0: * In case of nested contentInfos, this descends and retrieves the innermost content. andre@0: */ andre@0: extern SECItem * andre@0: NSS_CMSMessage_GetContent(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_ContentLevelCount - count number of levels of CMS content objects in this message andre@0: * andre@0: * CMS data content objects do not count. andre@0: */ andre@0: extern int andre@0: NSS_CMSMessage_ContentLevelCount(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_ContentLevel - find content level #n andre@0: * andre@0: * CMS data content objects do not count. andre@0: */ andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSMessage_ContentLevel(NSSCMSMessage *cmsg, int n); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_ContainsCertsOrCrls - see if message contains certs along the way andre@0: */ andre@0: extern PRBool andre@0: NSS_CMSMessage_ContainsCertsOrCrls(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_IsEncrypted - see if message contains a encrypted submessage andre@0: */ andre@0: extern PRBool andre@0: NSS_CMSMessage_IsEncrypted(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_IsSigned - see if message contains a signed submessage andre@0: * andre@0: * If the CMS message has a SignedData with a signature (not just a SignedData) andre@0: * return true; false otherwise. This can/should be called before calling andre@0: * VerifySignature, which will always indicate failure if no signature is andre@0: * present, but that does not mean there even was a signature! andre@0: * Note that the content itself can be empty (detached content was sent andre@0: * another way); it is the presence of the signature that matters. andre@0: */ andre@0: extern PRBool andre@0: NSS_CMSMessage_IsSigned(NSSCMSMessage *cmsg); andre@0: andre@0: /* andre@0: * NSS_CMSMessage_IsContentEmpty - see if content is empty andre@0: * andre@0: * returns PR_TRUE is innermost content length is < minLen andre@0: * XXX need the encrypted content length (why?) andre@0: */ andre@0: extern PRBool andre@0: NSS_CMSMessage_IsContentEmpty(NSSCMSMessage *cmsg, unsigned int minLen); andre@0: andre@0: /************************************************************************ andre@0: * cmscinfo.c - CMS contentInfo methods andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_Destroy - destroy a CMS contentInfo and all of its sub-pieces. andre@0: */ andre@0: extern void andre@0: NSS_CMSContentInfo_Destroy(NSSCMSContentInfo *cinfo); andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_GetChildContentInfo - get content's contentInfo (if it exists) andre@0: */ andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSContentInfo_GetChildContentInfo(NSSCMSContentInfo *cinfo); andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_SetContent - set cinfo's content type & content to CMS object andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContent(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECOidTag type, void *ptr); andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_SetContent_XXXX - typesafe wrappers for NSS_CMSContentInfo_SetType andre@0: * set cinfo's content type & content to CMS object andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContent_Data(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECItem *data, PRBool detached); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContent_SignedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSSignedData *sigd); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContent_EnvelopedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEnvelopedData *envd); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContent_DigestedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSDigestedData *digd); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContent_EncryptedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * turn off streaming for this content type. andre@0: * This could fail with SEC_ERROR_NO_MEMORY in memory constrained conditions. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetDontStream(NSSCMSContentInfo *cinfo, PRBool dontStream); andre@0: andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_GetContent - get pointer to inner content andre@0: * andre@0: * needs to be casted... andre@0: */ andre@0: extern void * andre@0: NSS_CMSContentInfo_GetContent(NSSCMSContentInfo *cinfo); andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_GetInnerContent - get pointer to innermost content andre@0: * andre@0: * this is typically only called by NSS_CMSMessage_GetContent() andre@0: */ andre@0: extern SECItem * andre@0: NSS_CMSContentInfo_GetInnerContent(NSSCMSContentInfo *cinfo); andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_GetContentType{Tag,OID} - find out (saving pointer to lookup result andre@0: * for future reference) and return the inner content type. andre@0: */ andre@0: extern SECOidTag andre@0: NSS_CMSContentInfo_GetContentTypeTag(NSSCMSContentInfo *cinfo); andre@0: andre@0: extern SECItem * andre@0: NSS_CMSContentInfo_GetContentTypeOID(NSSCMSContentInfo *cinfo); andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_GetContentEncAlgTag - find out (saving pointer to lookup result andre@0: * for future reference) and return the content encryption algorithm tag. andre@0: */ andre@0: extern SECOidTag andre@0: NSS_CMSContentInfo_GetContentEncAlgTag(NSSCMSContentInfo *cinfo); andre@0: andre@0: /* andre@0: * NSS_CMSContentInfo_GetContentEncAlg - find out and return the content encryption algorithm tag. andre@0: */ andre@0: extern SECAlgorithmID * andre@0: NSS_CMSContentInfo_GetContentEncAlg(NSSCMSContentInfo *cinfo); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContentEncAlg(PLArenaPool *poolp, NSSCMSContentInfo *cinfo, andre@0: SECOidTag bulkalgtag, SECItem *parameters, int keysize); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSContentInfo_SetContentEncAlgID(PLArenaPool *poolp, NSSCMSContentInfo *cinfo, andre@0: SECAlgorithmID *algid, int keysize); andre@0: andre@0: extern void andre@0: NSS_CMSContentInfo_SetBulkKey(NSSCMSContentInfo *cinfo, PK11SymKey *bulkkey); andre@0: andre@0: extern PK11SymKey * andre@0: NSS_CMSContentInfo_GetBulkKey(NSSCMSContentInfo *cinfo); andre@0: andre@0: extern int andre@0: NSS_CMSContentInfo_GetBulkKeySize(NSSCMSContentInfo *cinfo); andre@0: andre@0: /************************************************************************ andre@0: * cmsutil.c - CMS misc utility functions andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSArray_SortByDER - sort array of objects by objects' DER encoding andre@0: * andre@0: * make sure that the order of the objects guarantees valid DER (which must be andre@0: * in lexigraphically ascending order for a SET OF); if reordering is necessary it andre@0: * will be done in place (in objs). andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSArray_SortByDER(void **objs, const SEC_ASN1Template *objtemplate, void **objs2); andre@0: andre@0: /* andre@0: * NSS_CMSUtil_DERCompare - for use with NSS_CMSArray_Sort to andre@0: * sort arrays of SECItems containing DER andre@0: */ andre@0: extern int andre@0: NSS_CMSUtil_DERCompare(void *a, void *b); andre@0: andre@0: /* andre@0: * NSS_CMSAlgArray_GetIndexByAlgID - find a specific algorithm in an array of andre@0: * algorithms. andre@0: * andre@0: * algorithmArray - array of algorithm IDs andre@0: * algid - algorithmid of algorithm to pick andre@0: * andre@0: * Returns: andre@0: * An integer containing the index of the algorithm in the array or -1 if andre@0: * algorithm was not found. andre@0: */ andre@0: extern int andre@0: NSS_CMSAlgArray_GetIndexByAlgID(SECAlgorithmID **algorithmArray, SECAlgorithmID *algid); andre@0: andre@0: /* andre@0: * NSS_CMSAlgArray_GetIndexByAlgID - find a specific algorithm in an array of andre@0: * algorithms. andre@0: * andre@0: * algorithmArray - array of algorithm IDs andre@0: * algiddata - id of algorithm to pick andre@0: * andre@0: * Returns: andre@0: * An integer containing the index of the algorithm in the array or -1 if andre@0: * algorithm was not found. andre@0: */ andre@0: extern int andre@0: NSS_CMSAlgArray_GetIndexByAlgTag(SECAlgorithmID **algorithmArray, SECOidTag algtag); andre@0: andre@0: extern const SECHashObject * andre@0: NSS_CMSUtil_GetHashObjByAlgID(SECAlgorithmID *algid); andre@0: andre@0: extern const SEC_ASN1Template * andre@0: NSS_CMSUtil_GetTemplateByTypeTag(SECOidTag type); andre@0: andre@0: extern size_t andre@0: NSS_CMSUtil_GetSizeByTypeTag(SECOidTag type); andre@0: andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSContent_GetContentInfo(void *msg, SECOidTag type); andre@0: andre@0: extern const char * andre@0: NSS_CMSUtil_VerificationStatusToString(NSSCMSVerificationStatus vs); andre@0: andre@0: /************************************************************************ andre@0: * cmssigdata.c - CMS signedData methods andre@0: ************************************************************************/ andre@0: andre@0: extern NSSCMSSignedData * andre@0: NSS_CMSSignedData_Create(NSSCMSMessage *cmsg); andre@0: andre@0: extern void andre@0: NSS_CMSSignedData_Destroy(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_Encode_BeforeStart - do all the necessary things to a SignedData andre@0: * before start of encoding. andre@0: * andre@0: * In detail: andre@0: * - find out about the right value to put into sigd->version andre@0: * - come up with a list of digestAlgorithms (which should be the union of the algorithms andre@0: * in the signerinfos). andre@0: * If we happen to have a pre-set list of algorithms (and digest values!), we andre@0: * check if we have all the signerinfos' algorithms. If not, this is an error. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignedData_Encode_BeforeStart(NSSCMSSignedData *sigd); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_Encode_BeforeData(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_Encode_AfterData - do all the necessary things to a SignedData andre@0: * after all the encapsulated data was passed through the encoder. andre@0: * andre@0: * In detail: andre@0: * - create the signatures in all the SignerInfos andre@0: * andre@0: * Please note that nothing is done to the Certificates and CRLs in the message - this andre@0: * is entirely the responsibility of our callers. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignedData_Encode_AfterData(NSSCMSSignedData *sigd); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_Decode_BeforeData(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_Decode_AfterData - do all the necessary things to a SignedData andre@0: * after all the encapsulated data was passed through the decoder. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignedData_Decode_AfterData(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_Decode_AfterEnd - do all the necessary things to a SignedData andre@0: * after all decoding is finished. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignedData_Decode_AfterEnd(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_GetSignerInfos - retrieve the SignedData's signer list andre@0: */ andre@0: extern NSSCMSSignerInfo ** andre@0: NSS_CMSSignedData_GetSignerInfos(NSSCMSSignedData *sigd); andre@0: andre@0: extern int andre@0: NSS_CMSSignedData_SignerInfoCount(NSSCMSSignedData *sigd); andre@0: andre@0: extern NSSCMSSignerInfo * andre@0: NSS_CMSSignedData_GetSignerInfo(NSSCMSSignedData *sigd, int i); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_GetDigestAlgs - retrieve the SignedData's digest algorithm list andre@0: */ andre@0: extern SECAlgorithmID ** andre@0: NSS_CMSSignedData_GetDigestAlgs(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_GetContentInfo - return pointer to this signedData's contentinfo andre@0: */ andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSSignedData_GetContentInfo(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_GetCertificateList - retrieve the SignedData's certificate list andre@0: */ andre@0: extern SECItem ** andre@0: NSS_CMSSignedData_GetCertificateList(NSSCMSSignedData *sigd); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_ImportCerts(NSSCMSSignedData *sigd, CERTCertDBHandle *certdb, andre@0: SECCertUsage certusage, PRBool keepcerts); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_HasDigests - see if we have digests in place andre@0: */ andre@0: extern PRBool andre@0: NSS_CMSSignedData_HasDigests(NSSCMSSignedData *sigd); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_VerifySignerInfo - check a signature. andre@0: * andre@0: * The digests were either calculated during decoding (and are stored in the andre@0: * signedData itself) or set after decoding using NSS_CMSSignedData_SetDigests. andre@0: * andre@0: * The verification checks if the signing cert is valid and has a trusted chain andre@0: * for the purpose specified by "certusage". andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignedData_VerifySignerInfo(NSSCMSSignedData *sigd, int i, CERTCertDBHandle *certdb, andre@0: SECCertUsage certusage); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_VerifyCertsOnly - verify the certs in a certs-only message andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignedData_VerifyCertsOnly(NSSCMSSignedData *sigd, andre@0: CERTCertDBHandle *certdb, andre@0: SECCertUsage usage); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_AddCertList(NSSCMSSignedData *sigd, CERTCertificateList *certlist); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_AddCertChain - add cert and its entire chain to the set of certs andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignedData_AddCertChain(NSSCMSSignedData *sigd, CERTCertificate *cert); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_AddCertificate(NSSCMSSignedData *sigd, CERTCertificate *cert); andre@0: andre@0: extern PRBool andre@0: NSS_CMSSignedData_ContainsCertsOrCrls(NSSCMSSignedData *sigd); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_AddSignerInfo(NSSCMSSignedData *sigd, andre@0: NSSCMSSignerInfo *signerinfo); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_SetDigests(NSSCMSSignedData *sigd, andre@0: SECAlgorithmID **digestalgs, andre@0: SECItem **digests); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_SetDigestValue(NSSCMSSignedData *sigd, andre@0: SECOidTag digestalgtag, andre@0: SECItem *digestdata); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignedData_AddDigest(PLArenaPool *poolp, andre@0: NSSCMSSignedData *sigd, andre@0: SECOidTag digestalgtag, andre@0: SECItem *digest); andre@0: andre@0: extern SECItem * andre@0: NSS_CMSSignedData_GetDigestValue(NSSCMSSignedData *sigd, SECOidTag digestalgtag); andre@0: andre@0: /* andre@0: * NSS_CMSSignedData_CreateCertsOnly - create a certs-only SignedData. andre@0: * andre@0: * cert - base certificates that will be included andre@0: * include_chain - if true, include the complete cert chain for cert andre@0: * andre@0: * More certs and chains can be added via AddCertificate and AddCertChain. andre@0: * andre@0: * An error results in a return value of NULL and an error set. andre@0: */ andre@0: extern NSSCMSSignedData * andre@0: NSS_CMSSignedData_CreateCertsOnly(NSSCMSMessage *cmsg, CERTCertificate *cert, PRBool include_chain); andre@0: andre@0: /************************************************************************ andre@0: * cmssiginfo.c - signerinfo methods andre@0: ************************************************************************/ andre@0: andre@0: extern NSSCMSSignerInfo * andre@0: NSS_CMSSignerInfo_Create(NSSCMSMessage *cmsg, CERTCertificate *cert, SECOidTag digestalgtag); andre@0: extern NSSCMSSignerInfo * andre@0: NSS_CMSSignerInfo_CreateWithSubjKeyID(NSSCMSMessage *cmsg, SECItem *subjKeyID, SECKEYPublicKey *pubKey, SECKEYPrivateKey *signingKey, SECOidTag digestalgtag); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_Destroy - destroy a SignerInfo data structure andre@0: */ andre@0: extern void andre@0: NSS_CMSSignerInfo_Destroy(NSSCMSSignerInfo *si); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_Sign - sign something andre@0: * andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_Sign(NSSCMSSignerInfo *signerinfo, SECItem *digest, SECItem *contentType); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_VerifyCertificate(NSSCMSSignerInfo *signerinfo, CERTCertDBHandle *certdb, andre@0: SECCertUsage certusage); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_Verify - verify the signature of a single SignerInfo andre@0: * andre@0: * Just verifies the signature. The assumption is that verification of the certificate andre@0: * is done already. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_Verify(NSSCMSSignerInfo *signerinfo, SECItem *digest, SECItem *contentType); andre@0: andre@0: extern NSSCMSVerificationStatus andre@0: NSS_CMSSignerInfo_GetVerificationStatus(NSSCMSSignerInfo *signerinfo); andre@0: andre@0: extern SECOidData * andre@0: NSS_CMSSignerInfo_GetDigestAlg(NSSCMSSignerInfo *signerinfo); andre@0: andre@0: extern SECOidTag andre@0: NSS_CMSSignerInfo_GetDigestAlgTag(NSSCMSSignerInfo *signerinfo); andre@0: andre@0: extern int andre@0: NSS_CMSSignerInfo_GetVersion(NSSCMSSignerInfo *signerinfo); andre@0: andre@0: extern CERTCertificateList * andre@0: NSS_CMSSignerInfo_GetCertList(NSSCMSSignerInfo *signerinfo); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_GetSigningTime - return the signing time, andre@0: * in UTCTime format, of a CMS signerInfo. andre@0: * andre@0: * sinfo - signerInfo data for this signer andre@0: * andre@0: * Returns a pointer to XXXX (what?) andre@0: * A return value of NULL is an error. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_GetSigningTime(NSSCMSSignerInfo *sinfo, PRTime *stime); andre@0: andre@0: /* andre@0: * Return the signing cert of a CMS signerInfo. andre@0: * andre@0: * the certs in the enclosing SignedData must have been imported already andre@0: */ andre@0: extern CERTCertificate * andre@0: NSS_CMSSignerInfo_GetSigningCertificate(NSSCMSSignerInfo *signerinfo, CERTCertDBHandle *certdb); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_GetSignerCommonName - return the common name of the signer andre@0: * andre@0: * sinfo - signerInfo data for this signer andre@0: * andre@0: * Returns a pointer to allocated memory, which must be freed with PORT_Free. andre@0: * A return value of NULL is an error. andre@0: */ andre@0: extern char * andre@0: NSS_CMSSignerInfo_GetSignerCommonName(NSSCMSSignerInfo *sinfo); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_GetSignerEmailAddress - return the common name of the signer andre@0: * andre@0: * sinfo - signerInfo data for this signer andre@0: * andre@0: * Returns a pointer to allocated memory, which must be freed. andre@0: * A return value of NULL is an error. andre@0: */ andre@0: extern char * andre@0: NSS_CMSSignerInfo_GetSignerEmailAddress(NSSCMSSignerInfo *sinfo); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_AddAuthAttr - add an attribute to the andre@0: * authenticated (i.e. signed) attributes of "signerinfo". andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_AddAuthAttr(NSSCMSSignerInfo *signerinfo, NSSCMSAttribute *attr); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_AddUnauthAttr - add an attribute to the andre@0: * unauthenticated attributes of "signerinfo". andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_AddUnauthAttr(NSSCMSSignerInfo *signerinfo, NSSCMSAttribute *attr); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_AddSigningTime - add the signing time to the andre@0: * authenticated (i.e. signed) attributes of "signerinfo". andre@0: * andre@0: * This is expected to be included in outgoing signed andre@0: * messages for email (S/MIME) but is likely useful in other situations. andre@0: * andre@0: * This should only be added once; a second call will do nothing. andre@0: * andre@0: * XXX This will probably just shove the current time into "signerinfo" andre@0: * but it will not actually get signed until the entire item is andre@0: * processed for encoding. Is this (expected to be small) delay okay? andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_AddSigningTime(NSSCMSSignerInfo *signerinfo, PRTime t); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_AddSMIMECaps - add a SMIMECapabilities attribute to the andre@0: * authenticated (i.e. signed) attributes of "signerinfo". andre@0: * andre@0: * This is expected to be included in outgoing signed andre@0: * messages for email (S/MIME). andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_AddSMIMECaps(NSSCMSSignerInfo *signerinfo); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_AddSMIMEEncKeyPrefs - add a SMIMEEncryptionKeyPreferences attribute to the andre@0: * authenticated (i.e. signed) attributes of "signerinfo". andre@0: * andre@0: * This is expected to be included in outgoing signed messages for email (S/MIME). andre@0: */ andre@0: SECStatus andre@0: NSS_CMSSignerInfo_AddSMIMEEncKeyPrefs(NSSCMSSignerInfo *signerinfo, CERTCertificate *cert, CERTCertDBHandle *certdb); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_AddMSSMIMEEncKeyPrefs - add a SMIMEEncryptionKeyPreferences attribute to the andre@0: * authenticated (i.e. signed) attributes of "signerinfo", using the OID preferred by Microsoft. andre@0: * andre@0: * This is expected to be included in outgoing signed messages for email (S/MIME), andre@0: * if compatibility with Microsoft mail clients is wanted. andre@0: */ andre@0: SECStatus andre@0: NSS_CMSSignerInfo_AddMSSMIMEEncKeyPrefs(NSSCMSSignerInfo *signerinfo, CERTCertificate *cert, CERTCertDBHandle *certdb); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_AddCounterSignature - countersign a signerinfo andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_AddCounterSignature(NSSCMSSignerInfo *signerinfo, andre@0: SECOidTag digestalg, CERTCertificate signingcert); andre@0: andre@0: /* andre@0: * XXXX the following needs to be done in the S/MIME layer code andre@0: * after signature of a signerinfo is verified andre@0: */ andre@0: extern SECStatus andre@0: NSS_SMIMESignerInfo_SaveSMIMEProfile(NSSCMSSignerInfo *signerinfo); andre@0: andre@0: /* andre@0: * NSS_CMSSignerInfo_IncludeCerts - set cert chain inclusion mode for this signer andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSSignerInfo_IncludeCerts(NSSCMSSignerInfo *signerinfo, NSSCMSCertChainMode cm, SECCertUsage usage); andre@0: andre@0: /************************************************************************ andre@0: * cmsenvdata.c - CMS envelopedData methods andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Create - create an enveloped data message andre@0: */ andre@0: extern NSSCMSEnvelopedData * andre@0: NSS_CMSEnvelopedData_Create(NSSCMSMessage *cmsg, SECOidTag algorithm, int keysize); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Destroy - destroy an enveloped data message andre@0: */ andre@0: extern void andre@0: NSS_CMSEnvelopedData_Destroy(NSSCMSEnvelopedData *edp); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_GetContentInfo - return pointer to this envelopedData's contentinfo andre@0: */ andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSEnvelopedData_GetContentInfo(NSSCMSEnvelopedData *envd); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_AddRecipient - add a recipientinfo to the enveloped data msg andre@0: * andre@0: * rip must be created on the same pool as edp - this is not enforced, though. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEnvelopedData_AddRecipient(NSSCMSEnvelopedData *edp, NSSCMSRecipientInfo *rip); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Encode_BeforeStart - prepare this envelopedData for encoding andre@0: * andre@0: * at this point, we need andre@0: * - recipientinfos set up with recipient's certificates andre@0: * - a content encryption algorithm (if none, 3DES will be used) andre@0: * andre@0: * this function will generate a random content encryption key (aka bulk key), andre@0: * initialize the recipientinfos with certificate identification and wrap the bulk key andre@0: * using the proper algorithm for every certificiate. andre@0: * it will finally set the bulk algorithm and key so that the encode step can find it. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEnvelopedData_Encode_BeforeStart(NSSCMSEnvelopedData *envd); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Encode_BeforeData - set up encryption andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEnvelopedData_Encode_BeforeData(NSSCMSEnvelopedData *envd); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Encode_AfterData - finalize this envelopedData for encoding andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEnvelopedData_Encode_AfterData(NSSCMSEnvelopedData *envd); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Decode_BeforeData - find our recipientinfo, andre@0: * derive bulk key & set up our contentinfo andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEnvelopedData_Decode_BeforeData(NSSCMSEnvelopedData *envd); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Decode_AfterData - finish decrypting this envelopedData's content andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEnvelopedData_Decode_AfterData(NSSCMSEnvelopedData *envd); andre@0: andre@0: /* andre@0: * NSS_CMSEnvelopedData_Decode_AfterEnd - finish decoding this envelopedData andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEnvelopedData_Decode_AfterEnd(NSSCMSEnvelopedData *envd); andre@0: andre@0: andre@0: /************************************************************************ andre@0: * cmsrecinfo.c - CMS recipientInfo methods andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSRecipientInfo_Create - create a recipientinfo andre@0: * andre@0: * we currently do not create KeyAgreement recipientinfos with multiple recipientEncryptedKeys andre@0: * the certificate is supposed to have been verified by the caller andre@0: */ andre@0: extern NSSCMSRecipientInfo * andre@0: NSS_CMSRecipientInfo_Create(NSSCMSMessage *cmsg, CERTCertificate *cert); andre@0: andre@0: extern NSSCMSRecipientInfo * andre@0: NSS_CMSRecipientInfo_CreateWithSubjKeyID(NSSCMSMessage *cmsg, andre@0: SECItem *subjKeyID, andre@0: SECKEYPublicKey *pubKey); andre@0: andre@0: extern NSSCMSRecipientInfo * andre@0: NSS_CMSRecipientInfo_CreateWithSubjKeyIDFromCert(NSSCMSMessage *cmsg, andre@0: CERTCertificate *cert); andre@0: andre@0: /* andre@0: * NSS_CMSRecipientInfo_CreateNew - create a blank recipientinfo for andre@0: * applications which want to encode their own CMS structures and andre@0: * key exchange types. andre@0: */ andre@0: extern NSSCMSRecipientInfo * andre@0: NSS_CMSRecipientInfo_CreateNew(void* pwfn_arg); andre@0: andre@0: /* andre@0: * NSS_CMSRecipientInfo_CreateFromDER - create a recipientinfo from partially andre@0: * decoded DER data for applications which want to encode their own CMS andre@0: * structures and key exchange types. andre@0: */ andre@0: extern NSSCMSRecipientInfo * andre@0: NSS_CMSRecipientInfo_CreateFromDER(SECItem* input, void* pwfn_arg); andre@0: andre@0: extern void andre@0: NSS_CMSRecipientInfo_Destroy(NSSCMSRecipientInfo *ri); andre@0: andre@0: /* andre@0: * NSS_CMSRecipientInfo_GetCertAndKey - retrieve the cert and key from the andre@0: * recipientInfo struct. If retcert or retkey are NULL, the cert or andre@0: * key (respectively) would not be returned). This function is a no-op if both andre@0: * retcert and retkey are NULL. Caller inherits ownership of the cert and key andre@0: * he requested (and is responsible to free them). andre@0: */ andre@0: SECStatus NSS_CMSRecipientInfo_GetCertAndKey(NSSCMSRecipientInfo *ri, andre@0: CERTCertificate** retcert, SECKEYPrivateKey** retkey); andre@0: andre@0: extern int andre@0: NSS_CMSRecipientInfo_GetVersion(NSSCMSRecipientInfo *ri); andre@0: andre@0: extern SECItem * andre@0: NSS_CMSRecipientInfo_GetEncryptedKey(NSSCMSRecipientInfo *ri, int subIndex); andre@0: andre@0: /* andre@0: * NSS_CMSRecipientInfo_Encode - encode an NSS_CMSRecipientInfo as ASN.1 andre@0: */ andre@0: SECStatus NSS_CMSRecipientInfo_Encode(PLArenaPool* poolp, andre@0: const NSSCMSRecipientInfo *src, andre@0: SECItem* returned); andre@0: andre@0: extern SECOidTag andre@0: NSS_CMSRecipientInfo_GetKeyEncryptionAlgorithmTag(NSSCMSRecipientInfo *ri); andre@0: andre@0: extern SECStatus andre@0: NSS_CMSRecipientInfo_WrapBulkKey(NSSCMSRecipientInfo *ri, PK11SymKey *bulkkey, SECOidTag bulkalgtag); andre@0: andre@0: extern PK11SymKey * andre@0: NSS_CMSRecipientInfo_UnwrapBulkKey(NSSCMSRecipientInfo *ri, int subIndex, andre@0: CERTCertificate *cert, SECKEYPrivateKey *privkey, SECOidTag bulkalgtag); andre@0: andre@0: /************************************************************************ andre@0: * cmsencdata.c - CMS encryptedData methods andre@0: ************************************************************************/ andre@0: /* andre@0: * NSS_CMSEncryptedData_Create - create an empty encryptedData object. andre@0: * andre@0: * "algorithm" specifies the bulk encryption algorithm to use. andre@0: * "keysize" is the key size. andre@0: * andre@0: * An error results in a return value of NULL and an error set. andre@0: * (Retrieve specific errors via PORT_GetError()/XP_GetError().) andre@0: */ andre@0: extern NSSCMSEncryptedData * andre@0: NSS_CMSEncryptedData_Create(NSSCMSMessage *cmsg, SECOidTag algorithm, int keysize); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_Destroy - destroy an encryptedData object andre@0: */ andre@0: extern void andre@0: NSS_CMSEncryptedData_Destroy(NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_GetContentInfo - return pointer to encryptedData object's contentInfo andre@0: */ andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSEncryptedData_GetContentInfo(NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_Encode_BeforeStart - do all the necessary things to a EncryptedData andre@0: * before encoding begins. andre@0: * andre@0: * In particular: andre@0: * - set the correct version value. andre@0: * - get the encryption key andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncryptedData_Encode_BeforeStart(NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_Encode_BeforeData - set up encryption andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncryptedData_Encode_BeforeData(NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_Encode_AfterData - finalize this encryptedData for encoding andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncryptedData_Encode_AfterData(NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_Decode_BeforeData - find bulk key & set up decryption andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncryptedData_Decode_BeforeData(NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_Decode_AfterData - finish decrypting this encryptedData's content andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncryptedData_Decode_AfterData(NSSCMSEncryptedData *encd); andre@0: andre@0: /* andre@0: * NSS_CMSEncryptedData_Decode_AfterEnd - finish decoding this encryptedData andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSEncryptedData_Decode_AfterEnd(NSSCMSEncryptedData *encd); andre@0: andre@0: /************************************************************************ andre@0: * cmsdigdata.c - CMS encryptedData methods andre@0: ************************************************************************/ andre@0: /* andre@0: * NSS_CMSDigestedData_Create - create a digestedData object (presumably for encoding) andre@0: * andre@0: * version will be set by NSS_CMSDigestedData_Encode_BeforeStart andre@0: * digestAlg is passed as parameter andre@0: * contentInfo must be filled by the user andre@0: * digest will be calculated while encoding andre@0: */ andre@0: extern NSSCMSDigestedData * andre@0: NSS_CMSDigestedData_Create(NSSCMSMessage *cmsg, SECAlgorithmID *digestalg); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_Destroy - destroy a digestedData object andre@0: */ andre@0: extern void andre@0: NSS_CMSDigestedData_Destroy(NSSCMSDigestedData *digd); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_GetContentInfo - return pointer to digestedData object's contentInfo andre@0: */ andre@0: extern NSSCMSContentInfo * andre@0: NSS_CMSDigestedData_GetContentInfo(NSSCMSDigestedData *digd); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_Encode_BeforeStart - do all the necessary things to a DigestedData andre@0: * before encoding begins. andre@0: * andre@0: * In particular: andre@0: * - set the right version number. The contentInfo's content type must be set up already. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestedData_Encode_BeforeStart(NSSCMSDigestedData *digd); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_Encode_BeforeData - do all the necessary things to a DigestedData andre@0: * before the encapsulated data is passed through the encoder. andre@0: * andre@0: * In detail: andre@0: * - set up the digests if necessary andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestedData_Encode_BeforeData(NSSCMSDigestedData *digd); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_Encode_AfterData - do all the necessary things to a DigestedData andre@0: * after all the encapsulated data was passed through the encoder. andre@0: * andre@0: * In detail: andre@0: * - finish the digests andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestedData_Encode_AfterData(NSSCMSDigestedData *digd); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_Decode_BeforeData - do all the necessary things to a DigestedData andre@0: * before the encapsulated data is passed through the encoder. andre@0: * andre@0: * In detail: andre@0: * - set up the digests if necessary andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestedData_Decode_BeforeData(NSSCMSDigestedData *digd); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_Decode_AfterData - do all the necessary things to a DigestedData andre@0: * after all the encapsulated data was passed through the encoder. andre@0: * andre@0: * In detail: andre@0: * - finish the digests andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestedData_Decode_AfterData(NSSCMSDigestedData *digd); andre@0: andre@0: /* andre@0: * NSS_CMSDigestedData_Decode_AfterEnd - finalize a digestedData. andre@0: * andre@0: * In detail: andre@0: * - check the digests for equality andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestedData_Decode_AfterEnd(NSSCMSDigestedData *digd); andre@0: andre@0: /************************************************************************ andre@0: * cmsdigest.c - digestion routines andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * NSS_CMSDigestContext_StartMultiple - start digest calculation using all the andre@0: * digest algorithms in "digestalgs" in parallel. andre@0: */ andre@0: extern NSSCMSDigestContext * andre@0: NSS_CMSDigestContext_StartMultiple(SECAlgorithmID **digestalgs); andre@0: andre@0: /* andre@0: * NSS_CMSDigestContext_StartSingle - same as NSS_CMSDigestContext_StartMultiple, but andre@0: * only one algorithm. andre@0: */ andre@0: extern NSSCMSDigestContext * andre@0: NSS_CMSDigestContext_StartSingle(SECAlgorithmID *digestalg); andre@0: andre@0: /* andre@0: * NSS_CMSDigestContext_Update - feed more data into the digest machine andre@0: */ andre@0: extern void andre@0: NSS_CMSDigestContext_Update(NSSCMSDigestContext *cmsdigcx, const unsigned char *data, int len); andre@0: andre@0: /* andre@0: * NSS_CMSDigestContext_Cancel - cancel digesting operation andre@0: */ andre@0: extern void andre@0: NSS_CMSDigestContext_Cancel(NSSCMSDigestContext *cmsdigcx); andre@0: andre@0: /* andre@0: * NSS_CMSDigestContext_FinishMultiple - finish the digests and put them andre@0: * into an array of SECItems (allocated on poolp) andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestContext_FinishMultiple(NSSCMSDigestContext *cmsdigcx, PLArenaPool *poolp, andre@0: SECItem ***digestsp); andre@0: andre@0: /* andre@0: * NSS_CMSDigestContext_FinishSingle - same as NSS_CMSDigestContext_FinishMultiple, andre@0: * but for one digest. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDigestContext_FinishSingle(NSSCMSDigestContext *cmsdigcx, PLArenaPool *poolp, andre@0: SECItem *digest); andre@0: andre@0: /************************************************************************ andre@0: * andre@0: ************************************************************************/ andre@0: andre@0: /* shortcuts for basic use */ andre@0: andre@0: /* andre@0: * NSS_CMSDEREncode - DER Encode a CMS message, with input being andre@0: * the plaintext message and derOut being the output, andre@0: * stored in arena's pool. andre@0: */ andre@0: extern SECStatus andre@0: NSS_CMSDEREncode(NSSCMSMessage *cmsg, SECItem *input, SECItem *derOut, andre@0: PLArenaPool *arena); andre@0: andre@0: andre@0: /************************************************************************ andre@0: * andre@0: ************************************************************************/ andre@0: andre@0: /* andre@0: * define new S/MIME content type entries andre@0: * andre@0: * S/MIME uses the builtin PKCS7 oid types for encoding and decoding the andre@0: * various S/MIME content. Some applications have their own content type andre@0: * which is different from the standard content type defined by S/MIME. andre@0: * andre@0: * This function allows you to register new content types. There are basically andre@0: * Two different types of content, Wrappping content, and Data. andre@0: * andre@0: * For data types, All the functions below can be zero or NULL excext andre@0: * type and is isData, which should be your oid tag and PR_FALSE respectively andre@0: * andre@0: * For wrapping types, everything must be provided, or you will get encoder andre@0: * failures. andre@0: * andre@0: * If NSS doesn't already define the OID that you need, you can register andre@0: * your own with SECOID_AddEntry. andre@0: * andre@0: * Once you have defined your new content type, you can pass your new content andre@0: * type to NSS_CMSContentInfo_SetContent(). andre@0: * andre@0: * If you are using a wrapping type you can pass your own data structure in andre@0: * the ptr field, but it must contain and embedded NSSCMSGenericWrappingData andre@0: * structure as the first element. The size you pass to andre@0: * NSS_CMSType_RegisterContentType is the total size of your self defined andre@0: * data structure. NSS_CMSContentInfo_GetContent will return that data andre@0: * structure from the content info. Your ASN1Template will be evaluated andre@0: * against that data structure. andre@0: */ andre@0: SECStatus NSS_CMSType_RegisterContentType(SECOidTag type, andre@0: SEC_ASN1Template *asn1Template, size_t size, andre@0: NSSCMSGenericWrapperDataDestroy destroy, andre@0: NSSCMSGenericWrapperDataCallback decode_before, andre@0: NSSCMSGenericWrapperDataCallback decode_after, andre@0: NSSCMSGenericWrapperDataCallback decode_end, andre@0: NSSCMSGenericWrapperDataCallback encode_start, andre@0: NSSCMSGenericWrapperDataCallback encode_before, andre@0: NSSCMSGenericWrapperDataCallback encode_after, andre@0: PRBool isData); andre@0: andre@0: /************************************************************************/ andre@0: SEC_END_PROTOS andre@0: andre@0: #endif /* _CMS_H_ */