]> git.saurik.com Git - apple/security.git/blob - sec/securityd/SecPolicyServer.h
Security-55163.44.tar.gz
[apple/security.git] / sec / securityd / SecPolicyServer.h
1 /*
2 * Copyright (c) 2008-2010 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*!
25 @header SecPolicyServer
26 The functions provided in SecPolicyServer.h provide an interface to
27 trust policies dealing with certificate revocation.
28 */
29
30 #ifndef _SECURITY_SECPOLICYSERVER_H_
31 #define _SECURITY_SECPOLICYSERVER_H_
32
33 #include <Security/SecPolicyInternal.h>
34
35 #include <securityd/policytree.h>
36 #include <securityd/SecTrustServer.h>
37
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif
41
42 typedef struct OpaqueSecPVC *SecPVCRef;
43
44 struct OpaqueSecPVC {
45 SecPathBuilderRef builder;
46
47 /* @@@ Duplicated from builder, remove. */
48 CFArrayRef policies;
49 CFAbsoluteTime verifyTime;
50
51 SecCertificatePathRef path;
52 CFArrayRef details;
53 CFMutableDictionaryRef info;
54 policy_tree_t valid_policy_tree;
55 CFDictionaryRef callbacks;
56 CFIndex policyIX;
57
58 void *rvcs;
59 unsigned int asyncJobCount;
60
61 bool check_revocation;
62 bool optionally_ev;
63 bool is_ev;
64 bool result;
65 };
66
67 void SecPVCInit(SecPVCRef pvc, SecPathBuilderRef builder, CFArrayRef policies,
68 CFAbsoluteTime verifyTime);
69 void SecPVCDelete(SecPVCRef pvc);
70 void SecPVCSetPath(SecPVCRef pvc, SecCertificatePathRef path,
71 CFArrayRef details);
72 SecPolicyRef SecPVCGetPolicy(SecPVCRef pv);
73 CFAbsoluteTime SecPVCGetVerifyTime(SecPVCRef pv);
74 CFIndex SecPVCGetCertificateCount(SecPVCRef pv);
75 SecCertificateRef SecPVCGetCertificateAtIndex(SecPVCRef pv, CFIndex ix);
76 bool SecPVCIsCertificateAtIndexSelfSigned(SecPVCRef pvc, CFIndex ix);
77 bool SecPVCIsAnchored(SecPVCRef pvc);
78
79 /* Set the string result as the reason for the sub policy check key
80 failing. The policy check function should continue processing if
81 this function returns true. */
82 bool SecPVCSetResult(SecPVCRef pv, CFStringRef key, CFIndex ix,
83 CFTypeRef result);
84 bool SecPVCSetResultForced(SecPVCRef pvc,
85 CFStringRef key, CFIndex ix, CFTypeRef result, bool force);
86
87 /* Enable revocation checking if the rest of the policy checks succeed. */
88 void SecPVCSetCheckRevocation(SecPVCRef pvc);
89
90 /* Run static leaf checks on the path in pvc. */
91 bool SecPVCLeafChecks(SecPVCRef pvc);
92
93 /* Run static parent checks on the path in pvc. */
94 bool SecPVCParentCertificateChecks(SecPVCRef pvc, CFIndex ix);
95
96 /* Check whether an intermediate certificates key has been blacklisted. */
97 bool SecPVCBlackListedKeyChecks(SecPVCRef pvc, CFIndex ix);
98
99 /* Run dynamic checks on the complete path in pvc. Return true if the
100 operation is complete, returns false if an async backgroup request was
101 scheduled. Upon completion of the async background job
102 SecPathBuilderStep() should be called. */
103 bool SecPVCPathChecks(SecPVCRef pvc);
104
105 /* Return 0 if any certs revocation checking failed, the earliest date on
106 which one of the used revocation validation tokens (ocsp response or
107 crl) expires. */
108 CFAbsoluteTime SecPVCGetEarliestNextUpdate(SecPVCRef pvc);
109
110 typedef void (*SecPolicyCheckFunction)(SecPVCRef pv, CFStringRef key);
111
112 /*
113 Used by SecTrust to verify if a particular certificate chain matches
114 this policy. Returns true if the policy accepts the certificate chain.
115 */
116 bool SecPolicyValidate(SecPolicyRef policy, SecPVCRef pvc, CFStringRef key);
117
118 CFArrayRef SecPolicyArrayDeserialize(CFArrayRef serializedPolicies);
119
120 void SecPolicyServerInitalize(void);
121
122 /* True iff certificate could be an extended validation (EV) certificate. */
123 bool SecPolicySubscriberCertificateCouldBeEV(SecCertificateRef certificate);
124
125 #if defined(__cplusplus)
126 }
127 #endif
128
129 #endif /* !_SECURITY_SECPOLICYSERVER_H_ */