cms.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 1,085 行 · 第 1/3 页
H
1,085 行
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the Netscape security libraries. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1994-2000 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. *//* * Interfaces of the CMS implementation. * * $Id: cms.h,v 1.6 2000/09/29 16:38:11 mcgreer%netscape.com Exp $ */#ifndef _CMS_H_#define _CMS_H_#include "seccomon.h"#include "mcom_db.h" /* needed by certt.h */#include "secoidt.h"#include "secder.h" /* needed by certt.h; XXX go away when possible */#include "certt.h"#include "keyt.h"#include "hasht.h"#include "cmst.h"/************************************************************************/SEC_BEGIN_PROTOS/************************************************************************ * cmsdecode.c - CMS decoding ************************************************************************//* * NSS_CMSDecoder_Start - set up decoding of a DER-encoded CMS message * * "poolp" - pointer to arena for message, or NULL if new pool should be created * "cb", "cb_arg" - callback function and argument for delivery of inner content * inner content will be stored in the message if cb is NULL. * "pwfn", pwfn_arg" - callback function for getting token password * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData */extern NSSCMSDecoderContext *NSS_CMSDecoder_Start(PRArenaPool *poolp, NSSCMSContentCallback cb, void *cb_arg, PK11PasswordFunc pwfn, void *pwfn_arg, NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg);/* * NSS_CMSDecoder_Update - feed DER-encoded data to decoder */extern SECStatusNSS_CMSDecoder_Update(NSSCMSDecoderContext *p7dcx, const char *buf, unsigned long len);/* * NSS_CMSDecoder_Cancel - cancel a decoding process */extern voidNSS_CMSDecoder_Cancel(NSSCMSDecoderContext *p7dcx);/* * NSS_CMSDecoder_Finish - mark the end of inner content and finish decoding */extern NSSCMSMessage *NSS_CMSDecoder_Finish(NSSCMSDecoderContext *p7dcx);/* * NSS_CMSMessage_CreateFromDER - decode a CMS message from DER encoded data */extern NSSCMSMessage *NSS_CMSMessage_CreateFromDER(SECItem *DERmessage, NSSCMSContentCallback cb, void *cb_arg, PK11PasswordFunc pwfn, void *pwfn_arg, NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg);/************************************************************************ * cmsencode.c - CMS encoding ************************************************************************//* * NSS_CMSEncoder_Start - set up encoding of a CMS message * * "cmsg" - message to encode * "outputfn", "outputarg" - callback function for delivery of DER-encoded output * will not be called if NULL. * "dest" - if non-NULL, pointer to SECItem that will hold the DER-encoded output * "destpoolp" - pool to allocate DER-encoded output in * "pwfn", pwfn_arg" - callback function for getting token password * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData * "detached_digestalgs", "detached_digests" - digests from detached content */extern NSSCMSEncoderContext *NSS_CMSEncoder_Start(NSSCMSMessage *cmsg, NSSCMSContentCallback outputfn, void *outputarg, SECItem *dest, PLArenaPool *destpoolp, PK11PasswordFunc pwfn, void *pwfn_arg, NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg, SECAlgorithmID **detached_digestalgs, SECItem **detached_digests);/* * NSS_CMSEncoder_Update - take content data delivery from the user * * "p7ecx" - encoder context * "data" - content data * "len" - length of content data */extern SECStatusNSS_CMSEncoder_Update(NSSCMSEncoderContext *p7ecx, const char *data, unsigned long len);/* * NSS_CMSEncoder_Finish - signal the end of data * * we need to walk down the chain of encoders and the finish them from the innermost out */extern SECStatusNSS_CMSEncoder_Finish(NSSCMSEncoderContext *p7ecx);/************************************************************************ * cmsmessage.c - CMS message object ************************************************************************//* * NSS_CMSMessage_Create - create a CMS message object * * "poolp" - arena to allocate memory from, or NULL if new arena should be created */extern NSSCMSMessage *NSS_CMSMessage_Create(PLArenaPool *poolp);/* * NSS_CMSMessage_SetEncodingParams - set up a CMS message object for encoding or decoding * * "cmsg" - message object * "pwfn", pwfn_arg" - callback function for getting token password * "decrypt_key_cb", "decrypt_key_cb_arg" - callback function for getting bulk key for encryptedData * "detached_digestalgs", "detached_digests" - digests from detached content * * used internally. */extern voidNSS_CMSMessage_SetEncodingParams(NSSCMSMessage *cmsg, PK11PasswordFunc pwfn, void *pwfn_arg, NSSCMSGetDecryptKeyCallback decrypt_key_cb, void *decrypt_key_cb_arg, SECAlgorithmID **detached_digestalgs, SECItem **detached_digests);/* * NSS_CMSMessage_Destroy - destroy a CMS message and all of its sub-pieces. */extern voidNSS_CMSMessage_Destroy(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_Copy - return a copy of the given message. * * The copy may be virtual or may be real -- either way, the result needs * to be passed to NSS_CMSMessage_Destroy later (as does the original). */extern NSSCMSMessage *NSS_CMSMessage_Copy(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_GetArena - return a pointer to the message's arena pool */extern PLArenaPool *NSS_CMSMessage_GetArena(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_GetContentInfo - return a pointer to the top level contentInfo */extern NSSCMSContentInfo *NSS_CMSMessage_GetContentInfo(NSSCMSMessage *cmsg);/* * Return a pointer to the actual content. * In the case of those types which are encrypted, this returns the *plain* content. * In case of nested contentInfos, this descends and retrieves the innermost content. */extern SECItem *NSS_CMSMessage_GetContent(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_ContentLevelCount - count number of levels of CMS content objects in this message * * CMS data content objects do not count. */extern intNSS_CMSMessage_ContentLevelCount(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_ContentLevel - find content level #n * * CMS data content objects do not count. */extern NSSCMSContentInfo *NSS_CMSMessage_ContentLevel(NSSCMSMessage *cmsg, int n);/* * NSS_CMSMessage_ContainsCertsOrCrls - see if message contains certs along the way */extern PRBoolNSS_CMSMessage_ContainsCertsOrCrls(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_IsEncrypted - see if message contains a encrypted submessage */extern PRBoolNSS_CMSMessage_IsEncrypted(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_IsSigned - see if message contains a signed submessage * * If the CMS message has a SignedData with a signature (not just a SignedData) * return true; false otherwise. This can/should be called before calling * VerifySignature, which will always indicate failure if no signature is * present, but that does not mean there even was a signature! * Note that the content itself can be empty (detached content was sent * another way); it is the presence of the signature that matters. */extern PRBoolNSS_CMSMessage_IsSigned(NSSCMSMessage *cmsg);/* * NSS_CMSMessage_IsContentEmpty - see if content is empty * * returns PR_TRUE is innermost content length is < minLen * XXX need the encrypted content length (why?) */extern PRBoolNSS_CMSMessage_IsContentEmpty(NSSCMSMessage *cmsg, unsigned int minLen);/************************************************************************ * cmscinfo.c - CMS contentInfo methods ************************************************************************//* * NSS_CMSContentInfo_Destroy - destroy a CMS contentInfo and all of its sub-pieces. */extern voidNSS_CMSContentInfo_Destroy(NSSCMSContentInfo *cinfo);/* * NSS_CMSContentInfo_GetChildContentInfo - get content's contentInfo (if it exists) */extern NSSCMSContentInfo *NSS_CMSContentInfo_GetChildContentInfo(NSSCMSContentInfo *cinfo);/* * NSS_CMSContentInfo_SetContent - set cinfo's content type & content to CMS object */extern SECStatusNSS_CMSContentInfo_SetContent(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECOidTag type, void *ptr);/* * NSS_CMSContentInfo_SetContent_XXXX - typesafe wrappers for NSS_CMSContentInfo_SetType * set cinfo's content type & content to CMS object */extern SECStatusNSS_CMSContentInfo_SetContent_Data(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, SECItem *data, PRBool detached);extern SECStatusNSS_CMSContentInfo_SetContent_SignedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSSignedData *sigd);extern SECStatusNSS_CMSContentInfo_SetContent_EnvelopedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEnvelopedData *envd);extern SECStatusNSS_CMSContentInfo_SetContent_DigestedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSDigestedData *digd);extern SECStatusNSS_CMSContentInfo_SetContent_EncryptedData(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo, NSSCMSEncryptedData *encd);/* * NSS_CMSContentInfo_GetContent - get pointer to inner content * * needs to be casted... */extern void *NSS_CMSContentInfo_GetContent(NSSCMSContentInfo *cinfo);/* * NSS_CMSContentInfo_GetInnerContent - get pointer to innermost content * * this is typically only called by NSS_CMSMessage_GetContent() */extern SECItem *NSS_CMSContentInfo_GetInnerContent(NSSCMSContentInfo *cinfo);/* * NSS_CMSContentInfo_GetContentType{Tag,OID} - find out (saving pointer to lookup result * for future reference) and return the inner content type. */extern SECOidTagNSS_CMSContentInfo_GetContentTypeTag(NSSCMSContentInfo *cinfo);extern SECItem *NSS_CMSContentInfo_GetContentTypeOID(NSSCMSContentInfo *cinfo);/* * NSS_CMSContentInfo_GetContentEncAlgTag - find out (saving pointer to lookup result * for future reference) and return the content encryption algorithm tag. */extern SECOidTagNSS_CMSContentInfo_GetContentEncAlgTag(NSSCMSContentInfo *cinfo);/* * NSS_CMSContentInfo_GetContentEncAlg - find out and return the content encryption algorithm tag. */extern SECAlgorithmID *NSS_CMSContentInfo_GetContentEncAlg(NSSCMSContentInfo *cinfo);extern SECStatusNSS_CMSContentInfo_SetContentEncAlg(PLArenaPool *poolp, NSSCMSContentInfo *cinfo, SECOidTag bulkalgtag, SECItem *parameters, int keysize);extern SECStatusNSS_CMSContentInfo_SetContentEncAlgID(PLArenaPool *poolp, NSSCMSContentInfo *cinfo, SECAlgorithmID *algid, int keysize);extern voidNSS_CMSContentInfo_SetBulkKey(NSSCMSContentInfo *cinfo, PK11SymKey *bulkkey);extern PK11SymKey *NSS_CMSContentInfo_GetBulkKey(NSSCMSContentInfo *cinfo);extern intNSS_CMSContentInfo_GetBulkKeySize(NSSCMSContentInfo *cinfo);/************************************************************************ * cmsutil.c - CMS misc utility functions ************************************************************************//* * NSS_CMSArray_SortByDER - sort array of objects by objects' DER encoding * * make sure that the order of the objects guarantees valid DER (which must be * in lexigraphically ascending order for a SET OF); if reordering is necessary it
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?