objc2_security/generated/
SecStaticCode.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 SecStaticCode {
10    /// Returns the type identifier of all SecStaticCode instances.
11    #[doc(alias = "SecStaticCodeGetTypeID")]
12    #[inline]
13    fn type_id() -> CFTypeID {
14        extern "C-unwind" {
15            fn SecStaticCodeGetTypeID() -> CFTypeID;
16        }
17        unsafe { SecStaticCodeGetTypeID() }
18    }
19}
20
21#[cfg(feature = "CSCommon")]
22impl SecStaticCode {
23    /// Given a path to a file system object, create a SecStaticCode object representing
24    /// the code at that location, if possible. Such a SecStaticCode is not inherently
25    /// linked to running code in the system.
26    ///
27    /// It is possible to create a SecStaticCode object from an unsigned code object.
28    /// Most uses of such an object will return the errSecCSUnsigned error. However,
29    /// SecCodeCopyPath and SecCodeCopySigningInformation can be safely applied to such objects.
30    ///
31    ///
32    /// Parameter `path`: A path to a location in the file system. Only file:// URLs are
33    /// currently supported. For bundles, pass a URL to the root directory of the
34    /// bundle. For single files, pass a URL to the file. If you pass a URL to the
35    /// main executable of a bundle, the bundle as a whole will be generally recognized.
36    /// Caution: Paths containing embedded // or /../ within a bundle's directory
37    /// may cause the bundle to be misconstrued. If you expect to submit such paths,
38    /// first clean them with realpath(3) or equivalent.
39    ///
40    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
41    ///
42    /// Parameter `staticCode`: On successful return, contains a reference to the StaticCode object
43    /// representing the code at path. Unchanged on error.
44    ///
45    /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
46    /// CSCommon.h or certain other Security framework headers.
47    ///
48    /// # Safety
49    ///
50    /// `static_code` must be a valid pointer.
51    #[doc(alias = "SecStaticCodeCreateWithPath")]
52    #[cfg(feature = "CSCommon")]
53    #[inline]
54    pub unsafe fn create_with_path(
55        path: &CFURL,
56        flags: SecCSFlags,
57        static_code: NonNull<*const SecStaticCode>,
58    ) -> OSStatus {
59        extern "C-unwind" {
60            fn SecStaticCodeCreateWithPath(
61                path: &CFURL,
62                flags: SecCSFlags,
63                static_code: NonNull<*const SecStaticCode>,
64            ) -> OSStatus;
65        }
66        unsafe { SecStaticCodeCreateWithPath(path, flags, static_code) }
67    }
68}
69
70extern "C" {
71    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeattributearchitecture?language=objc)
72    pub static kSecCodeAttributeArchitecture: &'static CFString;
73}
74
75extern "C" {
76    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeattributesubarchitecture?language=objc)
77    pub static kSecCodeAttributeSubarchitecture: &'static CFString;
78}
79
80extern "C" {
81    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeattributeuniversalfileoffset?language=objc)
82    pub static kSecCodeAttributeUniversalFileOffset: &'static CFString;
83}
84
85extern "C" {
86    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccodeattributebundleversion?language=objc)
87    pub static kSecCodeAttributeBundleVersion: &'static CFString;
88}
89
90#[cfg(feature = "CSCommon")]
91impl SecStaticCode {
92    /// Given a path to a file system object, create a SecStaticCode object representing
93    /// the code at that location, if possible. Such a SecStaticCode is not inherently
94    /// linked to running code in the system.
95    ///
96    /// It is possible to create a SecStaticCode object from an unsigned code object.
97    /// Most uses of such an object will return the errSecCSUnsigned error. However,
98    /// SecCodeCopyPath and SecCodeCopySigningInformation can be safely applied to such objects.
99    ///
100    ///
101    /// Parameter `path`: A path to a location in the file system. Only file:// URLs are
102    /// currently supported. For bundles, pass a URL to the root directory of the
103    /// bundle. For single files, pass a URL to the file. If you pass a URL to the
104    /// main executable of a bundle, the bundle as a whole will be generally recognized.
105    /// Caution: Paths containing embedded // or /../ within a bundle's directory
106    /// may cause the bundle to be misconstrued. If you expect to submit such paths,
107    /// first clean them with realpath(3) or equivalent.
108    ///
109    /// Parameter `flags`: Optional flags. Pass kSecCSDefaultFlags for standard behavior.
110    ///
111    /// Parameter `attributes`: A CFDictionary containing additional attributes of the code sought.
112    ///
113    /// Parameter `staticCode`: On successful return, contains a reference to the StaticCode object
114    /// representing the code at path. Unchanged on error.
115    ///
116    /// Returns: Upon success, errSecSuccess. Upon error, an OSStatus value documented in
117    /// CSCommon.h or certain other Security framework headers.
118    ///
119    ///
120    /// This can be a CFString containing a canonical architecture name ("i386" etc.), or a CFNumber
121    /// specifying an architecture numerically (see mach/machine.h). This key is ignored if the code
122    /// is not in Mach-O binary form. If the code is Mach-O but not universal ("thin"), the architecture
123    /// specified must agree with the actual file contents.
124    ///
125    /// (using the kSecCodeAttributeArchitecture key), specifies any sub-architecture by number.
126    /// This key is ignored if no main architecture is specified; if it is specified by name; or
127    /// if the code is not in Mach-O form.
128    ///
129    ///
130    /// then select the specified framework version. This key is otherwise ignored.
131    ///
132    /// # Safety
133    ///
134    /// - `attributes` generics must be of the correct type.
135    /// - `static_code` must be a valid pointer.
136    #[doc(alias = "SecStaticCodeCreateWithPathAndAttributes")]
137    #[cfg(feature = "CSCommon")]
138    #[inline]
139    pub unsafe fn create_with_path_and_attributes(
140        path: &CFURL,
141        flags: SecCSFlags,
142        attributes: &CFDictionary,
143        static_code: NonNull<*const SecStaticCode>,
144    ) -> OSStatus {
145        extern "C-unwind" {
146            fn SecStaticCodeCreateWithPathAndAttributes(
147                path: &CFURL,
148                flags: SecCSFlags,
149                attributes: &CFDictionary,
150                static_code: NonNull<*const SecStaticCode>,
151            ) -> OSStatus;
152        }
153        unsafe { SecStaticCodeCreateWithPathAndAttributes(path, flags, attributes, static_code) }
154    }
155}
156
157/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccscheckallarchitectures?language=objc)
158pub const kSecCSCheckAllArchitectures: u32 = 1;
159/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsdonotvalidateexecutable?language=objc)
160pub const kSecCSDoNotValidateExecutable: u32 = 2;
161/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsdonotvalidateresources?language=objc)
162pub const kSecCSDoNotValidateResources: u32 = 4;
163/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsbasicvalidateonly?language=objc)
164pub const kSecCSBasicValidateOnly: u32 = 6;
165/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccschecknestedcode?language=objc)
166pub const kSecCSCheckNestedCode: u32 = 8;
167/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsstrictvalidate?language=objc)
168pub const kSecCSStrictValidate: u32 = 16;
169/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsfullreport?language=objc)
170pub const kSecCSFullReport: u32 = 32;
171/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccscheckgatekeeperarchitectures?language=objc)
172pub const kSecCSCheckGatekeeperArchitectures: u32 = 65;
173/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsrestrictsymlinks?language=objc)
174pub const kSecCSRestrictSymlinks: u32 = 128;
175/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsrestricttoapplike?language=objc)
176pub const kSecCSRestrictToAppLike: u32 = 256;
177/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsrestrictsidebanddata?language=objc)
178pub const kSecCSRestrictSidebandData: u32 = 512;
179/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsusesoftwaresigningcert?language=objc)
180pub const kSecCSUseSoftwareSigningCert: u32 = 1024;
181/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsvalidatepeh?language=objc)
182pub const kSecCSValidatePEH: u32 = 2048;
183/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccssinglethreaded?language=objc)
184pub const kSecCSSingleThreaded: u32 = 4096;
185/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsallownetworkaccess?language=objc)
186pub const kSecCSAllowNetworkAccess: u32 = 65536;
187/// [Apple's documentation](https://developer.apple.com/documentation/security/kseccsfastexecutablevalidation?language=objc)
188pub const kSecCSFastExecutableValidation: u32 = 131072;
189
190#[cfg(feature = "CSCommon")]
191impl SecStaticCode {
192    #[doc(alias = "SecStaticCodeCheckValidity")]
193    #[cfg(feature = "CSCommon")]
194    #[inline]
195    pub unsafe fn check_validity(
196        &self,
197        flags: SecCSFlags,
198        requirement: Option<&SecRequirement>,
199    ) -> OSStatus {
200        extern "C-unwind" {
201            fn SecStaticCodeCheckValidity(
202                static_code: &SecStaticCode,
203                flags: SecCSFlags,
204                requirement: Option<&SecRequirement>,
205            ) -> OSStatus;
206        }
207        unsafe { SecStaticCodeCheckValidity(self, flags, requirement) }
208    }
209
210    /// # Safety
211    ///
212    /// `errors` must be a valid pointer or null.
213    #[doc(alias = "SecStaticCodeCheckValidityWithErrors")]
214    #[cfg(feature = "CSCommon")]
215    #[inline]
216    pub unsafe fn check_validity_with_errors(
217        &self,
218        flags: SecCSFlags,
219        requirement: Option<&SecRequirement>,
220        errors: *mut *mut CFError,
221    ) -> OSStatus {
222        extern "C-unwind" {
223            fn SecStaticCodeCheckValidityWithErrors(
224                static_code: &SecStaticCode,
225                flags: SecCSFlags,
226                requirement: Option<&SecRequirement>,
227                errors: *mut *mut CFError,
228            ) -> OSStatus;
229        }
230        unsafe { SecStaticCodeCheckValidityWithErrors(self, flags, requirement, errors) }
231    }
232}
233
234extern "C-unwind" {
235    #[cfg(feature = "CSCommon")]
236    #[deprecated = "renamed to `SecStaticCode::create_with_path`"]
237    pub fn SecStaticCodeCreateWithPath(
238        path: &CFURL,
239        flags: SecCSFlags,
240        static_code: NonNull<*const SecStaticCode>,
241    ) -> OSStatus;
242}
243
244extern "C-unwind" {
245    #[cfg(feature = "CSCommon")]
246    #[deprecated = "renamed to `SecStaticCode::create_with_path_and_attributes`"]
247    pub fn SecStaticCodeCreateWithPathAndAttributes(
248        path: &CFURL,
249        flags: SecCSFlags,
250        attributes: &CFDictionary,
251        static_code: NonNull<*const SecStaticCode>,
252    ) -> OSStatus;
253}
254
255extern "C-unwind" {
256    #[cfg(feature = "CSCommon")]
257    #[deprecated = "renamed to `SecStaticCode::check_validity`"]
258    pub fn SecStaticCodeCheckValidity(
259        static_code: &SecStaticCode,
260        flags: SecCSFlags,
261        requirement: Option<&SecRequirement>,
262    ) -> OSStatus;
263}
264
265extern "C-unwind" {
266    #[cfg(feature = "CSCommon")]
267    #[deprecated = "renamed to `SecStaticCode::check_validity_with_errors`"]
268    pub fn SecStaticCodeCheckValidityWithErrors(
269        static_code: &SecStaticCode,
270        flags: SecCSFlags,
271        requirement: Option<&SecRequirement>,
272        errors: *mut *mut CFError,
273    ) -> OSStatus;
274}