objc2_security/generated/
CSCommon.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use core::ptr::NonNull;
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8use objc2_core_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsunimplemented?language=objc)
13pub const errSecCSUnimplemented: OSStatus = -67072;
14/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidobjectref?language=objc)
15pub const errSecCSInvalidObjectRef: OSStatus = -67071;
16/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidflags?language=objc)
17pub const errSecCSInvalidFlags: OSStatus = -67070;
18/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsobjectrequired?language=objc)
19pub const errSecCSObjectRequired: OSStatus = -67069;
20/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsstaticcodenotfound?language=objc)
21pub const errSecCSStaticCodeNotFound: OSStatus = -67068;
22/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsunsupportedguestattributes?language=objc)
23pub const errSecCSUnsupportedGuestAttributes: OSStatus = -67067;
24/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidattributevalues?language=objc)
25pub const errSecCSInvalidAttributeValues: OSStatus = -67066;
26/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsnosuchcode?language=objc)
27pub const errSecCSNoSuchCode: OSStatus = -67065;
28/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsmultipleguests?language=objc)
29pub const errSecCSMultipleGuests: OSStatus = -67064;
30/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsguestinvalid?language=objc)
31pub const errSecCSGuestInvalid: OSStatus = -67063;
32/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsunsigned?language=objc)
33pub const errSecCSUnsigned: OSStatus = -67062;
34/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccssignaturefailed?language=objc)
35pub const errSecCSSignatureFailed: OSStatus = -67061;
36/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccssignaturenotverifiable?language=objc)
37pub const errSecCSSignatureNotVerifiable: OSStatus = -67060;
38/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccssignatureunsupported?language=objc)
39pub const errSecCSSignatureUnsupported: OSStatus = -67059;
40/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbaddictionaryformat?language=objc)
41pub const errSecCSBadDictionaryFormat: OSStatus = -67058;
42/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsresourcesnotsealed?language=objc)
43pub const errSecCSResourcesNotSealed: OSStatus = -67057;
44/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsresourcesnotfound?language=objc)
45pub const errSecCSResourcesNotFound: OSStatus = -67056;
46/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsresourcesinvalid?language=objc)
47pub const errSecCSResourcesInvalid: OSStatus = -67055;
48/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadresource?language=objc)
49pub const errSecCSBadResource: OSStatus = -67054;
50/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsresourcerulesinvalid?language=objc)
51pub const errSecCSResourceRulesInvalid: OSStatus = -67053;
52/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsreqinvalid?language=objc)
53pub const errSecCSReqInvalid: OSStatus = -67052;
54/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsrequnsupported?language=objc)
55pub const errSecCSReqUnsupported: OSStatus = -67051;
56/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsreqfailed?language=objc)
57pub const errSecCSReqFailed: OSStatus = -67050;
58/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadobjectformat?language=objc)
59pub const errSecCSBadObjectFormat: OSStatus = -67049;
60/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinternalerror?language=objc)
61pub const errSecCSInternalError: OSStatus = -67048;
62/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostreject?language=objc)
63pub const errSecCSHostReject: OSStatus = -67047;
64/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsnotahost?language=objc)
65pub const errSecCSNotAHost: OSStatus = -67046;
66/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccssignatureinvalid?language=objc)
67pub const errSecCSSignatureInvalid: OSStatus = -67045;
68/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocolrelativepath?language=objc)
69pub const errSecCSHostProtocolRelativePath: OSStatus = -67044;
70/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocolcontradiction?language=objc)
71pub const errSecCSHostProtocolContradiction: OSStatus = -67043;
72/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocoldedicationerror?language=objc)
73pub const errSecCSHostProtocolDedicationError: OSStatus = -67042;
74/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocolnotproxy?language=objc)
75pub const errSecCSHostProtocolNotProxy: OSStatus = -67041;
76/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocolstateerror?language=objc)
77pub const errSecCSHostProtocolStateError: OSStatus = -67040;
78/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocolunrelated?language=objc)
79pub const errSecCSHostProtocolUnrelated: OSStatus = -67039;
80/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsnotsupported?language=objc)
81pub const errSecCSNotSupported: OSStatus = -67037;
82/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccscmstoolarge?language=objc)
83pub const errSecCSCMSTooLarge: OSStatus = -67036;
84/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocolinvalidhash?language=objc)
85pub const errSecCSHostProtocolInvalidHash: OSStatus = -67035;
86/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsstaticcodechanged?language=objc)
87pub const errSecCSStaticCodeChanged: OSStatus = -67034;
88/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsdbdenied?language=objc)
89pub const errSecCSDBDenied: OSStatus = -67033;
90/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsdbaccess?language=objc)
91pub const errSecCSDBAccess: OSStatus = -67032;
92/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccssigdbdenied?language=objc)
93pub const errSecCSSigDBDenied: OSStatus = -67033;
94/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccssigdbaccess?language=objc)
95pub const errSecCSSigDBAccess: OSStatus = -67032;
96/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshostprotocolinvalidattribute?language=objc)
97pub const errSecCSHostProtocolInvalidAttribute: OSStatus = -67031;
98/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinfoplistfailed?language=objc)
99pub const errSecCSInfoPlistFailed: OSStatus = -67030;
100/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsnomainexecutable?language=objc)
101pub const errSecCSNoMainExecutable: OSStatus = -67029;
102/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadbundleformat?language=objc)
103pub const errSecCSBadBundleFormat: OSStatus = -67028;
104/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsnomatches?language=objc)
105pub const errSecCSNoMatches: OSStatus = -67027;
106/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsfilehardquarantined?language=objc)
107pub const errSecCSFileHardQuarantined: OSStatus = -67026;
108/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsoutdated?language=objc)
109pub const errSecCSOutdated: OSStatus = -67025;
110/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsdbcorrupt?language=objc)
111pub const errSecCSDbCorrupt: OSStatus = -67024;
112/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsresourcedirectoryfailed?language=objc)
113pub const errSecCSResourceDirectoryFailed: OSStatus = -67023;
114/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsunsignednestedcode?language=objc)
115pub const errSecCSUnsignedNestedCode: OSStatus = -67022;
116/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadnestedcode?language=objc)
117pub const errSecCSBadNestedCode: OSStatus = -67021;
118/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadcallbackvalue?language=objc)
119pub const errSecCSBadCallbackValue: OSStatus = -67020;
120/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccshelperfailed?language=objc)
121pub const errSecCSHelperFailed: OSStatus = -67019;
122/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsvetoed?language=objc)
123pub const errSecCSVetoed: OSStatus = -67018;
124/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadlvarch?language=objc)
125pub const errSecCSBadLVArch: OSStatus = -67017;
126/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsresourcenotsupported?language=objc)
127pub const errSecCSResourceNotSupported: OSStatus = -67016;
128/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsregularfile?language=objc)
129pub const errSecCSRegularFile: OSStatus = -67015;
130/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsunsealedapproot?language=objc)
131pub const errSecCSUnsealedAppRoot: OSStatus = -67014;
132/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsweakresourcerules?language=objc)
133pub const errSecCSWeakResourceRules: OSStatus = -67013;
134/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsdsstoresymlink?language=objc)
135pub const errSecCSDSStoreSymlink: OSStatus = -67012;
136/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsambiguousbundleformat?language=objc)
137pub const errSecCSAmbiguousBundleFormat: OSStatus = -67011;
138/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadmainexecutable?language=objc)
139pub const errSecCSBadMainExecutable: OSStatus = -67010;
140/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadframeworkversion?language=objc)
141pub const errSecCSBadFrameworkVersion: OSStatus = -67009;
142/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsunsealedframeworkroot?language=objc)
143pub const errSecCSUnsealedFrameworkRoot: OSStatus = -67008;
144/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsweakresourceenvelope?language=objc)
145pub const errSecCSWeakResourceEnvelope: OSStatus = -67007;
146/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccscancelled?language=objc)
147pub const errSecCSCancelled: OSStatus = -67006;
148/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidplatform?language=objc)
149pub const errSecCSInvalidPlatform: OSStatus = -67005;
150/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccstoobig?language=objc)
151pub const errSecCSTooBig: OSStatus = -67004;
152/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidsymlink?language=objc)
153pub const errSecCSInvalidSymlink: OSStatus = -67003;
154/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsnotapplike?language=objc)
155pub const errSecCSNotAppLike: OSStatus = -67002;
156/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbaddiskimageformat?language=objc)
157pub const errSecCSBadDiskImageFormat: OSStatus = -67001;
158/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsunsupporteddigestalgorithm?language=objc)
159pub const errSecCSUnsupportedDigestAlgorithm: OSStatus = -67000;
160/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidassociatedfiledata?language=objc)
161pub const errSecCSInvalidAssociatedFileData: OSStatus = -66999;
162/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidteamidentifier?language=objc)
163pub const errSecCSInvalidTeamIdentifier: OSStatus = -66998;
164/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsbadteamidentifier?language=objc)
165pub const errSecCSBadTeamIdentifier: OSStatus = -66997;
166/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccssignatureuntrusted?language=objc)
167pub const errSecCSSignatureUntrusted: OSStatus = -66996;
168/// [Apple's documentation](https://developer.apple.com/documentation/security/errsecmultipleexecsegments?language=objc)
169pub const errSecMultipleExecSegments: OSStatus = -66995;
170/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidentitlements?language=objc)
171pub const errSecCSInvalidEntitlements: OSStatus = -66994;
172/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsinvalidruntimeversion?language=objc)
173pub const errSecCSInvalidRuntimeVersion: OSStatus = -66993;
174/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsrevokednotarization?language=objc)
175pub const errSecCSRevokedNotarization: OSStatus = -66992;
176/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccscmsconstructionfailed?language=objc)
177pub const errSecCSCMSConstructionFailed: OSStatus = -66991;
178/// [Apple's documentation](https://developer.apple.com/documentation/security/errseccsremotesignerfailed?language=objc)
179pub const errSecCSRemoteSignerFailed: OSStatus = -66990;
180
181extern "C" {
182    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorarchitecture?language=objc)
183    pub static kSecCFErrorArchitecture: &'static CFString;
184}
185
186extern "C" {
187    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorpattern?language=objc)
188    pub static kSecCFErrorPattern: &'static CFString;
189}
190
191extern "C" {
192    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorresourceseal?language=objc)
193    pub static kSecCFErrorResourceSeal: &'static CFString;
194}
195
196extern "C" {
197    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorresourceadded?language=objc)
198    pub static kSecCFErrorResourceAdded: &'static CFString;
199}
200
201extern "C" {
202    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorresourcealtered?language=objc)
203    pub static kSecCFErrorResourceAltered: &'static CFString;
204}
205
206extern "C" {
207    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorresourcemissing?language=objc)
208    pub static kSecCFErrorResourceMissing: &'static CFString;
209}
210
211extern "C" {
212    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorresourcesideband?language=objc)
213    pub static kSecCFErrorResourceSideband: &'static CFString;
214}
215
216extern "C" {
217    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorresourcerecursive?language=objc)
218    pub static kSecCFErrorResourceRecursive: &'static CFString;
219}
220
221extern "C" {
222    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorinfoplist?language=objc)
223    pub static kSecCFErrorInfoPlist: &'static CFString;
224}
225
226extern "C" {
227    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorguestattributes?language=objc)
228    pub static kSecCFErrorGuestAttributes: &'static CFString;
229}
230
231extern "C" {
232    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorrequirementsyntax?language=objc)
233    pub static kSecCFErrorRequirementSyntax: &'static CFString;
234}
235
236extern "C" {
237    /// [Apple's documentation](https://developer.apple.com/documentation/security/kseccferrorpath?language=objc)
238    pub static kSecCFErrorPath: &'static CFString;
239}
240
241/// This is the type of a reference to running code.
242///
243/// In many (but not all) calls, this can be passed to a SecStaticCodeRef
244/// argument, which performs an implicit SecCodeCopyStaticCode call and
245/// operates on the result.
246///
247/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccode?language=objc)
248#[doc(alias = "SecCodeRef")]
249#[repr(C)]
250pub struct SecCode {
251    inner: [u8; 0],
252    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
253}
254
255cf_type!(
256    unsafe impl SecCode {}
257);
258#[cfg(feature = "objc2")]
259cf_objc2_type!(
260    unsafe impl RefEncode<"__SecCode"> for SecCode {}
261);
262
263/// This is the type of a reference to static code on disk.
264///
265/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secstaticcode?language=objc)
266#[doc(alias = "SecStaticCodeRef")]
267#[repr(C)]
268pub struct SecStaticCode {
269    inner: [u8; 0],
270    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
271}
272
273cf_type!(
274    unsafe impl SecStaticCode {}
275);
276#[cfg(feature = "objc2")]
277cf_objc2_type!(
278    unsafe impl RefEncode<"__SecCode"> for SecStaticCode {}
279);
280
281/// This is the type of a reference to a code requirement.
282///
283/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secrequirement?language=objc)
284#[doc(alias = "SecRequirementRef")]
285#[repr(C)]
286pub struct SecRequirement {
287    inner: [u8; 0],
288    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
289}
290
291cf_type!(
292    unsafe impl SecRequirement {}
293);
294#[cfg(feature = "objc2")]
295cf_objc2_type!(
296    unsafe impl RefEncode<"__SecRequirement"> for SecRequirement {}
297);
298
299/// An abstract handle to identify a particular Guest in the context of its Host.
300///
301/// Guest handles are assigned by the host at will, with kSecNoGuest (zero) being
302/// reserved as the null value. They can be reused for new children if desired.
303///
304/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secguestref?language=objc)
305pub type SecGuestRef = u32;
306
307/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecnoguest?language=objc)
308pub const kSecNoGuest: SecGuestRef = 0;
309
310/// This is the type of flags arguments to Code Signing API calls.
311/// It provides a bit mask of request and option flags. All of the bits in these
312/// masks are reserved to Apple; if you set any bits not defined in these headers,
313/// the behavior is generally undefined.
314///
315/// This list describes the flags that are shared among several Code Signing API calls.
316/// Flags that only apply to one call are defined and documented with that call.
317/// Global flags are assigned from high order down (31 -> 0); call-specific flags
318/// are assigned from the bottom up (0 -> 31).
319///
320///
321/// When passed to a flags argument throughout, indicates that default behavior
322/// is desired. Do not mix with other flags values.
323///
324/// When passed to a call that performs code validation, requests that code signatures
325/// made by expired certificates be rejected. By default, expiration of participating
326/// certificates is not automatic grounds for rejection.
327///
328/// When passed to a call that performs code validation, configures the validation to
329/// not perform any work that requires the network. Using this flag disables security features
330/// like online certificate revocation and notarization checks by removing potentially
331/// slow network requests that can delay evaluations. This flag has always been usable for
332/// SecStaticCode objects and is usable with SecCode objects starting with macOS 11.3.
333///
334/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccsflags?language=objc)
335// NS_OPTIONS
336#[repr(transparent)]
337#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
338pub struct SecCSFlags(pub u32);
339bitflags::bitflags! {
340    impl SecCSFlags: u32 {
341        #[doc(alias = "kSecCSDefaultFlags")]
342        const DefaultFlags = 0;
343        #[doc(alias = "kSecCSConsiderExpiration")]
344        const ConsiderExpiration = 1<<31;
345        #[doc(alias = "kSecCSEnforceRevocationChecks")]
346        const EnforceRevocationChecks = 1<<30;
347        #[doc(alias = "kSecCSNoNetworkAccess")]
348        const NoNetworkAccess = 1<<29;
349        #[doc(alias = "kSecCSReportProgress")]
350        const ReportProgress = 1<<28;
351        #[doc(alias = "kSecCSCheckTrustedAnchors")]
352        const CheckTrustedAnchors = 1<<27;
353        #[doc(alias = "kSecCSQuickCheck")]
354        const QuickCheck = 1<<26;
355        #[doc(alias = "kSecCSApplyEmbeddedPolicy")]
356        const ApplyEmbeddedPolicy = 1<<25;
357        #[doc(alias = "kSecCSStripDisallowedXattrs")]
358        const StripDisallowedXattrs = 1<<24;
359        #[doc(alias = "kSecCSMatchGuestRequirementInKernel")]
360        const MatchGuestRequirementInKernel = 1<<23;
361    }
362}
363
364#[cfg(feature = "objc2")]
365unsafe impl Encode for SecCSFlags {
366    const ENCODING: Encoding = u32::ENCODING;
367}
368
369#[cfg(feature = "objc2")]
370unsafe impl RefEncode for SecCSFlags {
371    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
372}
373
374/// This is the type of option flags that can be embedded in a code signature
375/// during signing, and that govern the use of the signature thereafter.
376/// Some of these flags can be set through the codesign(1) command's --options
377/// argument; some are set implicitly based on signing circumstances; and all
378/// can be set with the kSecCodeSignerFlags item of a signing information dictionary.
379///
380///
381/// Indicates that the code may act as a host that controls and supervises guest
382/// code. If this flag is not set in a code signature, the code is never considered
383/// eligible to be a host, and any attempt to act like one will be ignored or rejected.
384///
385/// The code has been sealed without a signing identity. No identity may be retrieved
386/// from it, and any code requirement placing restrictions on the signing identity
387/// will fail. This flag is set by the code signing API and cannot be set explicitly.
388///
389/// Implicitly set the "hard" status bit for the code when it starts running.
390/// This bit indicates that the code prefers to be denied access to a resource
391/// if gaining such access would cause its invalidation. Since the hard bit is
392/// sticky, setting this option bit guarantees that the code will always have
393/// it set.
394///
395/// Implicitly set the "kill" status bit for the code when it starts running.
396/// This bit indicates that the code wishes to be terminated with prejudice if
397/// it is ever invalidated. Since the kill bit is sticky, setting this option bit
398/// guarantees that the code will always be dynamically valid, since it will die
399/// immediately    if it becomes invalid.
400///
401/// Forces the kSecCSConsiderExpiration flag on all validations of the code.
402///
403/// Instructs the kernel to apply runtime hardening policies as required by the
404/// hardened runtime version
405///
406/// The code was automatically signed by the linker. This signature should be
407/// ignored in any new signing operation.
408///
409/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccodesignatureflags?language=objc)
410// NS_OPTIONS
411#[repr(transparent)]
412#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
413pub struct SecCodeSignatureFlags(pub u32);
414bitflags::bitflags! {
415    impl SecCodeSignatureFlags: u32 {
416        #[doc(alias = "kSecCodeSignatureHost")]
417        const Host = 0x0001;
418        #[doc(alias = "kSecCodeSignatureAdhoc")]
419        const Adhoc = 0x0002;
420        #[doc(alias = "kSecCodeSignatureForceHard")]
421        const ForceHard = 0x0100;
422        #[doc(alias = "kSecCodeSignatureForceKill")]
423        const ForceKill = 0x0200;
424        #[doc(alias = "kSecCodeSignatureForceExpiration")]
425        const ForceExpiration = 0x0400;
426        #[doc(alias = "kSecCodeSignatureRestrict")]
427        const Restrict = 0x0800;
428        #[doc(alias = "kSecCodeSignatureEnforcement")]
429        const Enforcement = 0x1000;
430        #[doc(alias = "kSecCodeSignatureLibraryValidation")]
431        const LibraryValidation = 0x2000;
432        #[doc(alias = "kSecCodeSignatureRuntime")]
433        const Runtime = 0x10000;
434        #[doc(alias = "kSecCodeSignatureLinkerSigned")]
435        const LinkerSigned = 0x20000;
436    }
437}
438
439#[cfg(feature = "objc2")]
440unsafe impl Encode for SecCodeSignatureFlags {
441    const ENCODING: Encoding = u32::ENCODING;
442}
443
444#[cfg(feature = "objc2")]
445unsafe impl RefEncode for SecCodeSignatureFlags {
446    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
447}
448
449/// The code signing system attaches a set of status flags to each running code.
450/// These flags are maintained by the code's host, and can be read by anyone.
451/// A code may change its own flags, a host may change its guests' flags,
452/// and root may change anyone's flags.    However, these flags are sticky in that
453/// each can change in only one direction (and never back, for the lifetime of the code).
454/// Not even root can violate this restriction.
455///
456/// There are other flags in SecCodeStatus that are not publicly documented.
457/// Do not rely on them, and do not ever attempt to explicitly set them.
458///
459///
460/// Indicates that the code is dynamically valid, i.e. it started correctly
461/// and has not been invalidated since then. The valid bit can only be cleared.
462///
463/// Warning: This bit is not your one-stop shortcut to determining the validity    of code.
464/// It represents the dynamic component of the full validity function; if this
465/// bit is unset, the code is definitely invalid, but the converse is not always true.
466/// In fact, code hosts may represent the outcome of some delayed static validation work in this bit,
467/// and thus it strictly represents a blend of (all of) dynamic and (some of) static validity,
468/// depending on the implementation of the particular host managing the code. You can (only)
469/// rely that (1) dynamic invalidation will clear this bit; and (2) the combination
470/// of static validation and dynamic validity (as performed by the SecCodeCheckValidity* APIs)
471/// will give a correct answer.
472///
473///
474/// Indicates that the code prefers to be denied access to resources if gaining access
475/// would invalidate it. This bit can only be set.
476/// It is undefined whether code that is marked hard and is already invalid will still
477/// be denied access to a resource that would invalidate it if it were still valid. That is,
478/// the code may or may not get access to such a resource while being invalid, and that choice
479/// may appear random.
480///
481///
482/// Indicates that the code wants to be killed (terminated) if it ever loses its validity.
483/// This bit can only be set. Code that has the kill flag set will never be dynamically invalid
484/// (and live). Note however that a change in static validity does not necessarily trigger instant
485/// death.
486///
487///
488/// Indicated that code has been debugged by another process that was allowed to do so. The debugger
489/// causes this to be set when it attachs.
490///
491///
492/// Indicates the code is platform code, shipping with the operating system and signed by Apple.
493///
494/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccodestatus?language=objc)
495// NS_OPTIONS
496#[repr(transparent)]
497#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
498pub struct SecCodeStatus(pub u32);
499bitflags::bitflags! {
500    impl SecCodeStatus: u32 {
501        #[doc(alias = "kSecCodeStatusValid")]
502        const Valid = 0x00000001;
503        #[doc(alias = "kSecCodeStatusHard")]
504        const Hard = 0x00000100;
505        #[doc(alias = "kSecCodeStatusKill")]
506        const Kill = 0x00000200;
507        #[doc(alias = "kSecCodeStatusDebugged")]
508        const Debugged = 0x10000000;
509        #[doc(alias = "kSecCodeStatusPlatform")]
510        const Platform = 0x04000000;
511    }
512}
513
514#[cfg(feature = "objc2")]
515unsafe impl Encode for SecCodeStatus {
516    const ENCODING: Encoding = u32::ENCODING;
517}
518
519#[cfg(feature = "objc2")]
520unsafe impl RefEncode for SecCodeStatus {
521    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
522}
523
524/// An enumeration indicating different types of internal requirements for code.
525///
526/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secrequirementtype?language=objc)
527// NS_ENUM
528#[repr(transparent)]
529#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
530pub struct SecRequirementType(pub u32);
531impl SecRequirementType {
532    #[doc(alias = "kSecHostRequirementType")]
533    pub const HostRequirementType: Self = Self(1);
534    #[doc(alias = "kSecGuestRequirementType")]
535    pub const GuestRequirementType: Self = Self(2);
536    #[doc(alias = "kSecDesignatedRequirementType")]
537    pub const DesignatedRequirementType: Self = Self(3);
538    #[doc(alias = "kSecLibraryRequirementType")]
539    pub const LibraryRequirementType: Self = Self(4);
540    #[doc(alias = "kSecPluginRequirementType")]
541    pub const PluginRequirementType: Self = Self(5);
542    #[doc(alias = "kSecInvalidRequirementType")]
543    pub const InvalidRequirementType: Self = Self(6);
544    #[doc(alias = "kSecRequirementTypeCount")]
545    pub const RequirementTypeCount: Self = Self(SecRequirementType::InvalidRequirementType.0);
546}
547
548#[cfg(feature = "objc2")]
549unsafe impl Encode for SecRequirementType {
550    const ENCODING: Encoding = u32::ENCODING;
551}
552
553#[cfg(feature = "objc2")]
554unsafe impl RefEncode for SecRequirementType {
555    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
556}
557
558/// Types of cryptographic digests (hashes) used to hold code signatures
559/// together.
560///
561/// Each combination of type, length, and other parameters is a separate
562/// hash type; we don't understand "families" here.
563///
564/// These type codes govern the digest links that connect a CodeDirectory
565/// to its subordinate data structures (code pages, resources, etc.)
566/// They do not directly control other uses of hashes (such as those used
567/// within X.509 certificates and CMS blobs).
568///
569/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccsdigestalgorithm?language=objc)
570// NS_ENUM
571#[repr(transparent)]
572#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
573pub struct SecCSDigestAlgorithm(pub u32);
574impl SecCSDigestAlgorithm {
575    #[doc(alias = "kSecCodeSignatureNoHash")]
576    pub const CodeSignatureNoHash: Self = Self(0);
577    #[doc(alias = "kSecCodeSignatureHashSHA1")]
578    pub const CodeSignatureHashSHA1: Self = Self(1);
579    #[doc(alias = "kSecCodeSignatureHashSHA256")]
580    pub const CodeSignatureHashSHA256: Self = Self(2);
581    #[doc(alias = "kSecCodeSignatureHashSHA256Truncated")]
582    pub const CodeSignatureHashSHA256Truncated: Self = Self(3);
583    #[doc(alias = "kSecCodeSignatureHashSHA384")]
584    pub const CodeSignatureHashSHA384: Self = Self(4);
585    #[doc(alias = "kSecCodeSignatureHashSHA512")]
586    pub const CodeSignatureHashSHA512: Self = Self(5);
587}
588
589#[cfg(feature = "objc2")]
590unsafe impl Encode for SecCSDigestAlgorithm {
591    const ENCODING: Encoding = u32::ENCODING;
592}
593
594#[cfg(feature = "objc2")]
595unsafe impl RefEncode for SecCSDigestAlgorithm {
596    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
597}