cert.h
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C头文件 代码 · 共 1,391 行 · 第 1/3 页
H
1,391 行
/* * 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. *//* * cert.h - public data structures and prototypes for the certificate library * * $Id: cert.h,v 1.3 2000/09/09 06:08:43 nelsonb%netscape.com Exp $ */#ifndef _CERT_H_#define _CERT_H_#include "plarena.h"#include "plhash.h"#include "prlong.h"#include "prlog.h"#include "seccomon.h"#include "secdert.h"#include "secoidt.h"#include "keyt.h"#include "certt.h"SEC_BEGIN_PROTOS /**************************************************************************** * * RFC1485 ascii to/from X.? RelativeDistinguishedName (aka CERTName) * ****************************************************************************//*** Convert an ascii RFC1485 encoded name into its CERTName equivalent.*/extern CERTName *CERT_AsciiToName(char *string);/*** Convert an CERTName into its RFC1485 encoded equivalent.*/extern char *CERT_NameToAscii(CERTName *name);extern CERTAVA *CERT_CopyAVA(PRArenaPool *arena, CERTAVA *src);/*** Examine an AVA and return the tag that refers to it. The AVA tags are** defined as SEC_OID_AVA*.*/extern SECOidTag CERT_GetAVATag(CERTAVA *ava);/*** Compare two AVA's, returning the difference between them.*/extern SECComparison CERT_CompareAVA(CERTAVA *a, CERTAVA *b);/*** Create an RDN (relative-distinguished-name). The argument list is a** NULL terminated list of AVA's.*/extern CERTRDN *CERT_CreateRDN(PRArenaPool *arena, CERTAVA *avas, ...);/*** Make a copy of "src" storing it in "dest".*/extern SECStatus CERT_CopyRDN(PRArenaPool *arena, CERTRDN *dest, CERTRDN *src);/*** Destory an RDN object.** "rdn" the RDN to destroy** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void CERT_DestroyRDN(CERTRDN *rdn, PRBool freeit);/*** Add an AVA to an RDN.** "rdn" the RDN to add to** "ava" the AVA to add*/extern SECStatus CERT_AddAVA(PRArenaPool *arena, CERTRDN *rdn, CERTAVA *ava);/*** Compare two RDN's, returning the difference between them.*/extern SECComparison CERT_CompareRDN(CERTRDN *a, CERTRDN *b);/*** Create an X.500 style name using a NULL terminated list of RDN's.*/extern CERTName *CERT_CreateName(CERTRDN *rdn, ...);/*** Make a copy of "src" storing it in "dest". Memory is allocated in** "dest" for each of the appropriate sub objects. Memory is not freed in** "dest" before allocation is done (use CERT_DestroyName(dest, PR_FALSE) to** do that).*/extern SECStatus CERT_CopyName(PRArenaPool *arena, CERTName *dest, CERTName *src);/*** Destroy a Name object.** "name" the CERTName to destroy** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void CERT_DestroyName(CERTName *name);/*** Add an RDN to a name.** "name" the name to add the RDN to** "rdn" the RDN to add to name*/extern SECStatus CERT_AddRDN(CERTName *name, CERTRDN *rdn);/*** Compare two names, returning the difference between them.*/extern SECComparison CERT_CompareName(CERTName *a, CERTName *b);/*** Convert a CERTName into something readable*/extern char *CERT_FormatName (CERTName *name);/*** Convert a der-encoded integer to a hex printable string form.** Perhaps this should be a SEC function but it's only used for certs.*/extern char *CERT_Hexify (SECItem *i, int do_colon);/************************************************************************************** * * Certificate handling operations * **************************************************************************************//*** Create a new validity object given two unix time values.** "notBefore" the time before which the validity is not valid** "notAfter" the time after which the validity is not valid*/extern CERTValidity *CERT_CreateValidity(int64 notBefore, int64 notAfter);/*** Destroy a validity object.** "v" the validity to destroy** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void CERT_DestroyValidity(CERTValidity *v);/*** Copy the "src" object to "dest". Memory is allocated in "dest" for** each of the appropriate sub-objects. Memory in "dest" is not freed** before memory is allocated (use CERT_DestroyValidity(v, PR_FALSE) to do** that).*/extern SECStatus CERT_CopyValidity (PRArenaPool *arena, CERTValidity *dest, CERTValidity *src);/*** Create a new certificate object. The result must be wrapped with an** CERTSignedData to create a signed certificate.** "serialNumber" the serial number** "issuer" the name of the certificate issuer** "validity" the validity period of the certificate** "req" the certificate request that prompted the certificate issuance*/extern CERTCertificate *CERT_CreateCertificate (unsigned long serialNumber, CERTName *issuer, CERTValidity *validity, CERTCertificateRequest *req);/*** Destroy a certificate object** "cert" the certificate to destroy** NOTE: certificate's are reference counted. This call decrements the** reference count, and if the result is zero, then the object is destroyed** and optionally freed.*/extern void CERT_DestroyCertificate(CERTCertificate *cert);/*** Make a shallow copy of a certificate "c". Just increments the** reference count on "c".*/extern CERTCertificate *CERT_DupCertificate(CERTCertificate *c);/*** Create a new certificate request. This result must be wrapped with an** CERTSignedData to create a signed certificate request.** "name" the subject name (who the certificate request is from)** "spki" describes/defines the public key the certificate is for** "attributes" if non-zero, some optional attribute data*/extern CERTCertificateRequest *CERT_CreateCertificateRequest (CERTName *name, CERTSubjectPublicKeyInfo *spki, SECItem **attributes);/*** Destroy a certificate-request object** "r" the certificate-request to destroy** "freeit" if PR_TRUE then free the object as well as its sub-objects*/extern void CERT_DestroyCertificateRequest(CERTCertificateRequest *r);/*** Extract a public key object from a SubjectPublicKeyInfo*/extern SECKEYPublicKey *CERT_ExtractPublicKey(CERTCertificate *cert);/* * used to get a public key with Key Material ID. Only used for fortezza V1 * certificates. */extern SECKEYPublicKey *CERT_KMIDPublicKey(CERTCertificate *cert);/*** Retrieve the Key Type associated with the cert we're dealing with*/extern KeyType CERT_GetCertKeyType (CERTSubjectPublicKeyInfo *spki);/*** Initialize the certificate database. This is called to create** the initial list of certificates in the database.*/extern SECStatus CERT_InitCertDB(CERTCertDBHandle *handle);/*** Default certificate database routines*/extern void CERT_SetDefaultCertDB(CERTCertDBHandle *handle);extern CERTCertDBHandle *CERT_GetDefaultCertDB(void);extern CERTCertList *CERT_GetCertChainFromCert(CERTCertificate *cert, int64 time, SECCertUsage usage);/************************************************************************************ * * X.500 Name handling operations * ************************************************************************************//*** Create an AVA (attribute-value-assertion)** "arena" the memory arena to alloc from** "kind" is one of SEC_OID_AVA_*** "valueType" is one of DER_PRINTABLE_STRING, DER_IA5_STRING, or** DER_T61_STRING** "value" is the null terminated string containing the value*/extern CERTAVA *CERT_CreateAVA (PRArenaPool *arena, SECOidTag kind, int valueType, char *value);/*** Extract the Distinguished Name from a DER encoded certificate** "derCert" is the DER encoded certificate** "derName" is the SECItem that the name is returned in*/extern SECStatus CERT_NameFromDERCert(SECItem *derCert, SECItem *derName);/*** Extract the Issuers Distinguished Name from a DER encoded certificate** "derCert" is the DER encoded certificate** "derName" is the SECItem that the name is returned in*/extern SECStatus CERT_IssuerNameFromDERCert(SECItem *derCert, SECItem *derName);/*** Generate a database search key for a certificate, based on the** issuer and serial number.** "arena" the memory arena to alloc from** "derCert" the DER encoded certificate** "key" the returned key*/extern SECStatus CERT_KeyFromDERCert(PRArenaPool *arena, SECItem *derCert, SECItem *key);extern SECStatus CERT_KeyFromIssuerAndSN(PRArenaPool *arena, SECItem *issuer, SECItem *sn, SECItem *key);/*** Generate a database search key for a crl, based on the** issuer.** "arena" the memory arena to alloc from** "derCrl" the DER encoded crl** "key" the returned key*/extern SECStatus CERT_KeyFromDERCrl(PRArenaPool *arena, SECItem *derCrl, SECItem *key);/*** Open the certificate database. Use callback to get name of database.*/extern SECStatus CERT_OpenCertDB(CERTCertDBHandle *handle, PRBool readOnly, CERTDBNameFunc namecb, void *cbarg);/* Open the certificate database. Use given filename for database. */extern SECStatus CERT_OpenCertDBFilename(CERTCertDBHandle *handle, char *certdbname, PRBool readOnly);/*** Open and initialize a cert database that is entirely in memory. This** can be used when the permanent database can not be opened or created.*/extern SECStatus CERT_OpenVolatileCertDB(CERTCertDBHandle *handle);/*** Check the hostname to make sure that it matches the shexp that** is given in the common name of the certificate.*/extern SECStatus CERT_VerifyCertName(CERTCertificate *cert, const char *hostname);/*** Add a domain name to the list of names that the user has explicitly** allowed (despite cert name mismatches) for use with a server cert.*/extern SECStatus CERT_AddOKDomainName(CERTCertificate *cert, const char *hostname);/*** Decode a DER encoded certificate into an CERTCertificate structure** "derSignedCert" is the DER encoded signed certificate** "copyDER" is true if the DER should be copied, false if the** existing copy should be referenced** "nickname" is the nickname to use in the database. If it is NULL** then a temporary nickname is generated.*/extern CERTCertificate *CERT_DecodeDERCertificate (SECItem *derSignedCert, PRBool copyDER, char *nickname);/*** Decode a DER encoded CRL/KRL into an CERTSignedCrl structure** "derSignedCrl" is the DER encoded signed crl/krl.** "type" is this a CRL or KRL.*/#define SEC_CRL_TYPE 1#define SEC_KRL_TYPE 0extern CERTSignedCrl *CERT_DecodeDERCrl (PRArenaPool *arena, SECItem *derSignedCrl,int type);/* Validate CRL then import it to the dbase. If there is already a CRL with the * same CA in the dbase, it will be replaced if derCRL is more up to date. * If the process successes, a CRL will be returned. Otherwise, a NULL will * be returned. The caller should call PORT_GetError() for the exactly error * code. */extern CERTSignedCrl *CERT_ImportCRL (CERTCertDBHandle *handle, SECItem *derCRL, char *url, int type, void * wincx);extern void CERT_DestroyCrl (CERTSignedCrl *crl);/*** Decode a certificate and put it into the temporary certificate database*/extern CERTCertificate *CERT_NewTempCertificate (CERTCertDBHandle *handle, SECItem *derCert, char *nickname, PRBool isperm, PRBool copyDER);/*** Add a certificate to the temporary database.** "dbCert" is the certificate from the perm database.** "isperm" indicates if the cert is in the permanent database.*/extern CERTCertificate *CERT_AddTempCertificate (CERTCertDBHandle *handle, certDBEntryCert *entry, PRBool isperm);/*** Add a temporary certificate to the permanent database.** "cert" is the temporary cert** "nickname" is the permanent nickname to use** "trust" is the certificate trust parameters to assign to the cert*/extern SECStatusCERT_AddTempCertToPerm (CERTCertificate *cert, char *nickname, CERTCertTrust *trust);/*** Find a certificate in the database** "key" is the database key to look for*/extern CERTCertificate *CERT_FindCertByKey(CERTCertDBHandle *handle, SECItem *key);/* * Lookup a certificate in the databases without locking * "certKey" is the database key to look for * * XXX - this should be internal, but pkcs 11 needs to call it during a * traversal. */CERTCertificate *CERT_FindCertByKeyNoLocking(CERTCertDBHandle *handle, SECItem *certKey);/*** Find a certificate in the database by name** "name" is the distinguished name to look up*/extern CERTCertificate *CERT_FindCertByName (CERTCertDBHandle *handle, SECItem *name);/*** Find a certificate in the database by name** "name" is the distinguished name to look up (in ascii)*/extern CERTCertificate *CERT_FindCertByNameString (CERTCertDBHandle *handle, char *name);/*** Find a certificate in the database by name and keyid** "name" is the distinguished name to look up** "keyID" is the value of the subjectKeyID to match*/extern CERTCertificate *CERT_FindCertByKeyID (CERTCertDBHandle *handle, SECItem *name, SECItem *keyID);/*** Generate a certificate key from the issuer and serialnumber, then look it** up in the database. Return the cert if found.** "issuerAndSN" is the issuer and serial number to look for*/extern CERTCertificate *CERT_FindCertByIssuerAndSN (CERTCertDBHandle *handle, CERTIssuerAndSN *issuerAndSN);/*** Find a certificate in the database by a nickname** "nickname" is the ascii string nickname to look for*/extern CERTCertificate *CERT_FindCertByNickname (CERTCertDBHandle *handle, char *nickname);/*** Find a certificate in the database by a DER encoded certificate** "derCert" is the DER encoded certificate*/extern CERTCertificate *
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?