objc2_security/generated/
SecCode.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2_core_foundation::*;
5
6use crate::*;
7
8#[cfg(feature = "CSCommon")]
9unsafe impl ConcreteType for SecCode {
10    /// Returns the type identifier of all SecCode instances.
11    #[doc(alias = "SecCodeGetTypeID")]
12    #[inline]
13    fn type_id() -> CFTypeID {
14        extern "C-unwind" {
15            fn SecCodeGetTypeID() -> CFTypeID;
16        }
17        unsafe { SecCodeGetTypeID() }
18    }
19}
20
21extern "C-unwind" {
22    /// Obtains a SecCode object for the code making the call.
23    /// The calling code is determined in a way that is subject to modification over
24    /// time, but obeys the following rules. If it is a UNIX process, its process id (pid)
25    /// is always used.
26    ///
27    ///
28    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
29    ///
30    /// Parameter `self`: Upon successful return, contains a SecCodeRef representing the caller.
31    ///
32    ///
33    /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
34    /// CSCommon.h or certain other Security framework headers.
35    #[cfg(feature = "CSCommon")]
36    pub fn SecCodeCopySelf(flags: SecCSFlags, self_: NonNull<*mut SecCode>) -> OSStatus;
37}
38
39/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsuseallarchitectures?language=objc)
40pub const kSecCSUseAllArchitectures: u32 = 1;
41
42extern "C-unwind" {
43    #[cfg(feature = "CSCommon")]
44    pub fn SecCodeCopyStaticCode(
45        code: &SecCode,
46        flags: SecCSFlags,
47        static_code: NonNull<*const SecStaticCode>,
48    ) -> OSStatus;
49}
50
51extern "C-unwind" {
52    /// Given a SecCode object, identify the (different) SecCode object that acts
53    /// as its host. A SecCode's host acts as a supervisor and controller,
54    /// and is the ultimate authority on the its dynamic validity and status.
55    /// The host relationship is securely established (absent reported errors).
56    ///
57    ///
58    /// Parameter `guest`: A valid SecCode object reference representing code running
59    /// on the system.
60    ///
61    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
62    ///
63    /// Parameter `host`: On successful return, a SecCode object reference identifying
64    /// the code's host.
65    ///
66    /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
67    /// CSCommon.h or certain other Security framework headers.
68    #[cfg(feature = "CSCommon")]
69    pub fn SecCodeCopyHost(
70        guest: &SecCode,
71        flags: SecCSFlags,
72        host: NonNull<*mut SecCode>,
73    ) -> OSStatus;
74}
75
76extern "C" {
77    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributecanonical?language=objc)
78    pub static kSecGuestAttributeCanonical: &'static CFString;
79}
80
81extern "C" {
82    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributehash?language=objc)
83    pub static kSecGuestAttributeHash: &'static CFString;
84}
85
86extern "C" {
87    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributemachport?language=objc)
88    pub static kSecGuestAttributeMachPort: &'static CFString;
89}
90
91extern "C" {
92    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributepid?language=objc)
93    pub static kSecGuestAttributePid: &'static CFString;
94}
95
96extern "C" {
97    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributeaudit?language=objc)
98    pub static kSecGuestAttributeAudit: &'static CFString;
99}
100
101extern "C" {
102    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributedynamiccode?language=objc)
103    pub static kSecGuestAttributeDynamicCode: &'static CFString;
104}
105
106extern "C" {
107    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributedynamiccodeinfoplist?language=objc)
108    pub static kSecGuestAttributeDynamicCodeInfoPlist: &'static CFString;
109}
110
111extern "C" {
112    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributearchitecture?language=objc)
113    pub static kSecGuestAttributeArchitecture: &'static CFString;
114}
115
116extern "C" {
117    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecguestattributesubarchitecture?language=objc)
118    pub static kSecGuestAttributeSubarchitecture: &'static CFString;
119}
120
121extern "C-unwind" {
122    /// This is the omnibus API function for obtaining dynamic code references.
123    /// In general, it asks a particular code acting as a code host to locate
124    /// and return a guest with given attributes. Different hosts support
125    /// different combinations of attributes and values for guest selection.
126    ///
127    /// Asking the NULL host invokes system default    procedures for obtaining
128    /// any running code in the system with the    attributes given. The returned
129    /// code may be anywhere in the system.
130    ///
131    /// The methods a host uses to identify, separate, and control its guests
132    /// are specific to each type of host. This call provides a generic abstraction layer
133    /// that allows uniform interrogation of all hosts. A SecCode that does not
134    /// act as a host will always return errSecCSNoSuchCode. A SecCode that does
135    /// support hosting may return itself to signify that the attribute refers to
136    /// itself rather than one of its hosts.
137    ///
138    ///
139    /// Parameter `host`: A valid SecCode object reference representing code running
140    /// on the system that acts as a Code Signing host. As a special case, passing
141    /// NULL indicates that the Code Signing root of trust should be used as a starting
142    /// point. Currently, that is the system kernel.
143    ///
144    /// Parameter `attributes`: A CFDictionary containing zero or more attribute selector
145    /// values. Each selector has a CFString key and associated CFTypeRef value.
146    /// The key name identifies the attribute being specified; the associated value,
147    /// whose type depends on the the key name, selects a particular value or other
148    /// constraint on that attribute. Each host only supports particular combinations
149    /// of keys and values,    and errors will be returned if any unsupported set is requested.
150    /// As a special case, NULL is taken to mean an empty attribute set.
151    /// Note that some hosts that support hosting chains (guests being hosts)
152    /// may return sub-guests in this call. In other words, do not assume that
153    /// a SecCodeRef returned by this call is a direct guest of the queried host
154    /// (though it will be a proximate guest, i.e. a guest's guest some way down).
155    /// Asking the NULL host for NULL attributes returns a code reference for the system root
156    /// of trust (at present, the running Darwin kernel).
157    ///
158    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
159    ///
160    /// Parameter `guest`: On successful return, a SecCode object reference identifying
161    /// the particular guest of the host that owns the attribute value(s) specified.
162    /// This argument will not be changed if the call fails (does not return errSecSuccess).
163    ///
164    /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
165    /// CSCommon.h or certain other Security framework headers. In particular:
166    /// errSecCSUnsupportedGuestAttributes The host does not support the attribute
167    /// type given by attributeType.
168    /// errSecCSInvalidAttributeValues The type of value given for a guest
169    /// attribute is not supported by the host.
170    /// errSecCSNoSuchCode The host has no guest with the attribute value given
171    /// by attributeValue, even though the value is of a supported type. This may also
172    /// be returned if the host code does not currently act as a Code Signing host.
173    /// errSecCSNotAHost The specified host cannot, in fact, act as a code
174    /// host. (It is missing the kSecCodeSignatureHost option flag in its code
175    /// signature.)
176    /// errSecCSMultipleGuests The attributes specified do not uniquely identify
177    /// a guest (the specification is ambiguous).
178    #[cfg(feature = "CSCommon")]
179    pub fn SecCodeCopyGuestWithAttributes(
180        host: Option<&SecCode>,
181        attributes: Option<&CFDictionary>,
182        flags: SecCSFlags,
183        guest: NonNull<*mut SecCode>,
184    ) -> OSStatus;
185}
186
187extern "C-unwind" {
188    /// Performs dynamic validation of the given SecCode object. The call obtains and
189    /// verifies the signature on the code object. It checks the validity of only those
190    /// sealed components required to establish identity. It checks the SecCode's
191    /// dynamic validity status as reported by its host. It ensures that the SecCode's
192    /// host is in turn valid. Finally, it validates the code against a SecRequirement
193    /// if one is given. The call succeeds if all these conditions are satisfactory.
194    /// It fails otherwise.
195    ///
196    /// This call is secure against attempts to modify the file system source of the
197    /// SecCode.
198    ///
199    ///
200    /// Parameter `code`: The code object to be validated.
201    ///
202    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
203    ///
204    /// Parameter `requirement`: An optional code requirement specifying additional conditions
205    /// the code object must satisfy to be considered valid. If NULL, no additional
206    /// requirements are imposed.
207    ///
208    /// Returns: If validation passes, errSecSuccess. If validation fails, an OSStatus value
209    /// documented in CSCommon.h or certain other Security framework headers.
210    #[cfg(feature = "CSCommon")]
211    pub fn SecCodeCheckValidity(
212        code: &SecCode,
213        flags: SecCSFlags,
214        requirement: Option<&SecRequirement>,
215    ) -> OSStatus;
216}
217
218extern "C-unwind" {
219    /// Performs dynamic validation of the given SecCode object. The call obtains and
220    /// verifies the signature on the code object. It checks the validity of only those
221    /// sealed components required to establish identity. It checks the SecCode's
222    /// dynamic validity status as reported by its host. It ensures that the SecCode's
223    /// host is in turn valid. Finally, it validates the code against a SecRequirement
224    /// if one is given. The call succeeds if all these conditions are satisfactory.
225    /// It fails otherwise.
226    ///
227    /// This call is secure against attempts to modify the file system source of the
228    /// SecCode.
229    ///
230    ///
231    /// Parameter `code`: The code object to be validated.
232    ///
233    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
234    ///
235    /// Parameter `requirement`: An optional code requirement specifying additional conditions
236    /// the code object must satisfy to be considered valid. If NULL, no additional
237    /// requirements are imposed.
238    ///
239    /// Parameter `errors`: An optional pointer to a CFErrorRef variable. If the call fails
240    /// (and something other than errSecSuccess is returned), and this argument is non-NULL,
241    /// a CFErrorRef is stored there further describing the nature and circumstances
242    /// of the failure. The caller must CFRelease() this error object when done with it.
243    ///
244    /// Returns: If validation passes, errSecSuccess. If validation fails, an OSStatus value
245    /// documented in CSCommon.h or certain other Security framework headers.
246    #[cfg(feature = "CSCommon")]
247    pub fn SecCodeCheckValidityWithErrors(
248        code: &SecCode,
249        flags: SecCSFlags,
250        requirement: Option<&SecRequirement>,
251        errors: *mut *mut CFError,
252    ) -> OSStatus;
253}
254
255extern "C-unwind" {
256    /// For a SecStaticCodeRef, check that a given CFData object faithfully represents
257    /// a plain-file resource in its resource seal.
258    /// This call will fail if the file is missing in the bundle, even if it is optional.
259    ///
260    ///
261    /// Parameter `code`: A code or StaticCode object.
262    ///
263    /// Parameter `relativePath`: A CFStringRef containing the relative path to a sealed resource
264    /// file. This path is relative to the resource base, which is either Contents or
265    /// the bundle root, depending on bundle format.
266    ///
267    /// Parameter `fileData`: A CFDataRef containing the exact contents of that resource file.
268    ///
269    /// Parameter `flags`: Pass kSecCSDefaultFlags.
270    ///
271    /// Returns: noErr if fileData is the exact content of the file at relativePath at the
272    /// time it was signed. Various error codes if it is different, there was no such file,
273    /// it was not a plain file, or anything is irregular.
274    #[cfg(feature = "CSCommon")]
275    pub fn SecCodeValidateFileResource(
276        code: &SecStaticCode,
277        relative_path: &CFString,
278        file_data: &CFData,
279        flags: SecCSFlags,
280    ) -> OSStatus;
281}
282
283extern "C-unwind" {
284    /// For a given Code or StaticCode object, returns a URL to a location on disk where the
285    /// code object can be found. For single files, the URL points to that file.
286    /// For bundles, it points to the directory containing the entire bundle.
287    ///
288    ///
289    /// Parameter `staticCode`: The Code or StaticCode object to be located. For a Code
290    /// argument, its StaticCode is processed as per SecCodeCopyStaticCode.
291    ///
292    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
293    ///
294    /// Parameter `path`: On successful return, contains a CFURL identifying the location
295    /// on disk of the staticCode object.
296    ///
297    /// Returns: On success, errSecSuccess. On error, an OSStatus value
298    /// documented in CSCommon.h or certain other Security framework headers.
299    #[cfg(feature = "CSCommon")]
300    pub fn SecCodeCopyPath(
301        static_code: &SecStaticCode,
302        flags: SecCSFlags,
303        path: NonNull<*const CFURL>,
304    ) -> OSStatus;
305}
306
307extern "C-unwind" {
308    /// For a given Code or StaticCode object, determines its Designated Code Requirement.
309    /// The Designated Requirement is the SecRequirement that the code believes
310    /// should be used to properly identify it in the future.
311    ///
312    /// If the SecCode contains an explicit Designated Requirement, a copy of that
313    /// is returned. If it does not, a SecRequirement is implicitly constructed from
314    /// its signing authority and its embedded unique identifier. No Designated
315    /// Requirement can be obtained from code that is unsigned. Code that is modified
316    /// after signature, improperly signed, or has become invalid, may or may not yield
317    /// a Designated Requirement. This call does not validate the SecStaticCode argument.
318    ///
319    ///
320    /// Parameter `code`: The Code or StaticCode object to be interrogated. For a Code
321    /// argument, its StaticCode is processed as per SecCodeCopyStaticCode.
322    ///
323    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
324    ///
325    /// Parameter `requirement`: On successful return, contains a copy of a SecRequirement
326    /// object representing the code's Designated Requirement. On error, unchanged.
327    ///
328    /// Returns: On success, errSecSuccess. On error, an OSStatus value
329    /// documented in CSCommon.h or certain other Security framework headers.
330    #[cfg(feature = "CSCommon")]
331    pub fn SecCodeCopyDesignatedRequirement(
332        code: &SecStaticCode,
333        flags: SecCSFlags,
334        requirement: NonNull<*mut SecRequirement>,
335    ) -> OSStatus;
336}
337
338/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsinternalinformation?language=objc)
339pub const kSecCSInternalInformation: u32 = 1;
340/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccssigninginformation?language=objc)
341pub const kSecCSSigningInformation: u32 = 2;
342/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsrequirementinformation?language=objc)
343pub const kSecCSRequirementInformation: u32 = 4;
344/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsdynamicinformation?language=objc)
345pub const kSecCSDynamicInformation: u32 = 8;
346/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccscontentinformation?language=objc)
347pub const kSecCSContentInformation: u32 = 16;
348/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsskipresourcedirectory?language=objc)
349pub const kSecCSSkipResourceDirectory: u32 = 32;
350/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccscalculatecmsdigest?language=objc)
351pub const kSecCSCalculateCMSDigest: u32 = 64;
352
353extern "C" {
354    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfocertificates?language=objc)
355    pub static kSecCodeInfoCertificates: &'static CFString;
356}
357
358extern "C" {
359    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfochangedfiles?language=objc)
360    pub static kSecCodeInfoChangedFiles: &'static CFString;
361}
362
363extern "C" {
364    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfocms?language=objc)
365    pub static kSecCodeInfoCMS: &'static CFString;
366}
367
368extern "C" {
369    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfodesignatedrequirement?language=objc)
370    pub static kSecCodeInfoDesignatedRequirement: &'static CFString;
371}
372
373extern "C" {
374    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoentitlements?language=objc)
375    pub static kSecCodeInfoEntitlements: &'static CFString;
376}
377
378extern "C" {
379    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoentitlementsdict?language=objc)
380    pub static kSecCodeInfoEntitlementsDict: &'static CFString;
381}
382
383extern "C" {
384    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoflags?language=objc)
385    pub static kSecCodeInfoFlags: &'static CFString;
386}
387
388extern "C" {
389    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoformat?language=objc)
390    pub static kSecCodeInfoFormat: &'static CFString;
391}
392
393extern "C" {
394    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfodigestalgorithm?language=objc)
395    pub static kSecCodeInfoDigestAlgorithm: &'static CFString;
396}
397
398extern "C" {
399    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfodigestalgorithms?language=objc)
400    pub static kSecCodeInfoDigestAlgorithms: &'static CFString;
401}
402
403extern "C" {
404    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoplatformidentifier?language=objc)
405    pub static kSecCodeInfoPlatformIdentifier: &'static CFString;
406}
407
408extern "C" {
409    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoidentifier?language=objc)
410    pub static kSecCodeInfoIdentifier: &'static CFString;
411}
412
413extern "C" {
414    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoimplicitdesignatedrequirement?language=objc)
415    pub static kSecCodeInfoImplicitDesignatedRequirement: &'static CFString;
416}
417
418extern "C" {
419    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfodefaultdesignatedlightweightcoderequirement?language=objc)
420    pub static kSecCodeInfoDefaultDesignatedLightweightCodeRequirement: &'static CFString;
421}
422
423extern "C" {
424    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfomainexecutable?language=objc)
425    pub static kSecCodeInfoMainExecutable: &'static CFString;
426}
427
428extern "C" {
429    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoplist?language=objc)
430    pub static kSecCodeInfoPList: &'static CFString;
431}
432
433extern "C" {
434    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinforequirements?language=objc)
435    pub static kSecCodeInfoRequirements: &'static CFString;
436}
437
438extern "C" {
439    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinforequirementdata?language=objc)
440    pub static kSecCodeInfoRequirementData: &'static CFString;
441}
442
443extern "C" {
444    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfosource?language=objc)
445    pub static kSecCodeInfoSource: &'static CFString;
446}
447
448extern "C" {
449    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfostatus?language=objc)
450    pub static kSecCodeInfoStatus: &'static CFString;
451}
452
453extern "C" {
454    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfoteamidentifier?language=objc)
455    pub static kSecCodeInfoTeamIdentifier: &'static CFString;
456}
457
458extern "C" {
459    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfotime?language=objc)
460    pub static kSecCodeInfoTime: &'static CFString;
461}
462
463extern "C" {
464    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfotimestamp?language=objc)
465    pub static kSecCodeInfoTimestamp: &'static CFString;
466}
467
468extern "C" {
469    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfotrust?language=objc)
470    pub static kSecCodeInfoTrust: &'static CFString;
471}
472
473extern "C" {
474    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfounique?language=objc)
475    pub static kSecCodeInfoUnique: &'static CFString;
476}
477
478extern "C" {
479    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfocdhashes?language=objc)
480    pub static kSecCodeInfoCdHashes: &'static CFString;
481}
482
483extern "C" {
484    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinforuntimeversion?language=objc)
485    pub static kSecCodeInfoRuntimeVersion: &'static CFString;
486}
487
488extern "C" {
489    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeinfostaplednotarizationticket?language=objc)
490    pub static kSecCodeInfoStapledNotarizationTicket: &'static CFString;
491}
492
493extern "C-unwind" {
494    #[cfg(feature = "CSCommon")]
495    pub fn SecCodeCopySigningInformation(
496        code: &SecStaticCode,
497        flags: SecCSFlags,
498        information: NonNull<*const CFDictionary>,
499    ) -> OSStatus;
500}
501
502extern "C-unwind" {
503    #[cfg(feature = "CSCommon")]
504    pub fn SecCodeMapMemory(code: &SecStaticCode, flags: SecCSFlags) -> OSStatus;
505}