cert.h

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

H
1,391
字号
CERT_FindCertByDERCert(CERTCertDBHandle *handle, SECItem *derCert);/*** Find a certificate in the database by a email address**	"emailAddr" is the email address to look up*/CERTCertificate *CERT_FindCertByEmailAddr(CERTCertDBHandle *handle, char *emailAddr);/*** Find a certificate in the database by a email address or nickname**	"name" is the email address or nickname to look up*/CERTCertificate *CERT_FindCertByNicknameOrEmailAddr(CERTCertDBHandle *handle, char *name);/*** Find a certificate in the database by a digest of a subject public key**	"spkDigest" is the digest to look up*/extern CERTCertificate *CERT_FindCertBySPKDigest(CERTCertDBHandle *handle, SECItem *spkDigest);/* * Find the issuer of a cert */CERTCertificate *CERT_FindCertIssuer(CERTCertificate *cert, int64 validTime, SECCertUsage usage);/*** Delete a certificate from the temporary database**	"cert" is the certificate to be deleted*/extern SECStatus CERT_DeleteTempCertificate(CERTCertificate *cert);/*** Flush and close the permanent database.*/extern void CERT_ClosePermCertDB(CERTCertDBHandle *handle);/*** Check the validity times of a certificate vs. time 't', allowing** some slop for broken clocks and stuff.**	"cert" is the certificate to be checked**	"t" is the time to check against**	"allowOverride" if true then check to see if the invalidity has**		been overridden by the user.*/extern SECCertTimeValidity CERT_CheckCertValidTimes(CERTCertificate *cert,						    int64 t,						    PRBool allowOverride);/*** WARNING - this function is depricated, and will either go away or have**		a new API in the near future.**** Check the validity times of a certificate vs. the current time, allowing** some slop for broken clocks and stuff.**	"cert" is the certificate to be checked*/extern SECStatus CERT_CertTimesValid(CERTCertificate *cert);/*** Extract the validity times from a certificate**	"c" is the certificate**	"notBefore" is the start of the validity period**	"notAfter" is the end of the validity period*/extern SECStatusCERT_GetCertTimes (CERTCertificate *c, int64 *notBefore, int64 *notAfter);/*** Extract the issuer and serial number from a certificate*/extern CERTIssuerAndSN *CERT_GetCertIssuerAndSN(PRArenaPool *, 							CERTCertificate *);/*** verify the signature of a signed data object with a given certificate**	"sd" the signed data object to be verified**	"cert" the certificate to use to check the signature*/extern SECStatus CERT_VerifySignedData(CERTSignedData *sd,				       CERTCertificate *cert,				       int64 t,				       void *wincx);/*** verify a certificate by checking validity times against a certain time,** that we trust the issuer, and that the signature on the certificate is** valid.**	"cert" the certificate to verify**	"checkSig" only check signatures if true*/extern SECStatusCERT_VerifyCert(CERTCertDBHandle *handle, CERTCertificate *cert,		PRBool checkSig, SECCertUsage certUsage, int64 t,		void *wincx, CERTVerifyLog *log);/* same as above, but uses current time */extern SECStatusCERT_VerifyCertNow(CERTCertDBHandle *handle, CERTCertificate *cert,		   PRBool checkSig, SECCertUsage certUsage, void *wincx);/*** This must only be called on a cert that is known to have an issuer** with an invalid time*/extern CERTCertificate *CERT_FindExpiredIssuer (CERTCertDBHandle *handle, CERTCertificate *cert);/*** Read a base64 ascii encoded DER certificate and convert it to our** internal format.**	"certstr" is a null-terminated string containing the certificate*/extern CERTCertificate *CERT_ConvertAndDecodeCertificate(char *certstr);/*** Read a certificate in some foreign format, and convert it to our** internal format.**	"certbuf" is the buffer containing the certificate**	"certlen" is the length of the buffer** NOTE - currently supports netscape base64 ascii encoded raw certs**  and netscape binary DER typed files.*/extern CERTCertificate *CERT_DecodeCertFromPackage(char *certbuf, int certlen);extern SECStatusCERT_ImportCAChain (SECItem *certs, int numcerts, SECCertUsage certUsage);/*** Read a certificate chain in some foreign format, and pass it to a ** callback function.**	"certbuf" is the buffer containing the certificate**	"certlen" is the length of the buffer**	"f" is the callback function**	"arg" is the callback argument*/typedef SECStatus (*CERTImportCertificateFunc)   (void *arg, SECItem **certs, int numcerts);extern SECStatusCERT_DecodeCertPackage(char *certbuf, int certlen, CERTImportCertificateFunc f,		       void *arg);/*** Pretty print a certificate in HTML**	"cert" is the certificate to print**	"showImages" controls whether or not to use about:security URLs**		for subject and issuer images.  This should only be true**		in the browser.*/extern char *CERT_HTMLCertInfo(CERTCertificate *cert, PRBool showImages,			       PRBool showIssuer);/* ** Returns the value of an AVA.  This was a formerly static ** function that has been exposed due to the need to decode** and convert unicode strings to UTF8.  **** XXX This function resides in certhtml.c, should it be** moved elsewhere?*/extern SECItem *CERT_DecodeAVAValue(SECItem *derAVAValue);/*** extract various element strings from a distinguished name.**	"name" the distinguished name*/extern char *CERT_GetCommonName(CERTName *name);extern char *CERT_GetCertificateEmailAddress(CERTCertificate *cert);extern char *CERT_GetCertEmailAddress(CERTName *name);extern char *CERT_GetCommonName(CERTName *name);extern char *CERT_GetCountryName(CERTName *name);extern char *CERT_GetLocalityName(CERTName *name);extern char *CERT_GetStateName(CERTName *name);extern char *CERT_GetOrgName(CERTName *name);extern char *CERT_GetOrgUnitName(CERTName *name);extern char *CERT_GetDomainComponentName(CERTName *name);extern char *CERT_GetCertUid(CERTName *name);/* manipulate the trust parameters of a certificate */extern SECStatus CERT_GetCertTrust(CERTCertificate *cert, CERTCertTrust *trust);extern SECStatusCERT_ChangeCertTrust (CERTCertDBHandle *handle, CERTCertificate *cert,		      CERTCertTrust *trust);extern SECStatusCERT_ChangeCertTrustByUsage(CERTCertDBHandle *certdb, CERTCertificate *cert,			    SECCertUsage usage);/************************************************************************* * * manipulate the extensions of a certificate * ************************************************************************//*** Set up a cert for adding X509v3 extensions.  Returns an opaque handle** used by the next two routines.**	"cert" is the certificate we are adding extensions to*/extern void *CERT_StartCertExtensions(CERTCertificate *cert);/*** Add an extension to a certificate.**	"exthandle" is the handle returned by the previous function**	"idtag" is the integer tag for the OID that should ID this extension**	"value" is the value of the extension**	"critical" is the critical extension flag**	"copyData" is a flag indicating whether the value data should be**		copied.*/extern SECStatus CERT_AddExtension (void *exthandle, int idtag, 			SECItem *value, PRBool critical, PRBool copyData);extern SECStatus CERT_AddExtensionByOID (void *exthandle, SECItem *oid,			 SECItem *value, PRBool critical, PRBool copyData);extern SECStatus CERT_EncodeAndAddExtension   (void *exthandle, int idtag, void *value, PRBool critical,    const SEC_ASN1Template *atemplate);extern SECStatus CERT_EncodeAndAddBitStrExtension   (void *exthandle, int idtag, SECItem *value, PRBool critical);/*** Finish adding cert extensions.  Does final processing on extension** data, putting it in the right format, and freeing any temporary** storage.**	"exthandle" is the handle used to add extensions to a certificate*/extern SECStatus CERT_FinishExtensions(void *exthandle);/* If the extension is found, return its criticality and value.** This allocate storage for the returning extension value.*/extern SECStatus CERT_GetExtenCriticality   (CERTCertExtension **extensions, int tag, PRBool *isCritical);extern voidCERT_DestroyOidSequence(CERTOidSequence *oidSeq);/**************************************************************************** * * DER encode and decode extension values * ****************************************************************************//* Encode the value of the basicConstraint extension.**	arena - where to allocate memory for the encoded value.**	value - extension value to encode**	encodedValue - output encoded value*/extern SECStatus CERT_EncodeBasicConstraintValue   (PRArenaPool *arena, CERTBasicConstraints *value, SECItem *encodedValue);/*** Encode the value of the authorityKeyIdentifier extension.*/extern SECStatus CERT_EncodeAuthKeyID   (PRArenaPool *arena, CERTAuthKeyID *value, SECItem *encodedValue);/*** Encode the value of the crlDistributionPoints extension.*/extern SECStatus CERT_EncodeCRLDistributionPoints   (PRArenaPool *arena, CERTCrlDistributionPoints *value,SECItem *derValue);/*** Decodes a DER encoded basicConstaint extension value into a readable format**	value - decoded value**	encodedValue - value to decoded*/extern SECStatus CERT_DecodeBasicConstraintValue   (CERTBasicConstraints *value, SECItem *encodedValue);/* Decodes a DER encoded authorityKeyIdentifier extension value into a** readable format.**	arena - where to allocate memory for the decoded value**	encodedValue - value to be decoded**	Returns a CERTAuthKeyID structure which contains the decoded value*/extern CERTAuthKeyID *CERT_DecodeAuthKeyID 			(PRArenaPool *arena, SECItem *encodedValue);/* Decodes a DER encoded crlDistributionPoints extension value into a ** readable format.**	arena - where to allocate memory for the decoded value**	der - value to be decoded**	Returns a CERTCrlDistributionPoints structure which contains the **          decoded value*/extern CERTCrlDistributionPoints * CERT_DecodeCRLDistributionPoints   (PRArenaPool *arena, SECItem *der);/* Extract certain name type from a generalName */extern void *CERT_GetGeneralNameByType   (CERTGeneralName *genNames, CERTGeneralNameType type, PRBool derFormat);extern CERTOidSequence *CERT_DecodeOidSequence(SECItem *seqItem);/**************************************************************************** * * Find extension values of a certificate  * ***************************************************************************/extern SECStatus CERT_FindCertExtension   (CERTCertificate *cert, int tag, SECItem *value);extern SECStatus CERT_FindNSCertTypeExtension   (CERTCertificate *cert, SECItem *value);extern char * CERT_FindNSStringExtension (CERTCertificate *cert, int oidtag);extern SECStatus CERT_FindIssuerCertExtension   (CERTCertificate *cert, int tag, SECItem *value);extern SECStatus CERT_FindCertExtensionByOID   (CERTCertificate *cert, SECItem *oid, SECItem *value);extern char *CERT_FindCertURLExtension (CERTCertificate *cert, int tag, 								int catag);/* Returns the decoded value of the authKeyID extension.**   Note that this uses passed in the arena to allocate storage for the result*/extern CERTAuthKeyID * CERT_FindAuthKeyIDExten (PRArenaPool *arena,CERTCertificate *cert);/* Returns the decoded value of the basicConstraint extension. */extern SECStatus CERT_FindBasicConstraintExten   (CERTCertificate *cert, CERTBasicConstraints *value);/* Returns the decoded value of the crlDistributionPoints extension.**  Note that the arena in cert is used to allocate storage for the result*/extern CERTCrlDistributionPoints * CERT_FindCRLDistributionPoints   (CERTCertificate *cert);/* Returns value of the keyUsage extension.  This uses PR_Alloc to allocate ** buffer for the decoded value, The caller should free up the storage ** allocated in value->data.*/extern SECStatus CERT_FindKeyUsageExtension (CERTCertificate *cert, 							SECItem *value);/* Return the decoded value of the subjectKeyID extension. The caller should ** free up the storage allocated in retItem->data.*/extern SECStatus CERT_FindSubjectKeyIDExten (CERTCertificate *cert, 							   SECItem *retItem);/*** If cert is a v3 certificate, and a critical keyUsage extension is included,** then check the usage against the extension value.  If a non-critical ** keyUsage extension is included, this will return SECSuccess without ** checking, since the extension is an advisory field, not a restriction.  ** If cert is not a v3 certificate, this will return SECSuccess.**	cert - certificate**	usage - one of the x.509 v3 the Key Usage Extension flags*/extern SECStatus CERT_CheckCertUsage (CERTCertificate *cert, 							unsigned char usage);/**************************************************************************** * *  CRL v2 Extensions supported routines * ****************************************************************************/extern SECStatus CERT_FindCRLExtensionByOID   (CERTCrl *crl, SECItem *oid, SECItem *value);extern SECStatus CERT_FindCRLExtension   (CERTCrl *crl, int tag, SECItem *value);extern SECStatus   CERT_FindInvalidDateExten (CERTCrl *crl, int64 *value);extern void *CERT_StartCRLExtensions (CERTCrl *crl);extern CERTCertNicknames *CERT_GetCertNicknames (CERTCertDBHandle *handle,						 int what, void *wincx);/*** Finds the crlNumber extension and decodes its value into 'value'*/extern SECStatus CERT_FindCRLNumberExten (CERTCrl *crl, CERTCrlNumber *value);extern void CERT_FreeNicknames(CERTCertNicknames *nicknames);extern PRBool CERT_CompareCerts(CERTCertificate *c1, CERTCertificate *c2);extern PRBool CERT_CompareCertsForRedirection(CERTCertificate *c1,							 CERTCertificate *c2);/*** Generate an array of the Distinguished Names that the given cert database** "trusts"*/extern CERTDistNames *CERT_GetSSLCACerts(CERTCertDBHandle *handle);extern void CERT_FreeDistNames(CERTDistNames *names);/*** Generate an array of Distinguished names from an array of nicknames*/extern CERTDistNames *CERT_DistNamesFromNicknames   (CERTCertDBHandle *handle, char **nicknames, int nnames);/*** Generate a certificate chain from a certificate.*/extern CERTCertificateList *CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage,		       PRBool includeRoot);extern CERTCertificateList *CERT_CertListFromCert(CERTCertificate *cert);extern CERTCertificateList *CERT_DupCertList(CERTCertificateList * oldList);extern void CERT_DestroyCertificateList(CERTCertificateList *list);/* is cert a newer than cert b? */PRBool CERT_IsNewer(CERTCertificate *certa, CERTCertificate *certb);typedef SECStatus (* CERTCertCallback)(CERTCertificate *cert, void *arg);SECStatusCERT_TraversePermCertsForSubject(CERTCertDBHandle *handle, SECItem *derSubject,				 CERTCertCallback cb, void *cbarg);intCERT_NumPermCertsForSubject(CERTCertDBHandle *handle, SECItem *derSubject);SECStatusCERT_TraversePermCertsForNickname(CERTCertDBHandle *handle, char *nickname,				  CERTCertCallback cb, void *cbarg);int

⌨️ 快捷键说明

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