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 * Primary operation codes. These are operations the system policy can express
47 * opinions on. They are not operations *on* the system configuration itself.
48 * (For those, see SecAssessmentUpdate below.)
50 * @constant kSecAssessmentContextKeyOperation Context key describing the type of operation
52 * @constant kSecAssessmentOperationTypeInstall Value denoting the operation of installing
53 * software into the system.
54 * @constant kSecAssessmentOperationTypeExecute Value denoting the operation of running or executing
57 extern const CFStringRef kSecAssessmentContextKeyOperation
; // proposed operation
58 extern const CFStringRef kSecAssessmentOperationTypeExecute
; // .. execute code
59 extern const CFStringRef kSecAssessmentOperationTypeInstall
; // .. install software
60 extern const CFStringRef kSecAssessmentOperationTypeOpenDocument
; // .. LaunchServices-level document open
64 Operational flags for SecAssessment calls
66 @type SecAssessmentFlags A mask of flag bits passed to SecAssessment calls to influence their
69 @constant kSecAssessmentDefaultFlags Pass this to indicate that default behavior is desired.
70 @constant kSecAssessmentFlagIgnoreCache Do not use cached information; always perform a full
71 evaluation of system policy. This may be substantially slower.
72 @constant kSecAssessmentFlagNoCache Do not save any evaluation outcome in the system caches.
73 Any content already there is left undisturbed. Independent of kSecAssessmentFlagIgnoreCache.
75 Flags common to multiple calls are assigned from high-bit down. Flags for particular calls
76 are assigned low-bit up, and are documented with that call.
78 typedef uint64_t SecAssessmentFlags
;
80 kSecAssessmentDefaultFlags
= 0, // default behavior
82 kSecAssessmentFlagDirect
= 1 << 30, // in-process evaluation
83 kSecAssessmentFlagAsynchronous
= 1 << 29, // request asynchronous operation
84 kSecAssessmentFlagIgnoreCache
= 1 << 28, // do not search cache
85 kSecAssessmentFlagNoCache
= 1 << 27, // do not populate cache
86 kSecAssessmentFlagEnforce
= 1 << 26, // force on (disable bypass switches)
91 @function SecAssessmentCreate
92 Ask the system for its assessment of a proposed operation.
94 @param path CFURL describing the file central to the operation - the program
95 to be executed, archive to be installed, plugin to be loaded, etc.
96 @param flags Operation flags and options. Pass kSecAssessmentDefaultFlags for default
98 @param context Optional CFDictionaryRef containing additional information bearing
99 on the requested assessment.
100 @param errors Standard CFError argument for reporting errors. Note that declining to permit
101 the proposed operation is not an error. Inability to form a judgment is.
102 @result On success, a SecAssessment object that can be queried for its outcome.
103 On error, NULL (with *errors set).
107 @constant kSecAssessmentFlagRequestOrigin Request additional work to produce information on
108 the originator (signer) of the object being discussed.
112 @constant kSecAssessmentContextKeyOperation Type of operation (see overview above). This defaults
113 to the kSecAssessmentOperationTypeExecute.
114 @constant kSecAssessmentContextKeyEdit A CFArray of SecCertificateRefs describing the
115 certificate chain of a CMS-type signature as pulled from 'path' by the caller.
116 The first certificate is the signing certificate. The certificates provided must be
117 sufficient to construct a valid certificate chain.
119 extern const CFStringRef kSecAssessmentContextKeyCertificates
; // certificate chain as provided by caller
121 extern const CFStringRef kSecAssessmentAssessmentVerdict
; // CFBooleanRef: master result - allow or deny
122 extern const CFStringRef kSecAssessmentAssessmentOriginator
; // CFStringRef: describing the signature originator
123 extern const CFStringRef kSecAssessmentAssessmentAuthority
; // CFDictionaryRef: authority used to arrive at result
124 extern const CFStringRef kSecAssessmentAssessmentSource
; // CFStringRef: primary source of authority
125 extern const CFStringRef kSecAssessmentAssessmentFromCache
; // present if result is from cache
126 extern const CFStringRef kSecAssessmentAssessmentAuthorityRow
; // (internal)
127 extern const CFStringRef kSecAssessmentAssessmentAuthorityOverride
; // (internal)
130 kSecAssessmentFlagRequestOrigin
= 1 << 0, // request origin information (slower)
133 SecAssessmentRef
SecAssessmentCreate(CFURLRef path
,
134 SecAssessmentFlags flags
,
135 CFDictionaryRef context
,
140 @function SecAssessmentCopyResult
142 Extract results from a completed assessment and return them as a CFDictionary.
144 Assessment result keys (dictionary keys returned on success):
146 @param assessment A SecAssessmentRef created with SecAssessmentCreate.
147 @param flags Operation flags and options. Pass kSecAssessmentDefaultFlags for default
149 @errors Standard CFError argument for reporting errors. Note that declining to permit
150 the proposed operation is not an error. Inability to form a judgment is.
151 @result On success, a CFDictionary describing the outcome and various corroborating
152 data as requested by flags. The caller owns this dictionary and should release it
153 when done with it. On error, NULL (with *errors set).
155 @constant kSecAssessmentAssessmentVerdict A CFBoolean value indicating whether the system policy
156 allows (kCFBooleanTrue) or denies (kCFBooleanFalse) the proposed operation.
157 @constant kSecAssessmentAssessmentAuthority A CFDictionary describing what sources of authority
158 were used to arrive at this result.
159 @constant kSecAssessmentAssessmentOriginator A human-readable CFString describing the originator
160 of the signature securing the subject of the verdict. Requires kSecAssessmentFlagRequireOrigin.
161 May be missing anyway if no reliable source of origin can be determined.
163 CFDictionaryRef
SecAssessmentCopyResult(SecAssessmentRef assessment
,
164 SecAssessmentFlags flags
,
169 @function SecAssessmentUpdate
170 Make changes to the system policy configuration.
172 @param path CFURL describing the file central to an operation - the program
173 to be executed, archive to be installed, plugin to be loaded, etc.
174 Pass NULL if the requested operation has no file subject.
175 @param flags Operation flags and options. Pass kSecAssessmentDefaultFlags for default
177 @param context Required CFDictionaryRef containing information bearing
178 on the requested assessment. Must at least contain the kSecAssessmentContextKeyEdit key.
179 @param errors Standard CFError argument for reporting errors. Note that declining to permit
180 the proposed operation is not an error. Inability to form a judgment is.
181 @result Returns True on success. Returns False on failure (and sets *error).
183 Context keys and values:
185 @constant kSecAssessmentContextKeyEdit Required context key describing the kind of change
186 requested to the system policy configuration. Currently understood values:
187 @constant kSecAssessmentUpdateOperationAddFile Request to add rules governing operations on the 'path'
189 @constant kSecAssessmentUpdateOperationRemoveFile Request to remove rules governing operations on the
192 extern const CFStringRef kSecAssessmentContextKeyUpdate
; // proposed operation
193 extern const CFStringRef kSecAssessmentUpdateOperationAddFile
; // add to policy database
194 extern const CFStringRef kSecAssessmentUpdateOperationRemoveFile
; // remove from policy database
196 extern const CFStringRef kSecAssessmentUpdateKeyPriority
; // rule priority
197 extern const CFStringRef kSecAssessmentUpdateKeyLabel
; // rule label
199 Boolean
SecAssessmentUpdate(CFURLRef path
,
200 SecAssessmentFlags flags
,
201 CFDictionaryRef context
,
206 @function SecAssessmentControl
207 Miscellaneous system policy operations
210 Boolean
SecAssessmentControl(CFStringRef control
, void *arguments
, CFErrorRef
*errors
);
217 #endif //_H_SECASSESSMENT