2 * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
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
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.
18 #ifndef _SECURITY_SECCERTIFICATEPRIV_H_
19 #define _SECURITY_SECCERTIFICATEPRIV_H_
21 #include <Security/SecBase.h>
22 #include <Security/cssmtype.h>
23 #include <CoreFoundation/CFArray.h>
25 #if defined(__cplusplus)
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).
36 OSStatus
SecCertificateCopyPublicKey(SecCertificateRef certificate
, SecKeyRef
*key
);
38 OSStatus
SecCertificateGetAlgorithmID(SecCertificateRef certificate
,const CSSM_X509_ALGORITHM_IDENTIFIER
**algid
);
40 OSStatus
SecCertificateGetCommonName(SecCertificateRef certificate
, CFStringRef
*commonName
);
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
);
46 OSStatus
SecCertificateCopyEmailAddresses(SecCertificateRef certificate
, CFArrayRef
*emailAddresses
);
49 * Private API to infer a display name for a SecCertificateRef which
50 * may or may not be in a keychain.
52 OSStatus
SecCertificateInferLabel(SecCertificateRef certificate
, CFStringRef
*label
);
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.
60 const CSSM_DATA
*SecInferLabelFromX509Name(
61 const CSSM_X509_NAME
*x509Name
);
63 /* Convenience functions for searching
66 OSStatus
SecCertificateFindByIssuerAndSN(CFTypeRef keychainOrArray
, const CSSM_DATA
*issuer
,
67 const CSSM_DATA
*serialNumber
, SecCertificateRef
*certificate
);
69 OSStatus
SecCertificateFindBySubjectKeyID(CFTypeRef keychainOrArray
, const CSSM_DATA
*subjectKeyID
,
70 SecCertificateRef
*certificate
);
72 OSStatus
SecCertificateFindByEmail(CFTypeRef keychainOrArray
, const char *emailAddress
,
73 SecCertificateRef
*certificate
);
76 /* These should go to SecKeychainSearchPriv.h. */
77 OSStatus
SecKeychainSearchCreateForCertificateByIssuerAndSN(CFTypeRef keychainOrArray
, const CSSM_DATA
*issuer
,
78 const CSSM_DATA
*serialNumber
, SecKeychainSearchRef
*searchRef
);
80 OSStatus
SecKeychainSearchCreateForCertificateBySubjectKeyID(CFTypeRef keychainOrArray
, const CSSM_DATA
*subjectKeyID
,
81 SecKeychainSearchRef
*searchRef
);
83 OSStatus
SecKeychainSearchCreateForCertificateByEmail(CFTypeRef keychainOrArray
, const char *emailAddress
,
84 SecKeychainSearchRef
*searchRef
);
87 #if defined(__cplusplus)
91 #endif /* !_SECURITY_SECCERTIFICATEPRIV_H_ */