cms.h

来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 1,085 行 · 第 1/3 页

H
1,085
字号
 * will be done in place (in objs). */extern SECStatusNSS_CMSArray_SortByDER(void **objs, const SEC_ASN1Template *objtemplate, void **objs2);/* * NSS_CMSUtil_DERCompare - for use with NSS_CMSArray_Sort to *  sort arrays of SECItems containing DER */extern intNSS_CMSUtil_DERCompare(void *a, void *b);/* * NSS_CMSAlgArray_GetIndexByAlgID - find a specific algorithm in an array of  * algorithms. * * algorithmArray - array of algorithm IDs * algid - algorithmid of algorithm to pick * * Returns: *  An integer containing the index of the algorithm in the array or -1 if  *  algorithm was not found. */extern intNSS_CMSAlgArray_GetIndexByAlgID(SECAlgorithmID **algorithmArray, SECAlgorithmID *algid);/* * NSS_CMSAlgArray_GetIndexByAlgID - find a specific algorithm in an array of  * algorithms. * * algorithmArray - array of algorithm IDs * algiddata - id of algorithm to pick * * Returns: *  An integer containing the index of the algorithm in the array or -1 if  *  algorithm was not found. */extern intNSS_CMSAlgArray_GetIndexByAlgTag(SECAlgorithmID **algorithmArray, SECOidTag algtag);extern SECHashObject *NSS_CMSUtil_GetHashObjByAlgID(SECAlgorithmID *algid);/* * XXX I would *really* like to not have to do this, but the current * signing interface gives me little choice. */extern SECOidTagNSS_CMSUtil_MakeSignatureAlgorithm(SECOidTag hashalg, SECOidTag encalg);extern const SEC_ASN1Template *NSS_CMSUtil_GetTemplateByTypeTag(SECOidTag type);extern size_tNSS_CMSUtil_GetSizeByTypeTag(SECOidTag type);extern NSSCMSContentInfo *NSS_CMSContent_GetContentInfo(void *msg, SECOidTag type);extern const char *NSS_CMSUtil_VerificationStatusToString(NSSCMSVerificationStatus vs);/************************************************************************ * cmssigdata.c - CMS signedData methods ************************************************************************/extern NSSCMSSignedData *NSS_CMSSignedData_Create(NSSCMSMessage *cmsg);extern voidNSS_CMSSignedData_Destroy(NSSCMSSignedData *sigd);/* * NSS_CMSSignedData_Encode_BeforeStart - do all the necessary things to a SignedData *     before start of encoding. * * In detail: *  - find out about the right value to put into sigd->version *  - come up with a list of digestAlgorithms (which should be the union of the algorithms *         in the signerinfos). *         If we happen to have a pre-set list of algorithms (and digest values!), we *         check if we have all the signerinfos' algorithms. If not, this is an error. */extern SECStatusNSS_CMSSignedData_Encode_BeforeStart(NSSCMSSignedData *sigd);extern SECStatusNSS_CMSSignedData_Encode_BeforeData(NSSCMSSignedData *sigd);/* * NSS_CMSSignedData_Encode_AfterData - do all the necessary things to a SignedData *     after all the encapsulated data was passed through the encoder. * * In detail: *  - create the signatures in all the SignerInfos * * Please note that nothing is done to the Certificates and CRLs in the message - this * is entirely the responsibility of our callers. */extern SECStatusNSS_CMSSignedData_Encode_AfterData(NSSCMSSignedData *sigd);extern SECStatusNSS_CMSSignedData_Decode_BeforeData(NSSCMSSignedData *sigd);/* * NSS_CMSSignedData_Decode_AfterData - do all the necessary things to a SignedData *     after all the encapsulated data was passed through the decoder. */extern SECStatusNSS_CMSSignedData_Decode_AfterData(NSSCMSSignedData *sigd);/* * NSS_CMSSignedData_Decode_AfterEnd - do all the necessary things to a SignedData *     after all decoding is finished. */extern SECStatusNSS_CMSSignedData_Decode_AfterEnd(NSSCMSSignedData *sigd);/*  * NSS_CMSSignedData_GetSignerInfos - retrieve the SignedData's signer list */extern NSSCMSSignerInfo **NSS_CMSSignedData_GetSignerInfos(NSSCMSSignedData *sigd);extern intNSS_CMSSignedData_SignerInfoCount(NSSCMSSignedData *sigd);extern NSSCMSSignerInfo *NSS_CMSSignedData_GetSignerInfo(NSSCMSSignedData *sigd, int i);/*  * NSS_CMSSignedData_GetDigestAlgs - retrieve the SignedData's digest algorithm list */extern SECAlgorithmID **NSS_CMSSignedData_GetDigestAlgs(NSSCMSSignedData *sigd);/* * NSS_CMSSignedData_GetContentInfo - return pointer to this signedData's contentinfo */extern NSSCMSContentInfo *NSS_CMSSignedData_GetContentInfo(NSSCMSSignedData *sigd);/*  * NSS_CMSSignedData_GetCertificateList - retrieve the SignedData's certificate list */extern SECItem **NSS_CMSSignedData_GetCertificateList(NSSCMSSignedData *sigd);extern SECStatusNSS_CMSSignedData_ImportCerts(NSSCMSSignedData *sigd, CERTCertDBHandle *certdb,				SECCertUsage certusage, PRBool keepcerts);/* * NSS_CMSSignedData_HasDigests - see if we have digests in place */extern PRBoolNSS_CMSSignedData_HasDigests(NSSCMSSignedData *sigd);/* * NSS_CMSSignedData_VerifySignerInfo - check a signature. * * The digests were either calculated during decoding (and are stored in the * signedData itself) or set after decoding using NSS_CMSSignedData_SetDigests. * * The verification checks if the signing cert is valid and has a trusted chain * for the purpose specified by "certusage". */extern SECStatusNSS_CMSSignedData_VerifySignerInfo(NSSCMSSignedData *sigd, int i, CERTCertDBHandle *certdb,				    SECCertUsage certusage);/* * NSS_CMSSignedData_VerifyCertsOnly - verify the certs in a certs-only message*/extern SECStatusNSS_CMSSignedData_VerifyCertsOnly(NSSCMSSignedData *sigd,                                   CERTCertDBHandle *certdb,                                   SECCertUsage usage);extern SECStatusNSS_CMSSignedData_AddCertList(NSSCMSSignedData *sigd, CERTCertificateList *certlist);/* * NSS_CMSSignedData_AddCertChain - add cert and its entire chain to the set of certs  */extern SECStatusNSS_CMSSignedData_AddCertChain(NSSCMSSignedData *sigd, CERTCertificate *cert);extern SECStatusNSS_CMSSignedData_AddCertificate(NSSCMSSignedData *sigd, CERTCertificate *cert);extern PRBoolNSS_CMSSignedData_ContainsCertsOrCrls(NSSCMSSignedData *sigd);extern SECStatusNSS_CMSSignedData_AddSignerInfo(NSSCMSSignedData *sigd,				NSSCMSSignerInfo *signerinfo);extern SECItem *NSS_CMSSignedData_GetDigestByAlgTag(NSSCMSSignedData *sigd, SECOidTag algtag);extern SECStatusNSS_CMSSignedData_SetDigests(NSSCMSSignedData *sigd,				SECAlgorithmID **digestalgs,				SECItem **digests);extern SECStatusNSS_CMSSignedData_SetDigestValue(NSSCMSSignedData *sigd,				SECOidTag digestalgtag,				SECItem *digestdata);extern SECStatusNSS_CMSSignedData_AddDigest(PRArenaPool *poolp,				NSSCMSSignedData *sigd,				SECOidTag digestalgtag,				SECItem *digest);extern SECItem *NSS_CMSSignedData_GetDigestValue(NSSCMSSignedData *sigd, SECOidTag digestalgtag);/* * NSS_CMSSignedData_CreateCertsOnly - create a certs-only SignedData. * * cert          - base certificates that will be included * include_chain - if true, include the complete cert chain for cert * * More certs and chains can be added via AddCertificate and AddCertChain. * * An error results in a return value of NULL and an error set. */extern NSSCMSSignedData *NSS_CMSSignedData_CreateCertsOnly(NSSCMSMessage *cmsg, CERTCertificate *cert, PRBool include_chain);/************************************************************************ * cmssiginfo.c - signerinfo methods ************************************************************************/extern NSSCMSSignerInfo *NSS_CMSSignerInfo_Create(NSSCMSMessage *cmsg, CERTCertificate *cert, SECOidTag digestalgtag);/* * NSS_CMSSignerInfo_Destroy - destroy a SignerInfo data structure */extern voidNSS_CMSSignerInfo_Destroy(NSSCMSSignerInfo *si);/* * NSS_CMSSignerInfo_Sign - sign something * */extern SECStatusNSS_CMSSignerInfo_Sign(NSSCMSSignerInfo *signerinfo, SECItem *digest, SECItem *contentType);extern SECStatusNSS_CMSSignerInfo_VerifyCertificate(NSSCMSSignerInfo *signerinfo, CERTCertDBHandle *certdb,			    SECCertUsage certusage);/* * NSS_CMSSignerInfo_Verify - verify the signature of a single SignerInfo * * Just verifies the signature. The assumption is that verification of the certificate * is done already. */extern SECStatusNSS_CMSSignerInfo_Verify(NSSCMSSignerInfo *signerinfo, SECItem *digest, SECItem *contentType);extern NSSCMSVerificationStatusNSS_CMSSignerInfo_GetVerificationStatus(NSSCMSSignerInfo *signerinfo);extern SECOidData *NSS_CMSSignerInfo_GetDigestAlg(NSSCMSSignerInfo *signerinfo);extern SECOidTagNSS_CMSSignerInfo_GetDigestAlgTag(NSSCMSSignerInfo *signerinfo);extern intNSS_CMSSignerInfo_GetVersion(NSSCMSSignerInfo *signerinfo);extern CERTCertificateList *NSS_CMSSignerInfo_GetCertList(NSSCMSSignerInfo *signerinfo);/* * NSS_CMSSignerInfo_GetSigningTime - return the signing time, *				      in UTCTime format, of a CMS signerInfo. * * sinfo - signerInfo data for this signer * * Returns a pointer to XXXX (what?) * A return value of NULL is an error. */extern SECStatusNSS_CMSSignerInfo_GetSigningTime(NSSCMSSignerInfo *sinfo, PRTime *stime);/* * Return the signing cert of a CMS signerInfo. * * the certs in the enclosing SignedData must have been imported already */extern CERTCertificate *NSS_CMSSignerInfo_GetSigningCertificate(NSSCMSSignerInfo *signerinfo, CERTCertDBHandle *certdb);/* * NSS_CMSSignerInfo_GetSignerCommonName - return the common name of the signer * * sinfo - signerInfo data for this signer * * Returns a pointer to allocated memory, which must be freed. * A return value of NULL is an error. */extern char *NSS_CMSSignerInfo_GetSignerCommonName(NSSCMSSignerInfo *sinfo);/* * NSS_CMSSignerInfo_GetSignerEmailAddress - return the common name of the signer * * sinfo - signerInfo data for this signer * * Returns a pointer to allocated memory, which must be freed. * A return value of NULL is an error. */extern char *NSS_CMSSignerInfo_GetSignerEmailAddress(NSSCMSSignerInfo *sinfo);/* * NSS_CMSSignerInfo_AddAuthAttr - add an attribute to the * authenticated (i.e. signed) attributes of "signerinfo".  */extern SECStatusNSS_CMSSignerInfo_AddAuthAttr(NSSCMSSignerInfo *signerinfo, NSSCMSAttribute *attr);/* * NSS_CMSSignerInfo_AddUnauthAttr - add an attribute to the * unauthenticated attributes of "signerinfo".  */extern SECStatusNSS_CMSSignerInfo_AddUnauthAttr(NSSCMSSignerInfo *signerinfo, NSSCMSAttribute *attr);/*  * NSS_CMSSignerInfo_AddSigningTime - add the signing time to the * authenticated (i.e. signed) attributes of "signerinfo".  * * This is expected to be included in outgoing signed * messages for email (S/MIME) but is likely useful in other situations. * * This should only be added once; a second call will do nothing. * * XXX This will probably just shove the current time into "signerinfo" * but it will not actually get signed until the entire item is * processed for encoding.  Is this (expected to be small) delay okay? */extern SECStatusNSS_CMSSignerInfo_AddSigningTime(NSSCMSSignerInfo *signerinfo, PRTime t);/* * NSS_CMSSignerInfo_AddSMIMECaps - add a SMIMECapabilities attribute to the * authenticated (i.e. signed) attributes of "signerinfo". * * This is expected to be included in outgoing signed * messages for email (S/MIME). */extern SECStatus

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?