2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * SecTrustSettingsPriv.h - TrustSettings SPI functions.
28 #ifndef _SEC_TRUST_SETTINGS_PRIV_H_
29 #define _SEC_TRUST_SETTINGS_PRIV_H_
31 #include <CoreFoundation/CoreFoundation.h>
32 #include <Security/cssmtype.h>
33 #include <Security/SecPolicy.h>
34 #include <Security/SecCertificate.h>
35 #include <Security/SecTrustSettings.h>
42 * Fundamental routine used by TP to ascertain status of one cert.
44 * Returns true in *foundMatchingEntry if a trust setting matching
45 * specific constraints was found for the cert. Returns true in
46 * *foundAnyEntry if any entry was found for the cert, even if it
47 * did not match the specified constraints. The TP uses this to
48 * optimize for the case where a cert is being evaluated for
49 * one type of usage, and then later for another type. If
50 * foundAnyEntry is false, the second evaluation need not occur.
52 * Returns the domain in which a setting was found in *foundDomain.
54 * Allowed errors applying to the specified cert evaluation
55 * are returned in a mallocd array in *allowedErrors and must
58 OSStatus
SecTrustSettingsEvaluateCert(
59 CFStringRef certHashStr
,
60 /* parameters describing the current cert evalaution */
61 const CSSM_OID
*policyOID
,
62 const char *policyString
, /* optional */
63 uint32 policyStringLen
,
64 SecTrustSettingsKeyUsage keyUsage
, /* optional */
65 bool isRootCert
, /* for checking default setting */
67 SecTrustSettingsDomain
*foundDomain
,
68 CSSM_RETURN
**allowedErrors
, /* mallocd and RETURNED */
69 uint32
*numAllowedErrors
, /* RETURNED */
70 SecTrustSettingsResult
*resultType
, /* RETURNED */
71 bool *foundMatchingEntry
,/* RETURNED */
72 bool *foundAnyEntry
); /* RETURNED */
75 * Obtain trusted certs which match specified usage.
76 * Only certs with a SecTrustSettingsResult of
77 * kSecTrustSettingsResultTrustRoot or
78 * or kSecTrustSettingsResultTrustAsRoot will be returned.
80 * To be used by SecureTransport for its (hopefully soon-to-be-
81 * deprecated) SSLSetTrustedRoots() call; I hope nothing else has
84 * Caller must CFRelease the returned CFArrayRef.
86 OSStatus
SecTrustSettingsCopyQualifiedCerts(
87 const CSSM_OID
*policyOID
,
88 const char *policyString
, /* optional */
89 uint32 policyStringLen
,
90 SecTrustSettingsKeyUsage keyUsage
, /* optional */
91 CFArrayRef
*certArray
); /* RETURNED */
94 * Obtain unrestricted root certificates from the specified domain(s).
95 * Only returns root certificates with no usage constraints.
96 * Caller must CFRelease the returned CFArrayRef.
98 OSStatus
SecTrustSettingsCopyUnrestrictedRoots(
101 Boolean systemDomain
,
102 CFArrayRef
*certArray
); /* RETURNED */
105 * Obtain a string representing a cert's SHA1 digest. This string is
106 * the key used to look up per-cert trust settings in a TrustSettings record.
108 CFStringRef
SecTrustSettingsCertHashStrFromCert(
109 SecCertificateRef certRef
);
111 CFStringRef
SecTrustSettingsCertHashStrFromData(
116 * Add a cert's TrustSettings to a non-persistent TrustSettings record.
117 * Primarily intended for use in creating a system TrustSettings record
118 * (which is itself immutable via this module).
120 * The settingsIn argument is an external representation of a TrustSettings
121 * record, obtained from this function or from
122 * SecTrustSettingsCreateExternalRepresentation().
123 * If settingsIn is NULL, a new (empty) TrustSettings will be created.
125 * The certRef and trustSettingsDictOrArray arguments are as in
126 * SecTrustSettingsSetTrustSettings(). May be NULL, when e.g. creating
127 * a new and empty TrustSettings record.
129 * The external representation is written to the settingOut argument,
130 * which must eventually be CFReleased by the caller.
132 OSStatus
SecTrustSettingsSetTrustSettingsExternal(
133 CFDataRef settingsIn
, /* optional */
134 SecCertificateRef certRef
, /* optional */
135 CFTypeRef trustSettingsDictOrArray
, /* optional */
136 CFDataRef
*settingsOut
); /* RETURNED */
142 #endif /* _SEC_TRUST_SETTINGS_PRIV_H_ */