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#[repr(C)]
249pub struct SecCode {
250    inner: [u8; 0],
251    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
252}
253
254cf_type!(
255    #[encoding_name = "__SecCode"]
256    unsafe impl SecCode {}
257);
258
259/// This is the type of a reference to static code on disk.
260///
261/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secstaticcode?language=objc)
262#[repr(C)]
263pub struct SecStaticCode {
264    inner: [u8; 0],
265    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
266}
267
268cf_type!(
269    #[encoding_name = "__SecCode"]
270    unsafe impl SecStaticCode {}
271);
272
273/// This is the type of a reference to a code requirement.
274///
275/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secrequirement?language=objc)
276#[repr(C)]
277pub struct SecRequirement {
278    inner: [u8; 0],
279    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
280}
281
282cf_type!(
283    #[encoding_name = "__SecRequirement"]
284    unsafe impl SecRequirement {}
285);
286
287/// An abstract handle to identify a particular Guest in the context of its Host.
288///
289/// Guest handles are assigned by the host at will, with kSecNoGuest (zero) being
290/// reserved as the null value. They can be reused for new children if desired.
291///
292/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secguestref?language=objc)
293pub type SecGuestRef = u32;
294
295/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecnoguest?language=objc)
296pub const kSecNoGuest: SecGuestRef = 0;
297
298/// This is the type of flags arguments to Code Signing API calls.
299/// It provides a bit mask of request and option flags. All of the bits in these
300/// masks are reserved to Apple; if you set any bits not defined in these headers,
301/// the behavior is generally undefined.
302///
303/// This list describes the flags that are shared among several Code Signing API calls.
304/// Flags that only apply to one call are defined and documented with that call.
305/// Global flags are assigned from high order down (31 -> 0); call-specific flags
306/// are assigned from the bottom up (0 -> 31).
307///
308///
309/// When passed to a flags argument throughout, indicates that default behavior
310/// is desired. Do not mix with other flags values.
311///
312/// When passed to a call that performs code validation, requests that code signatures
313/// made by expired certificates be rejected. By default, expiration of participating
314/// certificates is not automatic grounds for rejection.
315///
316/// When passed to a call that performs code validation, configures the validation to
317/// not perform any work that requires the network. Using this flag disables security features
318/// like online certificate revocation and notarization checks by removing potentially
319/// slow network requests that can delay evaluations. This flag has always been usable for
320/// SecStaticCode objects and is usable with SecCode objects starting with macOS 11.3.
321///
322/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccsflags?language=objc)
323// NS_OPTIONS
324#[repr(transparent)]
325#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
326pub struct SecCSFlags(pub u32);
327bitflags::bitflags! {
328    impl SecCSFlags: u32 {
329        #[doc(alias = "kSecCSDefaultFlags")]
330        const DefaultFlags = 0;
331        #[doc(alias = "kSecCSConsiderExpiration")]
332        const ConsiderExpiration = 1<<31;
333        #[doc(alias = "kSecCSEnforceRevocationChecks")]
334        const EnforceRevocationChecks = 1<<30;
335        #[doc(alias = "kSecCSNoNetworkAccess")]
336        const NoNetworkAccess = 1<<29;
337        #[doc(alias = "kSecCSReportProgress")]
338        const ReportProgress = 1<<28;
339        #[doc(alias = "kSecCSCheckTrustedAnchors")]
340        const CheckTrustedAnchors = 1<<27;
341        #[doc(alias = "kSecCSQuickCheck")]
342        const QuickCheck = 1<<26;
343        #[doc(alias = "kSecCSApplyEmbeddedPolicy")]
344        const ApplyEmbeddedPolicy = 1<<25;
345        #[doc(alias = "kSecCSStripDisallowedXattrs")]
346        const StripDisallowedXattrs = 1<<24;
347        #[doc(alias = "kSecCSMatchGuestRequirementInKernel")]
348        const MatchGuestRequirementInKernel = 1<<23;
349    }
350}
351
352#[cfg(feature = "objc2")]
353unsafe impl Encode for SecCSFlags {
354    const ENCODING: Encoding = u32::ENCODING;
355}
356
357#[cfg(feature = "objc2")]
358unsafe impl RefEncode for SecCSFlags {
359    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
360}
361
362/// This is the type of option flags that can be embedded in a code signature
363/// during signing, and that govern the use of the signature thereafter.
364/// Some of these flags can be set through the codesign(1) command's --options
365/// argument; some are set implicitly based on signing circumstances; and all
366/// can be set with the kSecCodeSignerFlags item of a signing information dictionary.
367///
368///
369/// Indicates that the code may act as a host that controls and supervises guest
370/// code. If this flag is not set in a code signature, the code is never considered
371/// eligible to be a host, and any attempt to act like one will be ignored or rejected.
372///
373/// The code has been sealed without a signing identity. No identity may be retrieved
374/// from it, and any code requirement placing restrictions on the signing identity
375/// will fail. This flag is set by the code signing API and cannot be set explicitly.
376///
377/// Implicitly set the "hard" status bit for the code when it starts running.
378/// This bit indicates that the code prefers to be denied access to a resource
379/// if gaining such access would cause its invalidation. Since the hard bit is
380/// sticky, setting this option bit guarantees that the code will always have
381/// it set.
382///
383/// Implicitly set the "kill" status bit for the code when it starts running.
384/// This bit indicates that the code wishes to be terminated with prejudice if
385/// it is ever invalidated. Since the kill bit is sticky, setting this option bit
386/// guarantees that the code will always be dynamically valid, since it will die
387/// immediately    if it becomes invalid.
388///
389/// Forces the kSecCSConsiderExpiration flag on all validations of the code.
390///
391/// Instructs the kernel to apply runtime hardening policies as required by the
392/// hardened runtime version
393///
394/// The code was automatically signed by the linker. This signature should be
395/// ignored in any new signing operation.
396///
397/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccodesignatureflags?language=objc)
398// NS_OPTIONS
399#[repr(transparent)]
400#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
401pub struct SecCodeSignatureFlags(pub u32);
402bitflags::bitflags! {
403    impl SecCodeSignatureFlags: u32 {
404        #[doc(alias = "kSecCodeSignatureHost")]
405        const Host = 0x0001;
406        #[doc(alias = "kSecCodeSignatureAdhoc")]
407        const Adhoc = 0x0002;
408        #[doc(alias = "kSecCodeSignatureForceHard")]
409        const ForceHard = 0x0100;
410        #[doc(alias = "kSecCodeSignatureForceKill")]
411        const ForceKill = 0x0200;
412        #[doc(alias = "kSecCodeSignatureForceExpiration")]
413        const ForceExpiration = 0x0400;
414        #[doc(alias = "kSecCodeSignatureRestrict")]
415        const Restrict = 0x0800;
416        #[doc(alias = "kSecCodeSignatureEnforcement")]
417        const Enforcement = 0x1000;
418        #[doc(alias = "kSecCodeSignatureLibraryValidation")]
419        const LibraryValidation = 0x2000;
420        #[doc(alias = "kSecCodeSignatureRuntime")]
421        const Runtime = 0x10000;
422        #[doc(alias = "kSecCodeSignatureLinkerSigned")]
423        const LinkerSigned = 0x20000;
424    }
425}
426
427#[cfg(feature = "objc2")]
428unsafe impl Encode for SecCodeSignatureFlags {
429    const ENCODING: Encoding = u32::ENCODING;
430}
431
432#[cfg(feature = "objc2")]
433unsafe impl RefEncode for SecCodeSignatureFlags {
434    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
435}
436
437/// The code signing system attaches a set of status flags to each running code.
438/// These flags are maintained by the code's host, and can be read by anyone.
439/// A code may change its own flags, a host may change its guests' flags,
440/// and root may change anyone's flags.    However, these flags are sticky in that
441/// each can change in only one direction (and never back, for the lifetime of the code).
442/// Not even root can violate this restriction.
443///
444/// There are other flags in SecCodeStatus that are not publicly documented.
445/// Do not rely on them, and do not ever attempt to explicitly set them.
446///
447///
448/// Indicates that the code is dynamically valid, i.e. it started correctly
449/// and has not been invalidated since then. The valid bit can only be cleared.
450///
451/// Warning: This bit is not your one-stop shortcut to determining the validity    of code.
452/// It represents the dynamic component of the full validity function; if this
453/// bit is unset, the code is definitely invalid, but the converse is not always true.
454/// In fact, code hosts may represent the outcome of some delayed static validation work in this bit,
455/// and thus it strictly represents a blend of (all of) dynamic and (some of) static validity,
456/// depending on the implementation of the particular host managing the code. You can (only)
457/// rely that (1) dynamic invalidation will clear this bit; and (2) the combination
458/// of static validation and dynamic validity (as performed by the SecCodeCheckValidity* APIs)
459/// will give a correct answer.
460///
461///
462/// Indicates that the code prefers to be denied access to resources if gaining access
463/// would invalidate it. This bit can only be set.
464/// It is undefined whether code that is marked hard and is already invalid will still
465/// be denied access to a resource that would invalidate it if it were still valid. That is,
466/// the code may or may not get access to such a resource while being invalid, and that choice
467/// may appear random.
468///
469///
470/// Indicates that the code wants to be killed (terminated) if it ever loses its validity.
471/// This bit can only be set. Code that has the kill flag set will never be dynamically invalid
472/// (and live). Note however that a change in static validity does not necessarily trigger instant
473/// death.
474///
475///
476/// Indicated that code has been debugged by another process that was allowed to do so. The debugger
477/// causes this to be set when it attachs.
478///
479///
480/// Indicates the code is platform code, shipping with the operating system and signed by Apple.
481///
482/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccodestatus?language=objc)
483// NS_OPTIONS
484#[repr(transparent)]
485#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
486pub struct SecCodeStatus(pub u32);
487bitflags::bitflags! {
488    impl SecCodeStatus: u32 {
489        #[doc(alias = "kSecCodeStatusValid")]
490        const Valid = 0x00000001;
491        #[doc(alias = "kSecCodeStatusHard")]
492        const Hard = 0x00000100;
493        #[doc(alias = "kSecCodeStatusKill")]
494        const Kill = 0x00000200;
495        #[doc(alias = "kSecCodeStatusDebugged")]
496        const Debugged = 0x10000000;
497        #[doc(alias = "kSecCodeStatusPlatform")]
498        const Platform = 0x04000000;
499    }
500}
501
502#[cfg(feature = "objc2")]
503unsafe impl Encode for SecCodeStatus {
504    const ENCODING: Encoding = u32::ENCODING;
505}
506
507#[cfg(feature = "objc2")]
508unsafe impl RefEncode for SecCodeStatus {
509    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
510}
511
512/// An enumeration indicating different types of internal requirements for code.
513///
514/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secrequirementtype?language=objc)
515// NS_ENUM
516#[repr(transparent)]
517#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
518pub struct SecRequirementType(pub u32);
519impl SecRequirementType {
520    #[doc(alias = "kSecHostRequirementType")]
521    pub const HostRequirementType: Self = Self(1);
522    #[doc(alias = "kSecGuestRequirementType")]
523    pub const GuestRequirementType: Self = Self(2);
524    #[doc(alias = "kSecDesignatedRequirementType")]
525    pub const DesignatedRequirementType: Self = Self(3);
526    #[doc(alias = "kSecLibraryRequirementType")]
527    pub const LibraryRequirementType: Self = Self(4);
528    #[doc(alias = "kSecPluginRequirementType")]
529    pub const PluginRequirementType: Self = Self(5);
530    #[doc(alias = "kSecInvalidRequirementType")]
531    pub const InvalidRequirementType: Self = Self(6);
532    #[doc(alias = "kSecRequirementTypeCount")]
533    pub const RequirementTypeCount: Self = Self(SecRequirementType::InvalidRequirementType.0);
534}
535
536#[cfg(feature = "objc2")]
537unsafe impl Encode for SecRequirementType {
538    const ENCODING: Encoding = u32::ENCODING;
539}
540
541#[cfg(feature = "objc2")]
542unsafe impl RefEncode for SecRequirementType {
543    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
544}
545
546/// Types of cryptographic digests (hashes) used to hold code signatures
547/// together.
548///
549/// Each combination of type, length, and other parameters is a separate
550/// hash type; we don't understand "families" here.
551///
552/// These type codes govern the digest links that connect a CodeDirectory
553/// to its subordinate data structures (code pages, resources, etc.)
554/// They do not directly control other uses of hashes (such as those used
555/// within X.509 certificates and CMS blobs).
556///
557/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seccsdigestalgorithm?language=objc)
558// NS_ENUM
559#[repr(transparent)]
560#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
561pub struct SecCSDigestAlgorithm(pub u32);
562impl SecCSDigestAlgorithm {
563    #[doc(alias = "kSecCodeSignatureNoHash")]
564    pub const CodeSignatureNoHash: Self = Self(0);
565    #[doc(alias = "kSecCodeSignatureHashSHA1")]
566    pub const CodeSignatureHashSHA1: Self = Self(1);
567    #[doc(alias = "kSecCodeSignatureHashSHA256")]
568    pub const CodeSignatureHashSHA256: Self = Self(2);
569    #[doc(alias = "kSecCodeSignatureHashSHA256Truncated")]
570    pub const CodeSignatureHashSHA256Truncated: Self = Self(3);
571    #[doc(alias = "kSecCodeSignatureHashSHA384")]
572    pub const CodeSignatureHashSHA384: Self = Self(4);
573    #[doc(alias = "kSecCodeSignatureHashSHA512")]
574    pub const CodeSignatureHashSHA512: Self = Self(5);
575}
576
577#[cfg(feature = "objc2")]
578unsafe impl Encode for SecCSDigestAlgorithm {
579    const ENCODING: Encoding = u32::ENCODING;
580}
581
582#[cfg(feature = "objc2")]
583unsafe impl RefEncode for SecCSDigestAlgorithm {
584    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
585}