2 * Copyright (c) 2011 Apple 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@
23 #ifndef _H_SECASSESSMENT
24 #define _H_SECASSESSMENT
26 #include <CoreFoundation/CoreFoundation.h>
34 * @type SecAccessmentRef An assessment being performed.
36 typedef struct _SecAssessment
*SecAssessmentRef
;
40 * CF-standard type function
42 CFTypeID
SecAssessmentGetTypeID();
46 * Notifications sent when the policy authority database changes.
47 * (Should move to /usr/include/notify_keys.h eventually.)
49 #define kNotifySecAssessmentMasterSwitch "com.apple.security.assessment.masterswitch"
50 #define kNotifySecAssessmentUpdate "com.apple.security.assessment.update"
54 * Primary operation types. These are operations the system policy can express
55 * opinions on. They are not operations *on* the system configuration itself.
56 * (For those, see SecAssessmentUpdate below.)
58 * @constant kSecAssessmentContextKeyOperation Context key describing the type of operation
59 * being contemplated. The default varies depending on the API call used.
60 * @constant kSecAssessmentOperationTypeExecute Value denoting the operation of running or executing
62 * @constant kSecAssessmentOperationTypeInstall Value denoting the operation of installing
63 * software into the system.
64 * @constant kSecAssessmentOperationTypeOpenDocument Value denoting the operation of opening
65 * (in the LaunchServices sense) of documents.
67 extern const CFStringRef kSecAssessmentContextKeyOperation
; // proposed operation
68 extern const CFStringRef kSecAssessmentOperationTypeExecute
; // .. execute code
69 extern const CFStringRef kSecAssessmentOperationTypeInstall
; // .. install software
70 extern const CFStringRef kSecAssessmentOperationTypeOpenDocument
; // .. LaunchServices-level document open
74 Operational flags for SecAssessment calls
76 @type SecAssessmentFlags A mask of flag bits passed to SecAssessment calls to influence their
79 @constant kSecAssessmentDefaultFlags Pass this to indicate that default behavior is desired.
80 @constant kSecAssessmentFlagIgnoreCache Do not use cached information; always perform a full
81 evaluation of system policy. This may be substantially slower.
82 @constant kSecAssessmentFlagNoCache Do not save any evaluation outcome in the system caches.
83 Any content already there is left undisturbed. Independent of kSecAssessmentFlagIgnoreCache.
84 @constant kSecAssessmentFlagEnforce Perform normal operations even if assessments have been
85 globally bypassed (which would usually approve anything).
87 Flags common to multiple calls are assigned from high-bit down. Flags for particular calls
88 are assigned low-bit up, and are documented with that call.
90 typedef uint64_t SecAssessmentFlags
;
92 kSecAssessmentDefaultFlags
= 0, // default behavior
94 kSecAssessmentFlagDirect
= 1 << 30, // in-process evaluation
95 kSecAssessmentFlagAsynchronous
= 1 << 29, // request asynchronous operation
96 kSecAssessmentFlagIgnoreCache
= 1 << 28, // do not search cache
97 kSecAssessmentFlagNoCache
= 1 << 27, // do not populate cache
98 kSecAssessmentFlagEnforce
= 1 << 26, // force on (disable bypass switches)
103 @function SecAssessmentCreate
104 Ask the system for its assessment of a proposed operation.
106 @param path CFURL describing the file central to the operation - the program
107 to be executed, archive to be installed, plugin to be loaded, etc.
108 @param flags Operation flags and options. Pass kSecAssessmentDefaultFlags for default
110 @param context Optional CFDictionaryRef containing additional information bearing
111 on the requested assessment.
112 @param errors Standard CFError argument for reporting errors. Note that declining to permit
113 the proposed operation is not an error. Inability to arrive at a judgment is.
114 @result On success, a SecAssessment object that can be queried for its outcome.
115 On error, NULL (with *errors set).
119 @constant kSecAssessmentFlagRequestOrigin Request additional work to produce information on
120 the originator (signer) of the object being discussed.
124 @constant kSecAssessmentContextKeyOperation Type of operation (see overview above). This defaults
125 to the kSecAssessmentOperationTypeExecute.
127 extern const CFStringRef kSecAssessmentContextKeyCertificates
; // certificate chain as provided by caller
129 extern const CFStringRef kSecAssessmentAssessmentVerdict
; // CFBooleanRef: master result - allow or deny
130 extern const CFStringRef kSecAssessmentAssessmentOriginator
; // CFStringRef: describing the signature originator
131 extern const CFStringRef kSecAssessmentAssessmentAuthority
; // CFDictionaryRef: authority used to arrive at result
132 extern const CFStringRef kSecAssessmentAssessmentSource
; // CFStringRef: primary source of authority
133 extern const CFStringRef kSecAssessmentAssessmentFromCache
; // present if result is from cache
134 extern const CFStringRef kSecAssessmentAssessmentAuthorityRow
; // (internal)
135 extern const CFStringRef kSecAssessmentAssessmentAuthorityOverride
; // (internal)
138 kSecAssessmentFlagRequestOrigin
= 1 << 0, // request origin information (slower)
141 SecAssessmentRef
SecAssessmentCreate(CFURLRef path
,
142 SecAssessmentFlags flags
,
143 CFDictionaryRef context
,
148 @function SecAssessmentCopyResult
150 Extract results from a completed assessment and return them as a CFDictionary.
152 @param assessment A SecAssessmentRef created with SecAssessmentCreate.
153 @param flags Operation flags and options. Pass kSecAssessmentDefaultFlags for default
155 @errors Standard CFError argument for reporting errors. Note that declining to permit
156 the proposed operation is not an error. Inability to form a judgment is.
157 @result On success, a CFDictionary describing the outcome and various corroborating
158 data as requested by flags. The caller owns this dictionary and should release it
159 when done with it. On error, NULL (with *errors set).
161 Assessment result keys (dictionary keys returned on success):
163 @constant kSecAssessmentAssessmentVerdict A CFBoolean value indicating whether the system policy
164 allows (kCFBooleanTrue) or denies (kCFBooleanFalse) the proposed operation.
165 @constant kSecAssessmentAssessmentAuthority A CFDictionary describing what sources of authority
166 were used to arrive at this result.
167 @constant kSecAssessmentAssessmentOriginator A human-readable CFString describing the originator
168 of the signature securing the subject of the verdict. Requires kSecAssessmentFlagRequireOrigin.
169 May be missing anyway if no reliable source of origin can be determined.
171 CFDictionaryRef
SecAssessmentCopyResult(SecAssessmentRef assessment
,
172 SecAssessmentFlags flags
,
177 @function SecAssessmentUpdate
178 Make changes to the system policy configuration.
180 @param path CFTypeRef describing the subject of the operation. Depending on the operation,
181 this may be a CFURL denoting a (single) file or bundle; a SecRequirement describing
182 a group of files; a CFNumber denoting an existing rule by rule number, or NULL to perform
184 @param flags Operation flags and options. Pass kSecAssessmentDefaultFlags for default
186 @param context Required CFDictionaryRef containing information bearing
187 on the requested assessment. Must at least contain the kSecAssessmentContextKeyEdit key.
188 @param errors Standard CFError argument for reporting errors. Note that declining to permit
189 the proposed operation is not an error. Inability to form a judgment is.
190 @result Returns True on success. Returns False on failure (and sets *error).
192 Context keys and values:
194 @constant kSecAssessmentContextKeyEdit Required context key describing the kind of change
195 requested to the system policy configuration. Currently understood values:
196 @constant kSecAssessmentUpdateOperationAdd Add a new rule to the assessment rule database.
197 @constant kSecAssessmentUpdateOperationRemove Remove rules from the rule database.
198 @constant kSecAssessmentUpdateOperationEnable (Re)enable rules in the rule database.
199 @constant kSecAssessmentUpdateOperationDisable Disable rules in the rule database.
200 @constant kSecAssessmentUpdateKeyAuthorization A CFData containing the external form of a
201 system AuthorizationRef used to authorize the change. The call will automatically generate
202 a suitable authorization if this is missing; however, if the request is on behalf of
203 another client, an AuthorizationRef should be created there and passed along here.
204 @constant kSecAssessmentUpdateKeyPriority CFNumber denoting a (floating point) priority
205 for the rule(s) being processed.
206 @constant kSecAssessmentUpdateKeyLabel CFString denoting a label string applied to the rule(s)
208 @constant kSecAssessmentUpdateKeyExpires CFDate denoting an (absolute, future) expiration date
209 for rule(s) being processed.
210 @constant kSecAssessmentUpdateKeyAllow CFBoolean denoting whether a new rule allows or denies
211 assessment. The default is to allow; set to kCFBooleanFalse to create a negative (denial) rule.
212 @constant kSecAssessmentUpdateKeyRemarks CFString containing a colloquial description or comment
213 about a newly created rule. This is mean to be human readable and is not used when evaluating rules.
215 extern const CFStringRef kSecAssessmentContextKeyUpdate
; // proposed operation
216 extern const CFStringRef kSecAssessmentUpdateOperationAdd
; // add rule to policy database
217 extern const CFStringRef kSecAssessmentUpdateOperationRemove
; // remove rule from policy database
218 extern const CFStringRef kSecAssessmentUpdateOperationEnable
; // enable rule(s) in policy database
219 extern const CFStringRef kSecAssessmentUpdateOperationDisable
; // disable rule(s) in policy database
221 extern const CFStringRef kSecAssessmentUpdateKeyAuthorization
; // [CFData] external form of governing authorization
223 extern const CFStringRef kSecAssessmentUpdateKeyPriority
; // rule priority
224 extern const CFStringRef kSecAssessmentUpdateKeyLabel
; // rule label
225 extern const CFStringRef kSecAssessmentUpdateKeyExpires
; // rule expiration
226 extern const CFStringRef kSecAssessmentUpdateKeyAllow
; // rule outcome (allow/deny)
227 extern const CFStringRef kSecAssessmentUpdateKeyRemarks
; // rule remarks (human readable)
229 extern const CFStringRef kSecAssessmentContextKeyCertificates
; // obsolete
231 Boolean
SecAssessmentUpdate(CFTypeRef target
,
232 SecAssessmentFlags flags
,
233 CFDictionaryRef context
,
238 @function SecAssessmentControl
239 Miscellaneous system policy operations.
241 @param control A CFString indicating which operation is requested.
242 @param arguments Arguments to the operation as documented for control.
243 @param errors Standard CFErrorRef * argument to report errors.
244 @result Returns True on success. Returns False on failure (and sets *errors).
247 Boolean
SecAssessmentControl(CFStringRef control
, void *arguments
, CFErrorRef
*errors
);
254 #endif //_H_SECASSESSMENT