5 * Created by john on Wed Mar 12 2003.
6 * Copyright (c) 2003 __MyCompanyName__. All rights reserved.
13 #include <Security/SecCmsBase.h>
14 #include <Security/nameTemplates.h>
15 #include <Security/SecCertificate.h>
16 #include <CoreFoundation/CFDate.h>
17 #include <Security/SecTrust.h>
20 /************************************************************************/
23 typedef void CERTVerifyLog
;
25 void CERT_NormalizeX509NameNSS(NSS_Name
*nssName
);
27 SecIdentityRef
CERT_FindIdentityByUsage(SecKeychainRef keychainOrArray
,
28 char *nickname
, SECCertUsage usage
, Boolean validOnly
, void *proto_win
);
30 SecCertificateRef
CERT_FindUserCertByUsage(SecKeychainRef dbhandle
,
31 char *nickname
,SECCertUsage usage
,Boolean validOnly
,void *proto_win
);
33 // Find a certificate in the database by a email address or nickname
34 // "name" is the email address or nickname to look up
35 SecCertificateRef
CERT_FindCertByNicknameOrEmailAddr(SecKeychainRef dbhandle
, char *name
);
37 SecPublicKeyRef
SECKEY_CopyPublicKey(SecPublicKeyRef pubKey
);
38 void SECKEY_DestroyPublicKey(SecPublicKeyRef pubKey
);
39 SecPublicKeyRef
SECKEY_CopyPrivateKey(SecPublicKeyRef privKey
);
40 void SECKEY_DestroyPrivateKey(SecPublicKeyRef privKey
);
41 void CERT_DestroyCertificate(SecCertificateRef cert
);
42 SecCertificateRef
CERT_DupCertificate(SecCertificateRef cert
);
44 // from security/nss/lib/certdb/cert.h
48 CERTCertificate * -> SecCertificateRef
49 SECKEYPublicKey * -> SecPublicKeyRef
50 CERTCertDBHandle * -> SecKeychainRef
51 CERT_GetDefaultCertDB -> OSStatus SecKeychainCopyDefault(SecKeychainRef *keychain);
52 CERTCertificateList * -> CFArrayRef
55 // Generate a certificate chain from a certificate.
57 CFArrayRef
CERT_CertChainFromCert(SecCertificateRef cert
, SECCertUsage usage
,Boolean includeRoot
);
59 CFArrayRef
CERT_CertListFromCert(SecCertificateRef cert
);
61 CFArrayRef
CERT_DupCertList(CFArrayRef oldList
);
63 // Extract a public key object from a SubjectPublicKeyInfo
64 SecPublicKeyRef
CERT_ExtractPublicKey(SecCertificateRef cert
);
66 SECStatus
CERT_CheckCertUsage (SecCertificateRef cert
,unsigned char usage
);
68 // Find a certificate in the database by a email address
69 // "emailAddr" is the email address to look up
70 SecCertificateRef
CERT_FindCertByEmailAddr(SecKeychainRef keychainOrArray
, char *emailAddr
);
72 // Find a certificate in the database by a DER encoded certificate
73 // "derCert" is the DER encoded certificate
74 SecCertificateRef
CERT_FindCertByDERCert(SecKeychainRef keychainOrArray
, const SECItem
*derCert
);
76 // Generate a certificate key from the issuer and serialnumber, then look it up in the database.
77 // Return the cert if found. "issuerAndSN" is the issuer and serial number to look for
78 SecCertificateRef
CERT_FindCertByIssuerAndSN (CFTypeRef keychainOrArray
,
79 CSSM_DATA_PTR
*rawCerts
, PRArenaPool
*pl
, const SecCmsIssuerAndSN
*issuerAndSN
);
81 SecCertificateRef
CERT_FindCertBySubjectKeyID (CFTypeRef keychainOrArray
,
82 CSSM_DATA_PTR
*rawCerts
, const SECItem
*subjKeyID
);
84 SecIdentityRef
CERT_FindIdentityByIssuerAndSN (CFTypeRef keychainOrArray
, const SecCmsIssuerAndSN
*issuerAndSN
);
86 SecIdentityRef
CERT_FindIdentityBySubjectKeyID (CFTypeRef keychainOrArray
, const SECItem
*subjKeyID
);
88 // find the smime symmetric capabilities profile for a given cert
89 SECItem
*CERT_FindSMimeProfile(SecCertificateRef cert
);
91 // Return the decoded value of the subjectKeyID extension. The caller should
92 // free up the storage allocated in retItem->data.
93 SECStatus
CERT_FindSubjectKeyIDExtension (SecCertificateRef cert
, SECItem
*retItem
);
95 // Extract the issuer and serial number from a certificate
96 SecCmsIssuerAndSN
*CERT_GetCertIssuerAndSN(PRArenaPool
*pl
, SecCertificateRef cert
);
98 // import a collection of certs into the temporary or permanent cert database
99 SECStatus
CERT_ImportCerts(SecKeychainRef keychain
, SECCertUsage usage
,unsigned int ncerts
,
100 SECItem
**derCerts
,SecCertificateRef
**retCerts
, Boolean keepCerts
,Boolean caOnly
, char *nickname
);
102 SECStatus
CERT_SaveSMimeProfile(SecCertificateRef cert
, SECItem
*emailProfile
,SECItem
*profileTime
);
104 // Check the hostname to make sure that it matches the shexp that
105 // is given in the common name of the certificate.
106 SECStatus
CERT_VerifyCertName(SecCertificateRef cert
, const char *hostname
);
108 SECStatus
CERT_VerifyCert(SecKeychainRef keychainOrArray
, SecCertificateRef cert
,
109 const CSSM_DATA_PTR
*otherCerts
, /* intermediates */
110 CFTypeRef policies
, CFAbsoluteTime stime
, SecTrustRef
*trustRef
);
112 CFTypeRef
CERT_PolicyForCertUsage(SECCertUsage certUsage
);
114 /************************************************************************/
117 #endif /* _CERT_H_ */