]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/lib/SecRequirementPriv.h
Security-57740.51.3.tar.gz
[apple/security.git] / OSX / libsecurity_codesigning / lib / SecRequirementPriv.h
1 /*
2 * Copyright (c) 2006,2011-2014 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 SecRequirement
26 SecRequirementPriv is the private counter-part to SecRequirement. Its contents are not
27 official API, and are subject to change without notice.
28 */
29 #ifndef _H_SECREQUIREMENTPRIV
30 #define _H_SECREQUIREMENTPRIV
31
32 #include <Security/SecRequirement.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38
39 /*!
40 @function SecRequirementsCreateFromRequirements
41 Take a dictionary of requirement objects and package them up as a requirement set.
42
43 @param requirements A dictionary of requirements to combine into a set.
44 Dictionary keys are CFNumbers representing the index keys. Values are SecRequirementRefs.
45 NULL requirements are not allowed in the dictionary.
46 @param flags Optional flags. Pass kSecCSDefaultFlags for standard behavior.
47 @param requirementSet Upon success, receives a CFData object
48 @result Upon success, errSecSuccess. Upon error, an OSStatus value documented in
49 CSCommon.h or certain other Security framework headers.
50 */
51 OSStatus SecRequirementsCreateFromRequirements(CFDictionaryRef requirements, SecCSFlags flags,
52 CFDataRef *requirementSet);
53
54
55 /*!
56 @function SecRequirementsCopyRequirements
57 Create a SecRequirement object from binary form obtained from a file.
58 This call is functionally equivalent to reading the entire contents of a file
59 into a CFDataRef and then calling SecRequirementCreateWithData with that.
60
61 @param requirementSet A CFData containing a requirement set.
62 @param flags Optional flags. Pass kSecCSDefaultFlags for standard behavior.
63 @param requirements Upon success, a dictionary containing each requirement contained
64 in requirementSet. The keys are CFNumbers indicating the requirement type.
65 @result Upon success, errSecSuccess. Upon error, an OSStatus value documented in
66 CSCommon.h or certain other Security framework headers.
67 */
68 OSStatus SecRequirementsCopyRequirements(CFDataRef requirementSet, SecCSFlags flags,
69 CFDictionaryRef *requirements);
70
71
72
73 typedef CF_OPTIONS(uint32_t, SecCSFlagsPriv) {
74 kSecCSParseRequirement = 0x0001, // accept single requirements
75 kSecCSParseRequirementSet = 0x0002, // accept requirement sets
76 };
77
78 /*!
79 @function SecRequirementsCreateWithString
80 Create a SecRequirement object or requirement set based on the string provided.
81
82 @param text A CFString containing the text form of a (single) Code Requirement.
83 @param flags Optional flags. Pass kSecCSDefaultFlags to accept any supported input form.
84 Pass a combination of individual flags to select what forms to accept; other forms will result
85 in an error.
86 @param result Upon success, a CoreFoundation object of some kind representing
87 the result of parsing text. Depending on the input string and flags, the result
88 can be a SecRequirementRef (for a single requirement) or a CFDataRef for a requirement set.
89 @param errors An optional pointer to a CFErrorRef variable. If the call fails
90 (and something other than errSecSuccess is returned), and this argument is non-NULL,
91 a CFErrorRef is stored there further describing the nature and circumstances
92 of the failure. The caller must CFRelease() this error object when done with it.
93 @result Upon success, errSecSuccess. Upon error, an OSStatus value documented in
94 CSCommon.h or certain other Security framework headers.
95 */
96 OSStatus SecRequirementsCreateWithString(CFStringRef text, SecCSFlags flags,
97 CFTypeRef *result, CFErrorRef *errors);
98
99
100 /*!
101 @function SecRequirementsCopyString
102 Converts a requirement object of some kind into text form.
103 This is the effective inverse of SecRequirementsCreateWithString.
104
105 This function can process individual requirements (SecRequirementRefs)
106 and requirement sets (represented as CFDataRefs).
107
108 Repeated application of this function may produce text that differs in
109 formatting, may contain different source comments, and may perform its
110 validation functions in different order. However, it is guaranteed that
111 recompiling the text using SecRequirementCreateWithString will produce a
112 SecRequirement object that behaves identically to the one you start with.
113
114 @param input A SecRequirementRef, or a CFDataRef containing a valid requirement set.
115 @param flags Optional flags. Pass kSecCSDefaultFlags for standard behavior.
116 @param text On successful return, contains a reference to a CFString object
117 containing a text representation of the requirement.
118 @result Upon success, errSecSuccess. Upon error, an OSStatus value documented in
119 CSCommon.h or certain other Security framework headers.
120 */
121 OSStatus SecRequirementsCopyString(CFTypeRef input, SecCSFlags flags, CFStringRef *text);
122
123
124 /*!
125 @function SecRequirementCreateWithResource
126 Create a SecRequirement object from binary form obtained from a file.
127 This call is functionally equivalent to reading the entire contents of a file
128 into a CFDataRef and then calling SecRequirementCreateWithData with that.
129
130 @param resource A CFURL identifying a file containing a (binary) requirement blob.
131 @param flags Optional flags. Pass kSecCSDefaultFlags for standard behavior.
132 @param requirement On successful return, contains a reference to a SecRequirement
133 object that behaves identically to the one the data blob was obtained from.
134 @result Upon success, errSecSuccess. Upon error, an OSStatus value documented in
135 CSCommon.h or certain other Security framework headers.
136 */
137 OSStatus SecRequirementCreateWithResource(CFURLRef resource, SecCSFlags flags,
138 SecRequirementRef *requirement);
139
140
141 /*!
142 @function SecRequirementCreateGroup
143 Create a SecRequirement object that represents membership in a developer-defined
144 application group. Group membership is defined by an entry in the code's
145 Info.plist, and sealed to a particular signing authority.
146
147 This is not an API-track function. Don't call it if you don't already do.
148
149 @param groupName A CFString containing the name of the desired application group.
150 @param anchor A reference to a digital certificate representing the signing
151 authority that asserts group membership. If NULL, indicates Apple's authority.
152 @param flags Optional flags. Pass kSecCSDefaultFlags for standard behavior.
153 @param requirement On successful return, contains a reference to a SecRequirement
154 object that requires group membership to pass validation.
155 @result Upon success, errSecSuccess. Upon error, an OSStatus value documented in
156 CSCommon.h or certain other Security framework headers.
157 */
158 OSStatus SecRequirementCreateGroup(CFStringRef groupName, SecCertificateRef anchor,
159 SecCSFlags flags, SecRequirementRef *requirement);
160
161
162 extern CFStringRef kSecRequirementKeyInfoPlist;
163 extern CFStringRef kSecRequirementKeyEntitlements;
164 extern CFStringRef kSecRequirementKeyIdentifier;
165 /*!
166 @function SecRequirementEvaluate
167 Explicitly evaluate a SecRequirementRef against context provided in the call.
168 This allows evaluation of a code requirement outside the context of a code signature.
169
170 @param requirement A valid SecRequirement object.
171 @param certificateChain A CFArray of SecCertificate objects describing the certificate
172 chain of the object being validated. This must be a full chain terminating in an anchor
173 certificate that is cryptographically valid.
174 @param context An optional CFDictionary containing additional context made available
175 to the requirement program's evaluation. NULL is equivalent to an empty dictionary.
176 @param flags Optional flags. Pass kSecCSDefaultFlags for standard behavior.
177 @result Upon success, errSecSuccess. Failure to pass the check returns errSecCSReqFailed.
178 All other returns indicate errors as documented in CSCommon.h or certain other
179 Security framework headers.
180
181 @constant kSecRequirementKeyInfoPlist A context key providing an CFDictionary denoting
182 an Info.plist. If this key is missing, all references to Info.plist contents will fail.
183 @constant kSecRequirementKeyEntitlements A context key providing an CFDictionary describing
184 an entitlement dictionary. If this key is missing, all references to entitlements will fail.
185 @constant kSecRequirementKeyIdentifier A context key providing the signing identifier as a CFString.
186 */
187 OSStatus SecRequirementEvaluate(SecRequirementRef requirement,
188 CFArrayRef certificateChain, CFDictionaryRef context,
189 SecCSFlags flags);
190
191
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif //_H_SECREQUIREMENTPRIV