michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Interface to the PKCS7 implementation. michael@0: */ michael@0: michael@0: #ifndef _SECPKCS7_H_ michael@0: #define _SECPKCS7_H_ michael@0: michael@0: #include "seccomon.h" michael@0: michael@0: #include "secoidt.h" michael@0: #include "certt.h" michael@0: #include "keyt.h" michael@0: #include "hasht.h" michael@0: #include "pkcs7t.h" michael@0: michael@0: extern const SEC_ASN1Template sec_PKCS7ContentInfoTemplate[]; michael@0: michael@0: /************************************************************************/ michael@0: SEC_BEGIN_PROTOS michael@0: michael@0: /************************************************************************ michael@0: * Miscellaneous michael@0: ************************************************************************/ michael@0: michael@0: /* michael@0: * Returns the content type of the given contentInfo. michael@0: */ michael@0: extern SECOidTag SEC_PKCS7ContentType (SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* michael@0: * Destroy a PKCS7 contentInfo and all of its sub-pieces. michael@0: */ michael@0: extern void SEC_PKCS7DestroyContentInfo(SEC_PKCS7ContentInfo *contentInfo); michael@0: michael@0: /* michael@0: * Copy a PKCS7 contentInfo. A Destroy is needed on *each* copy. michael@0: */ michael@0: extern SEC_PKCS7ContentInfo * michael@0: SEC_PKCS7CopyContentInfo(SEC_PKCS7ContentInfo *contentInfo); michael@0: michael@0: /* michael@0: * Return a pointer to the actual content. In the case of those types michael@0: * which are encrypted, this returns the *plain* content. michael@0: */ michael@0: extern SECItem *SEC_PKCS7GetContent(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /************************************************************************ michael@0: * PKCS7 Decoding, Verification, etc.. michael@0: ************************************************************************/ michael@0: michael@0: extern SEC_PKCS7DecoderContext * michael@0: SEC_PKCS7DecoderStart(SEC_PKCS7DecoderContentCallback callback, michael@0: void *callback_arg, michael@0: SECKEYGetPasswordKey pwfn, void *pwfn_arg, michael@0: SEC_PKCS7GetDecryptKeyCallback decrypt_key_cb, michael@0: void *decrypt_key_cb_arg, michael@0: SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb); michael@0: michael@0: extern SECStatus michael@0: SEC_PKCS7DecoderUpdate(SEC_PKCS7DecoderContext *p7dcx, michael@0: const char *buf, unsigned long len); michael@0: michael@0: extern SEC_PKCS7ContentInfo * michael@0: SEC_PKCS7DecoderFinish(SEC_PKCS7DecoderContext *p7dcx); michael@0: michael@0: michael@0: /* Abort the underlying ASN.1 stream & set an error */ michael@0: void SEC_PKCS7DecoderAbort(SEC_PKCS7DecoderContext *p7dcx, int error); michael@0: michael@0: extern SEC_PKCS7ContentInfo * michael@0: SEC_PKCS7DecodeItem(SECItem *p7item, michael@0: SEC_PKCS7DecoderContentCallback cb, void *cb_arg, michael@0: SECKEYGetPasswordKey pwfn, void *pwfn_arg, michael@0: SEC_PKCS7GetDecryptKeyCallback decrypt_key_cb, michael@0: void *decrypt_key_cb_arg, michael@0: SEC_PKCS7DecryptionAllowedCallback decrypt_allowed_cb); michael@0: michael@0: extern PRBool SEC_PKCS7ContainsCertsOrCrls(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* checks to see if the contents of the content info is michael@0: * empty. it so, PR_TRUE is returned. PR_FALSE, otherwise. michael@0: * michael@0: * minLen is used to specify a minimum size. if content size <= minLen, michael@0: * content is assumed empty. michael@0: */ michael@0: extern PRBool michael@0: SEC_PKCS7IsContentEmpty(SEC_PKCS7ContentInfo *cinfo, unsigned int minLen); michael@0: michael@0: extern PRBool SEC_PKCS7ContentIsEncrypted(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* michael@0: * If the PKCS7 content has a signature (not just *could* have a signature) michael@0: * return true; false otherwise. This can/should be called before calling michael@0: * VerifySignature, which will always indicate failure if no signature is michael@0: * present, but that does not mean there even was a signature! michael@0: * Note that the content itself can be empty (detached content was sent michael@0: * another way); it is the presence of the signature that matters. michael@0: */ michael@0: extern PRBool SEC_PKCS7ContentIsSigned(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* michael@0: * SEC_PKCS7VerifySignature michael@0: * Look at a PKCS7 contentInfo and check if the signature is good. michael@0: * The verification checks that the signing cert is valid and trusted michael@0: * for the purpose specified by "certusage". michael@0: * michael@0: * In addition, if "keepcerts" is true, add any new certificates found michael@0: * into our local database. michael@0: */ michael@0: extern PRBool SEC_PKCS7VerifySignature(SEC_PKCS7ContentInfo *cinfo, michael@0: SECCertUsage certusage, michael@0: PRBool keepcerts); michael@0: michael@0: /* michael@0: * SEC_PKCS7VerifyDetachedSignature michael@0: * Look at a PKCS7 contentInfo and check if the signature matches michael@0: * a passed-in digest (calculated, supposedly, from detached contents). michael@0: * The verification checks that the signing cert is valid and trusted michael@0: * for the purpose specified by "certusage". michael@0: * michael@0: * In addition, if "keepcerts" is true, add any new certificates found michael@0: * into our local database. michael@0: */ michael@0: extern PRBool SEC_PKCS7VerifyDetachedSignature(SEC_PKCS7ContentInfo *cinfo, michael@0: SECCertUsage certusage, michael@0: const SECItem *detached_digest, michael@0: HASH_HashType digest_type, michael@0: PRBool keepcerts); michael@0: michael@0: /* michael@0: * SEC_PKCS7VerifyDetachedSignatureAtTime michael@0: * Look at a PKCS7 contentInfo and check if the signature matches michael@0: * a passed-in digest (calculated, supposedly, from detached contents). michael@0: * The verification checks that the signing cert is valid and trusted michael@0: * for the purpose specified by "certusage" at time "atTime". michael@0: * michael@0: * In addition, if "keepcerts" is true, add any new certificates found michael@0: * into our local database. michael@0: */ michael@0: extern PRBool michael@0: SEC_PKCS7VerifyDetachedSignatureAtTime(SEC_PKCS7ContentInfo *cinfo, michael@0: SECCertUsage certusage, michael@0: const SECItem *detached_digest, michael@0: HASH_HashType digest_type, michael@0: PRBool keepcerts, michael@0: PRTime atTime); michael@0: michael@0: /* michael@0: * SEC_PKCS7GetSignerCommonName, SEC_PKCS7GetSignerEmailAddress michael@0: * The passed-in contentInfo is espected to be Signed, and these michael@0: * functions return the specified portion of the full signer name. michael@0: * michael@0: * Returns a pointer to allocated memory, which must be freed. michael@0: * A NULL return value is an error. michael@0: */ michael@0: extern char *SEC_PKCS7GetSignerCommonName(SEC_PKCS7ContentInfo *cinfo); michael@0: extern char *SEC_PKCS7GetSignerEmailAddress(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* michael@0: * Return the the signing time, in UTCTime format, of a PKCS7 contentInfo. michael@0: */ michael@0: extern SECItem *SEC_PKCS7GetSigningTime(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: michael@0: /************************************************************************ michael@0: * PKCS7 Creation and Encoding. michael@0: ************************************************************************/ michael@0: michael@0: /* michael@0: * Start a PKCS7 signing context. michael@0: * michael@0: * "cert" is the cert that will be used to sign the data. It will be michael@0: * checked for validity. michael@0: * michael@0: * "certusage" describes the signing usage (e.g. certUsageEmailSigner) michael@0: * XXX Maybe SECCertUsage should be split so that our caller just says michael@0: * "email" and *we* add the "signing" part -- otherwise our caller michael@0: * could be lying about the usage; we do not want to allow encryption michael@0: * certs for signing or vice versa. michael@0: * michael@0: * "certdb" is the cert database to use for verifying the cert. michael@0: * It can be NULL if a default database is available (like in the client). michael@0: * michael@0: * "digestalg" names the digest algorithm (e.g. SEC_OID_SHA1). michael@0: * michael@0: * "digest" is the actual digest of the data. It must be provided in michael@0: * the case of detached data or NULL if the content will be included. michael@0: * michael@0: * The return value can be passed to functions which add things to michael@0: * it like attributes, then eventually to SEC_PKCS7Encode() or to michael@0: * SEC_PKCS7EncoderStart() to create the encoded data, and finally to michael@0: * SEC_PKCS7DestroyContentInfo(). michael@0: * michael@0: * An error results in a return value of NULL and an error set. michael@0: * (Retrieve specific errors via PORT_GetError()/XP_GetError().) michael@0: */ michael@0: extern SEC_PKCS7ContentInfo * michael@0: SEC_PKCS7CreateSignedData (CERTCertificate *cert, michael@0: SECCertUsage certusage, michael@0: CERTCertDBHandle *certdb, michael@0: SECOidTag digestalg, michael@0: SECItem *digest, michael@0: SECKEYGetPasswordKey pwfn, void *pwfn_arg); michael@0: michael@0: /* michael@0: * Create a PKCS7 certs-only container. michael@0: * michael@0: * "cert" is the (first) cert that will be included. michael@0: * michael@0: * "include_chain" specifies whether the entire chain for "cert" should michael@0: * be included. michael@0: * michael@0: * "certdb" is the cert database to use for finding the chain. michael@0: * It can be NULL in when "include_chain" is false, or when meaning michael@0: * use the default database. michael@0: * michael@0: * More certs and chains can be added via AddCertficate and AddCertChain. michael@0: * michael@0: * An error results in a return value of NULL and an error set. michael@0: * (Retrieve specific errors via PORT_GetError()/XP_GetError().) michael@0: */ michael@0: extern SEC_PKCS7ContentInfo * michael@0: SEC_PKCS7CreateCertsOnly (CERTCertificate *cert, michael@0: PRBool include_chain, michael@0: CERTCertDBHandle *certdb); michael@0: michael@0: /* michael@0: * Start a PKCS7 enveloping context. michael@0: * michael@0: * "cert" is the cert for the recipient. It will be checked for validity. michael@0: * michael@0: * "certusage" describes the encryption usage (e.g. certUsageEmailRecipient) michael@0: * XXX Maybe SECCertUsage should be split so that our caller just says michael@0: * "email" and *we* add the "recipient" part -- otherwise our caller michael@0: * could be lying about the usage; we do not want to allow encryption michael@0: * certs for signing or vice versa. michael@0: * michael@0: * "certdb" is the cert database to use for verifying the cert. michael@0: * It can be NULL if a default database is available (like in the client). michael@0: * michael@0: * "encalg" specifies the bulk encryption algorithm to use (e.g. SEC_OID_RC2). michael@0: * michael@0: * "keysize" specifies the bulk encryption key size, in bits. michael@0: * michael@0: * The return value can be passed to functions which add things to michael@0: * it like more recipients, then eventually to SEC_PKCS7Encode() or to michael@0: * SEC_PKCS7EncoderStart() to create the encoded data, and finally to michael@0: * SEC_PKCS7DestroyContentInfo(). michael@0: * michael@0: * An error results in a return value of NULL and an error set. michael@0: * (Retrieve specific errors via PORT_GetError()/XP_GetError().) michael@0: */ michael@0: extern SEC_PKCS7ContentInfo * michael@0: SEC_PKCS7CreateEnvelopedData (CERTCertificate *cert, michael@0: SECCertUsage certusage, michael@0: CERTCertDBHandle *certdb, michael@0: SECOidTag encalg, michael@0: int keysize, michael@0: SECKEYGetPasswordKey pwfn, void *pwfn_arg); michael@0: michael@0: /* michael@0: * XXX There will be a similar routine for creating signedAndEnvelopedData. michael@0: * But its parameters will be different and I have no plans to implement michael@0: * it any time soon because we have no current need for it. michael@0: */ michael@0: michael@0: /* michael@0: * Create an empty PKCS7 data content info. michael@0: * michael@0: * An error results in a return value of NULL and an error set. michael@0: * (Retrieve specific errors via PORT_GetError()/XP_GetError().) michael@0: */ michael@0: extern SEC_PKCS7ContentInfo *SEC_PKCS7CreateData (void); michael@0: michael@0: /* michael@0: * Create an empty PKCS7 encrypted content info. michael@0: * michael@0: * "algorithm" specifies the bulk encryption algorithm to use. michael@0: * michael@0: * An error results in a return value of NULL and an error set. michael@0: * (Retrieve specific errors via PORT_GetError()/XP_GetError().) michael@0: */ michael@0: extern SEC_PKCS7ContentInfo * michael@0: SEC_PKCS7CreateEncryptedData (SECOidTag algorithm, int keysize, michael@0: SECKEYGetPasswordKey pwfn, void *pwfn_arg); michael@0: michael@0: /* michael@0: * All of the following things return SECStatus to signal success or failure. michael@0: * Failure should have a more specific error status available via michael@0: * PORT_GetError()/XP_GetError(). michael@0: */ michael@0: michael@0: /* michael@0: * Add the specified attribute to the authenticated (i.e. signed) attributes michael@0: * of "cinfo" -- "oidtag" describes the attribute and "value" is the michael@0: * value to be associated with it. NOTE! "value" must already be encoded; michael@0: * no interpretation of "oidtag" is done. Also, it is assumed that this michael@0: * signedData has only one signer -- if we ever need to add attributes michael@0: * when there is more than one signature, we need a way to specify *which* michael@0: * signature should get the attribute. michael@0: * michael@0: * XXX Technically, a signed attribute can have multiple values; if/when michael@0: * we ever need to support an attribute which takes multiple values, we michael@0: * either need to change this interface or create an AddSignedAttributeValue michael@0: * which can be called subsequently, and would then append a value. michael@0: * michael@0: * "cinfo" should be of type signedData (the only kind of pkcs7 data michael@0: * that is allowed authenticated attributes); SECFailure will be returned michael@0: * if it is not. michael@0: */ michael@0: extern SECStatus SEC_PKCS7AddSignedAttribute (SEC_PKCS7ContentInfo *cinfo, michael@0: SECOidTag oidtag, michael@0: SECItem *value); michael@0: michael@0: /* michael@0: * Add "cert" and its entire chain to the set of certs included in "cinfo". michael@0: * michael@0: * "certdb" is the cert database to use for finding the chain. michael@0: * It can be NULL, meaning use the default database. michael@0: * michael@0: * "cinfo" should be of type signedData or signedAndEnvelopedData; michael@0: * SECFailure will be returned if it is not. michael@0: */ michael@0: extern SECStatus SEC_PKCS7AddCertChain (SEC_PKCS7ContentInfo *cinfo, michael@0: CERTCertificate *cert, michael@0: CERTCertDBHandle *certdb); michael@0: michael@0: /* michael@0: * Add "cert" to the set of certs included in "cinfo". michael@0: * michael@0: * "cinfo" should be of type signedData or signedAndEnvelopedData; michael@0: * SECFailure will be returned if it is not. michael@0: */ michael@0: extern SECStatus SEC_PKCS7AddCertificate (SEC_PKCS7ContentInfo *cinfo, michael@0: CERTCertificate *cert); michael@0: michael@0: /* michael@0: * Add another recipient to an encrypted message. michael@0: * michael@0: * "cinfo" should be of type envelopedData or signedAndEnvelopedData; michael@0: * SECFailure will be returned if it is not. michael@0: * michael@0: * "cert" is the cert for the recipient. It will be checked for validity. michael@0: * michael@0: * "certusage" describes the encryption usage (e.g. certUsageEmailRecipient) michael@0: * XXX Maybe SECCertUsage should be split so that our caller just says michael@0: * "email" and *we* add the "recipient" part -- otherwise our caller michael@0: * could be lying about the usage; we do not want to allow encryption michael@0: * certs for signing or vice versa. michael@0: * michael@0: * "certdb" is the cert database to use for verifying the cert. michael@0: * It can be NULL if a default database is available (like in the client). michael@0: */ michael@0: extern SECStatus SEC_PKCS7AddRecipient (SEC_PKCS7ContentInfo *cinfo, michael@0: CERTCertificate *cert, michael@0: SECCertUsage certusage, michael@0: CERTCertDBHandle *certdb); michael@0: michael@0: /* michael@0: * Add the signing time to the authenticated (i.e. signed) attributes michael@0: * of "cinfo". This is expected to be included in outgoing signed michael@0: * messages for email (S/MIME) but is likely useful in other situations. michael@0: * michael@0: * This should only be added once; a second call will either do michael@0: * nothing or replace an old signing time with a newer one. michael@0: * michael@0: * XXX This will probably just shove the current time into "cinfo" michael@0: * but it will not actually get signed until the entire item is michael@0: * processed for encoding. Is this (expected to be small) delay okay? michael@0: * michael@0: * "cinfo" should be of type signedData (the only kind of pkcs7 data michael@0: * that is allowed authenticated attributes); SECFailure will be returned michael@0: * if it is not. michael@0: */ michael@0: extern SECStatus SEC_PKCS7AddSigningTime (SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* michael@0: * Add the signer's symmetric capabilities to the authenticated michael@0: * (i.e. signed) attributes of "cinfo". This is expected to be michael@0: * included in outgoing signed messages for email (S/MIME). michael@0: * michael@0: * This can only be added once; a second call will return SECFailure. michael@0: * michael@0: * "cinfo" should be of type signedData or signedAndEnvelopedData; michael@0: * SECFailure will be returned if it is not. michael@0: */ michael@0: extern SECStatus SEC_PKCS7AddSymmetricCapabilities(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* michael@0: * Mark that the signer's certificate and its issuing chain should michael@0: * be included in the encoded data. This is expected to be used michael@0: * in outgoing signed messages for email (S/MIME). michael@0: * michael@0: * "certdb" is the cert database to use for finding the chain. michael@0: * It can be NULL, meaning use the default database. michael@0: * michael@0: * "cinfo" should be of type signedData or signedAndEnvelopedData; michael@0: * SECFailure will be returned if it is not. michael@0: */ michael@0: extern SECStatus SEC_PKCS7IncludeCertChain (SEC_PKCS7ContentInfo *cinfo, michael@0: CERTCertDBHandle *certdb); michael@0: michael@0: michael@0: /* michael@0: * Set the content; it will be included and also hashed and/or encrypted michael@0: * as appropriate. This is for in-memory content (expected to be "small") michael@0: * that will be included in the PKCS7 object. All others should stream the michael@0: * content through when encoding (see SEC_PKCS7Encoder{Start,Update,Finish}). michael@0: * michael@0: * "buf" points to data of length "len"; it will be copied. michael@0: */ michael@0: extern SECStatus SEC_PKCS7SetContent (SEC_PKCS7ContentInfo *cinfo, michael@0: const char *buf, unsigned long len); michael@0: michael@0: /* michael@0: * Encode a PKCS7 object, in one shot. All necessary components michael@0: * of the object must already be specified. Either the data has michael@0: * already been included (via SetContent), or the data is detached, michael@0: * or there is no data at all (certs-only). michael@0: * michael@0: * "cinfo" specifies the object to be encoded. michael@0: * michael@0: * "outputfn" is where the encoded bytes will be passed. michael@0: * michael@0: * "outputarg" is an opaque argument to the above callback. michael@0: * michael@0: * "bulkkey" specifies the bulk encryption key to use. This argument michael@0: * can be NULL if no encryption is being done, or if the bulk key should michael@0: * be generated internally (usually the case for EnvelopedData but never michael@0: * for EncryptedData, which *must* provide a bulk encryption key). michael@0: * michael@0: * "pwfn" is a callback for getting the password which protects the michael@0: * private key of the signer. This argument can be NULL if it is known michael@0: * that no signing is going to be done. michael@0: * michael@0: * "pwfnarg" is an opaque argument to the above callback. michael@0: */ michael@0: extern SECStatus SEC_PKCS7Encode (SEC_PKCS7ContentInfo *cinfo, michael@0: SEC_PKCS7EncoderOutputCallback outputfn, michael@0: void *outputarg, michael@0: PK11SymKey *bulkkey, michael@0: SECKEYGetPasswordKey pwfn, michael@0: void *pwfnarg); michael@0: michael@0: /* michael@0: * Encode a PKCS7 object, in one shot. All necessary components michael@0: * of the object must already be specified. Either the data has michael@0: * already been included (via SetContent), or the data is detached, michael@0: * or there is no data at all (certs-only). The output, rather than michael@0: * being passed to an output function as is done above, is all put michael@0: * into a SECItem. michael@0: * michael@0: * "pool" specifies a pool from which to allocate the result. michael@0: * It can be NULL, in which case memory is allocated generically. michael@0: * michael@0: * "dest" specifies a SECItem in which to put the result data. michael@0: * It can be NULL, in which case the entire item is allocated, too. michael@0: * michael@0: * "cinfo" specifies the object to be encoded. michael@0: * michael@0: * "bulkkey" specifies the bulk encryption key to use. This argument michael@0: * can be NULL if no encryption is being done, or if the bulk key should michael@0: * be generated internally (usually the case for EnvelopedData but never michael@0: * for EncryptedData, which *must* provide a bulk encryption key). michael@0: * michael@0: * "pwfn" is a callback for getting the password which protects the michael@0: * private key of the signer. This argument can be NULL if it is known michael@0: * that no signing is going to be done. michael@0: * michael@0: * "pwfnarg" is an opaque argument to the above callback. michael@0: */ michael@0: extern SECItem *SEC_PKCS7EncodeItem (PLArenaPool *pool, michael@0: SECItem *dest, michael@0: SEC_PKCS7ContentInfo *cinfo, michael@0: PK11SymKey *bulkkey, michael@0: SECKEYGetPasswordKey pwfn, michael@0: void *pwfnarg); michael@0: michael@0: /* michael@0: * For those who want to simply point to the pkcs7 contentInfo ASN.1 michael@0: * template, and *not* call the encoding functions directly, the michael@0: * following function can be used -- after it is called, the entire michael@0: * PKCS7 contentInfo is ready to be encoded. michael@0: */ michael@0: extern SECStatus SEC_PKCS7PrepareForEncode (SEC_PKCS7ContentInfo *cinfo, michael@0: PK11SymKey *bulkkey, michael@0: SECKEYGetPasswordKey pwfn, michael@0: void *pwfnarg); michael@0: michael@0: /* michael@0: * Start the process of encoding a PKCS7 object. The first part of michael@0: * the encoded object will be passed to the output function right away; michael@0: * after that it is expected that SEC_PKCS7EncoderUpdate will be called, michael@0: * streaming in the actual content that is getting included as well as michael@0: * signed or encrypted (or both). michael@0: * michael@0: * "cinfo" specifies the object to be encoded. michael@0: * michael@0: * "outputfn" is where the encoded bytes will be passed. michael@0: * michael@0: * "outputarg" is an opaque argument to the above callback. michael@0: * michael@0: * "bulkkey" specifies the bulk encryption key to use. This argument michael@0: * can be NULL if no encryption is being done, or if the bulk key should michael@0: * be generated internally (usually the case for EnvelopedData but never michael@0: * for EncryptedData, which *must* provide a bulk encryption key). michael@0: * michael@0: * Returns an object to be passed to EncoderUpdate and EncoderFinish. michael@0: */ michael@0: extern SEC_PKCS7EncoderContext * michael@0: SEC_PKCS7EncoderStart (SEC_PKCS7ContentInfo *cinfo, michael@0: SEC_PKCS7EncoderOutputCallback outputfn, michael@0: void *outputarg, michael@0: PK11SymKey *bulkkey); michael@0: michael@0: /* michael@0: * Encode more contents, hashing and/or encrypting along the way. michael@0: */ michael@0: extern SECStatus SEC_PKCS7EncoderUpdate (SEC_PKCS7EncoderContext *p7ecx, michael@0: const char *buf, michael@0: unsigned long len); michael@0: michael@0: /* michael@0: * No more contents; finish the signature creation, if appropriate, michael@0: * and then the encoding. michael@0: * michael@0: * "pwfn" is a callback for getting the password which protects the michael@0: * signer's private key. This argument can be NULL if it is known michael@0: * that no signing is going to be done. michael@0: * michael@0: * "pwfnarg" is an opaque argument to the above callback. michael@0: */ michael@0: extern SECStatus SEC_PKCS7EncoderFinish (SEC_PKCS7EncoderContext *p7ecx, michael@0: SECKEYGetPasswordKey pwfn, michael@0: void *pwfnarg); michael@0: michael@0: /* Abort the underlying ASN.1 stream & set an error */ michael@0: void SEC_PKCS7EncoderAbort(SEC_PKCS7EncoderContext *p7dcx, int error); michael@0: michael@0: /* retrieve the algorithm ID used to encrypt the content info michael@0: * for encrypted and enveloped data. The SECAlgorithmID pointer michael@0: * returned needs to be freed as it is a copy of the algorithm michael@0: * id in the content info. michael@0: */ michael@0: extern SECAlgorithmID * michael@0: SEC_PKCS7GetEncryptionAlgorithm(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* the content of an encrypted data content info is encrypted. michael@0: * it is assumed that for encrypted data, that the data has already michael@0: * been set and is in the "plainContent" field of the content info. michael@0: * michael@0: * cinfo is the content info to encrypt michael@0: * michael@0: * key is the key with which to perform the encryption. if the michael@0: * algorithm is a password based encryption algorithm, the michael@0: * key is actually a password which will be processed per michael@0: * PKCS #5. michael@0: * michael@0: * in the event of an error, SECFailure is returned. SECSuccess michael@0: * indicates a success. michael@0: */ michael@0: extern SECStatus michael@0: SEC_PKCS7EncryptContents(PLArenaPool *poolp, michael@0: SEC_PKCS7ContentInfo *cinfo, michael@0: SECItem *key, michael@0: void *wincx); michael@0: michael@0: /* the content of an encrypted data content info is decrypted. michael@0: * it is assumed that for encrypted data, that the data has already michael@0: * been set and is in the "encContent" field of the content info. michael@0: * michael@0: * cinfo is the content info to decrypt michael@0: * michael@0: * key is the key with which to perform the decryption. if the michael@0: * algorithm is a password based encryption algorithm, the michael@0: * key is actually a password which will be processed per michael@0: * PKCS #5. michael@0: * michael@0: * in the event of an error, SECFailure is returned. SECSuccess michael@0: * indicates a success. michael@0: */ michael@0: extern SECStatus michael@0: SEC_PKCS7DecryptContents(PLArenaPool *poolp, michael@0: SEC_PKCS7ContentInfo *cinfo, michael@0: SECItem *key, michael@0: void *wincx); michael@0: michael@0: /* retrieve the certificate list from the content info. the list michael@0: * is a pointer to the list in the content info. this should not michael@0: * be deleted or freed in any way short of calling michael@0: * SEC_PKCS7DestroyContentInfo michael@0: */ michael@0: extern SECItem ** michael@0: SEC_PKCS7GetCertificateList(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: /* Returns the key length (in bits) of the algorithm used to encrypt michael@0: this object. Returns 0 if it's not encrypted, or the key length is michael@0: irrelevant. */ michael@0: extern int michael@0: SEC_PKCS7GetKeyLength(SEC_PKCS7ContentInfo *cinfo); michael@0: michael@0: michael@0: /************************************************************************/ michael@0: SEC_END_PROTOS michael@0: michael@0: #endif /* _SECPKCS7_H_ */