]> git.saurik.com Git - apple/security.git/blob - Keychain/SecCertificatePriv.h
Security-176.tar.gz
[apple/security.git] / Keychain / SecCertificatePriv.h
1 /*
2 * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18 #ifndef _SECURITY_SECCERTIFICATEPRIV_H_
19 #define _SECURITY_SECCERTIFICATEPRIV_H_
20
21 #include <Security/SecBase.h>
22 #include <Security/cssmtype.h>
23 #include <CoreFoundation/CFArray.h>
24
25 #if defined(__cplusplus)
26 extern "C" {
27 #endif
28
29 /*!
30 @function SecCertificateGetPublicKey
31 @abstract Retrieves the public key for a given certificate.
32 @param certificate A reference to the certificate from which to retrieve the data.
33 @param data On return, a pointer to the data for the certificate specified. The caller must allocate the space for a CSSM_DATA structure before calling this function. This data pointer is only guaranteed to remain valid as long as the certificate remains unchanged and valid.
34 @result A result code. See "Security Error Codes" (SecBase.h).
35 */
36 OSStatus SecCertificateCopyPublicKey(SecCertificateRef certificate, SecKeyRef *key);
37
38 OSStatus SecCertificateGetAlgorithmID(SecCertificateRef certificate,const CSSM_X509_ALGORITHM_IDENTIFIER **algid);
39
40 OSStatus SecCertificateGetCommonName(SecCertificateRef certificate, CFStringRef *commonName);
41
42 /* @@@ Obsoleted by SecCertificateCopyEmailAddresses(), also really should of been named
43 SecCertificateCopyEmailAddress() since the returned address is not autoreleased. */
44 OSStatus SecCertificateGetEmailAddress(SecCertificateRef certificate, CFStringRef *emailAddress);
45
46 OSStatus SecCertificateCopyEmailAddresses(SecCertificateRef certificate, CFArrayRef *emailAddresses);
47
48 /*
49 * Private API to infer a display name for a SecCertificateRef which
50 * may or may not be in a keychain.
51 */
52 OSStatus SecCertificateInferLabel(SecCertificateRef certificate, CFStringRef *label);
53
54
55 /*
56 * Subset of the above, useful for both certs and CRLs.
57 * Infer printable label for a given an CSSM_X509_NAME. Returns NULL
58 * if no appropriate printable name found.
59 */
60 const CSSM_DATA *SecInferLabelFromX509Name(
61 const CSSM_X509_NAME *x509Name);
62
63 /* Convenience functions for searching
64 */
65
66 OSStatus SecCertificateFindByIssuerAndSN(CFTypeRef keychainOrArray, const CSSM_DATA *issuer,
67 const CSSM_DATA *serialNumber, SecCertificateRef *certificate);
68
69 OSStatus SecCertificateFindBySubjectKeyID(CFTypeRef keychainOrArray, const CSSM_DATA *subjectKeyID,
70 SecCertificateRef *certificate);
71
72 OSStatus SecCertificateFindByEmail(CFTypeRef keychainOrArray, const char *emailAddress,
73 SecCertificateRef *certificate);
74
75
76 /* These should go to SecKeychainSearchPriv.h. */
77 OSStatus SecKeychainSearchCreateForCertificateByIssuerAndSN(CFTypeRef keychainOrArray, const CSSM_DATA *issuer,
78 const CSSM_DATA *serialNumber, SecKeychainSearchRef *searchRef);
79
80 OSStatus SecKeychainSearchCreateForCertificateBySubjectKeyID(CFTypeRef keychainOrArray, const CSSM_DATA *subjectKeyID,
81 SecKeychainSearchRef *searchRef);
82
83 OSStatus SecKeychainSearchCreateForCertificateByEmail(CFTypeRef keychainOrArray, const char *emailAddress,
84 SecKeychainSearchRef *searchRef);
85
86
87 #if defined(__cplusplus)
88 }
89 #endif
90
91 #endif /* !_SECURITY_SECCERTIFICATEPRIV_H_ */