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