objc2_security/generated/
SecACL.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6use objc2_core_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/security/seckeychainpromptselector?language=objc)
11// NS_OPTIONS
12#[cfg(feature = "cssmconfig")]
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct SecKeychainPromptSelector(pub uint16);
16#[cfg(feature = "cssmconfig")]
17bitflags::bitflags! {
18    impl SecKeychainPromptSelector: uint16 {
19        #[doc(alias = "kSecKeychainPromptRequirePassphase")]
20        const RequirePassphase = 0x0001;
21        #[doc(alias = "kSecKeychainPromptUnsigned")]
22        const Unsigned = 0x0010;
23        #[doc(alias = "kSecKeychainPromptUnsignedAct")]
24        const UnsignedAct = 0x0020;
25        #[doc(alias = "kSecKeychainPromptInvalid")]
26        const Invalid = 0x0040;
27        #[doc(alias = "kSecKeychainPromptInvalidAct")]
28        const InvalidAct = 0x0080;
29    }
30}
31
32#[cfg(all(feature = "cssmconfig", feature = "objc2"))]
33unsafe impl Encode for SecKeychainPromptSelector {
34    const ENCODING: Encoding = uint16::ENCODING;
35}
36
37#[cfg(all(feature = "cssmconfig", feature = "objc2"))]
38unsafe impl RefEncode for SecKeychainPromptSelector {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42#[cfg(feature = "SecBase")]
43unsafe impl ConcreteType for SecACL {
44    /// Returns the type identifier of SecACL instances.
45    ///
46    /// Returns: The CFTypeID of SecACL instances.
47    #[doc(alias = "SecACLGetTypeID")]
48    #[inline]
49    fn type_id() -> CFTypeID {
50        extern "C-unwind" {
51            fn SecACLGetTypeID() -> CFTypeID;
52        }
53        unsafe { SecACLGetTypeID() }
54    }
55}
56
57#[cfg(feature = "SecBase")]
58impl SecACL {
59    /// Creates a new access control list entry from the application list, description, and prompt selector provided and adds it to an item's access.
60    ///
61    /// Parameter `access`: An access reference.
62    ///
63    /// Parameter `applicationList`: An array of SecTrustedApplication instances that will be allowed access without prompting.
64    ///
65    /// Parameter `description`: The human readable name that will be used to refer to this item when the user is prompted.
66    ///
67    /// Parameter `promptSelector`: A pointer to a CSSM prompt selector.
68    ///
69    /// Parameter `newAcl`: A pointer to an access control list entry.  On return, this points to the reference of the new access control list entry.
70    ///
71    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
72    ///
73    /// This function is deprecated in 10.7 and later;
74    /// use SecACLCreateWithSimpleContents instead.
75    ///
76    /// # Safety
77    ///
78    /// - `application_list` generic must be of the correct type.
79    /// - `prompt_selector` must be a valid pointer.
80    /// - `new_acl` must be a valid pointer.
81    #[doc(alias = "SecACLCreateFromSimpleContents")]
82    #[cfg(all(feature = "SecBase", feature = "cssmapple", feature = "cssmconfig"))]
83    #[deprecated = "CSSM is not supported"]
84    #[inline]
85    pub unsafe fn create_from_simple_contents(
86        access: &SecAccess,
87        application_list: Option<&CFArray>,
88        description: &CFString,
89        prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
90        new_acl: NonNull<*mut SecACL>,
91    ) -> OSStatus {
92        extern "C-unwind" {
93            fn SecACLCreateFromSimpleContents(
94                access: &SecAccess,
95                application_list: Option<&CFArray>,
96                description: &CFString,
97                prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
98                new_acl: NonNull<*mut SecACL>,
99            ) -> OSStatus;
100        }
101        unsafe {
102            SecACLCreateFromSimpleContents(
103                access,
104                application_list,
105                description,
106                prompt_selector,
107                new_acl,
108            )
109        }
110    }
111
112    /// Creates a new access control list entry from the application list, description, and prompt selector provided and adds it to an item's access.
113    ///
114    /// Parameter `access`: An access reference.
115    ///
116    /// Parameter `applicationList`: An array of SecTrustedApplication instances that will be allowed access without prompting.
117    ///
118    /// Parameter `description`: The human readable name that will be used to refer to this item when the user is prompted.
119    ///
120    /// Parameter `promptSelector`: A SecKeychainPromptSelector selector.
121    ///
122    /// Parameter `newAcl`: A pointer to an access control list entry.  On return, this points to the reference of the new access control list entry.
123    ///
124    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
125    ///
126    /// # Safety
127    ///
128    /// - `application_list` generic must be of the correct type.
129    /// - `new_acl` must be a valid pointer.
130    #[doc(alias = "SecACLCreateWithSimpleContents")]
131    #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
132    #[deprecated = "SecKeychain is deprecated"]
133    #[inline]
134    pub unsafe fn create_with_simple_contents(
135        access: &SecAccess,
136        application_list: Option<&CFArray>,
137        description: &CFString,
138        prompt_selector: SecKeychainPromptSelector,
139        new_acl: NonNull<*mut SecACL>,
140    ) -> OSStatus {
141        extern "C-unwind" {
142            fn SecACLCreateWithSimpleContents(
143                access: &SecAccess,
144                application_list: Option<&CFArray>,
145                description: &CFString,
146                prompt_selector: SecKeychainPromptSelector,
147                new_acl: NonNull<*mut SecACL>,
148            ) -> OSStatus;
149        }
150        unsafe {
151            SecACLCreateWithSimpleContents(
152                access,
153                application_list,
154                description,
155                prompt_selector,
156                new_acl,
157            )
158        }
159    }
160
161    /// Removes the access control list entry specified.
162    ///
163    /// Parameter `aclRef`: The reference to the access control list entry to remove.
164    ///
165    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
166    #[doc(alias = "SecACLRemove")]
167    #[cfg(feature = "SecBase")]
168    #[deprecated = "SecKeychain is deprecated"]
169    #[inline]
170    pub unsafe fn remove(&self) -> OSStatus {
171        extern "C-unwind" {
172            fn SecACLRemove(acl_ref: &SecACL) -> OSStatus;
173        }
174        unsafe { SecACLRemove(self) }
175    }
176
177    /// Returns the application list, description, and CSSM prompt selector for a given access control list entry.
178    ///
179    /// Parameter `acl`: An access control list entry reference.
180    ///
181    /// Parameter `applicationList`: On return, An array of SecTrustedApplication instances that will be allowed access without prompting, for the given access control list entry.  The caller needs to call CFRelease on this array when it's no longer needed.
182    ///
183    /// Parameter `description`: On return, the human readable name that will be used to refer to this item when the user is prompted, for the given access control list entry. The caller needs to call CFRelease on this string when it's no longer needed.
184    ///
185    /// Parameter `promptSelector`: A pointer to a CSSM prompt selector.  On return, this points to the CSSM prompt selector for the given access control list entry.
186    ///
187    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
188    ///
189    /// This function is deprecated in 10.7 and later;
190    /// use SecACLCopyContents instead.
191    ///
192    /// # Safety
193    ///
194    /// - `application_list` must be a valid pointer.
195    /// - `description` must be a valid pointer.
196    /// - `prompt_selector` must be a valid pointer.
197    #[doc(alias = "SecACLCopySimpleContents")]
198    #[cfg(all(feature = "SecBase", feature = "cssmapple", feature = "cssmconfig"))]
199    #[deprecated = "CSSM is not supported"]
200    #[inline]
201    pub unsafe fn copy_simple_contents(
202        &self,
203        application_list: NonNull<*const CFArray>,
204        description: NonNull<*const CFString>,
205        prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
206    ) -> OSStatus {
207        extern "C-unwind" {
208            fn SecACLCopySimpleContents(
209                acl: &SecACL,
210                application_list: NonNull<*const CFArray>,
211                description: NonNull<*const CFString>,
212                prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
213            ) -> OSStatus;
214        }
215        unsafe { SecACLCopySimpleContents(self, application_list, description, prompt_selector) }
216    }
217
218    /// Returns the application list, description, and prompt selector for a given access control list entry.
219    ///
220    /// Parameter `acl`: An access control list entry reference.
221    ///
222    /// Parameter `applicationList`: On return, An array of SecTrustedApplication instances that will be allowed access without prompting, for the given access control list entry.  The caller needs to call CFRelease on this array when it's no longer needed.
223    ///
224    /// Parameter `description`: On return, the human readable name that will be used to refer to this item when the user is prompted, for the given access control list entry. The caller needs to call CFRelease on this string when it's no longer needed.
225    ///
226    /// Parameter `promptSelector`: A pointer to a SecKeychainPromptSelector.  On return, this points to the SecKeychainPromptSelector for the given access control list entry.
227    ///
228    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
229    ///
230    /// # Safety
231    ///
232    /// - `application_list` must be a valid pointer.
233    /// - `description` must be a valid pointer.
234    /// - `prompt_selector` must be a valid pointer.
235    #[doc(alias = "SecACLCopyContents")]
236    #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
237    #[deprecated = "SecKeychain is deprecated"]
238    #[inline]
239    pub unsafe fn copy_contents(
240        &self,
241        application_list: NonNull<*const CFArray>,
242        description: NonNull<*const CFString>,
243        prompt_selector: NonNull<SecKeychainPromptSelector>,
244    ) -> OSStatus {
245        extern "C-unwind" {
246            fn SecACLCopyContents(
247                acl: &SecACL,
248                application_list: NonNull<*const CFArray>,
249                description: NonNull<*const CFString>,
250                prompt_selector: NonNull<SecKeychainPromptSelector>,
251            ) -> OSStatus;
252        }
253        unsafe { SecACLCopyContents(self, application_list, description, prompt_selector) }
254    }
255
256    /// Sets the application list, description, and CSSM prompt selector for a given access control list entry.
257    ///
258    /// Parameter `acl`: A reference to the access control list entry to edit.
259    ///
260    /// Parameter `applicationList`: An application list reference.
261    ///
262    /// Parameter `description`: The human readable name that will be used to refer to this item when the user is prompted.
263    ///
264    /// Parameter `promptSelector`: A pointer to a CSSM prompt selector.
265    ///
266    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
267    ///
268    /// This function is deprecated in 10.7 and later;
269    /// use SecACLSetContents instead.
270    ///
271    /// # Safety
272    ///
273    /// - `application_list` generic must be of the correct type.
274    /// - `prompt_selector` must be a valid pointer.
275    #[doc(alias = "SecACLSetSimpleContents")]
276    #[cfg(all(feature = "SecBase", feature = "cssmapple", feature = "cssmconfig"))]
277    #[deprecated = "CSSM is not supported"]
278    #[inline]
279    pub unsafe fn set_simple_contents(
280        &self,
281        application_list: Option<&CFArray>,
282        description: &CFString,
283        prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
284    ) -> OSStatus {
285        extern "C-unwind" {
286            fn SecACLSetSimpleContents(
287                acl: &SecACL,
288                application_list: Option<&CFArray>,
289                description: &CFString,
290                prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
291            ) -> OSStatus;
292        }
293        unsafe { SecACLSetSimpleContents(self, application_list, description, prompt_selector) }
294    }
295
296    /// Sets the application list, description, and prompt selector for a given access control list entry.
297    ///
298    /// Parameter `acl`: A reference to the access control list entry to edit.
299    ///
300    /// Parameter `applicationList`: An application list reference.
301    ///
302    /// Parameter `description`: The human readable name that will be used to refer to this item when the user is prompted.
303    ///
304    /// Parameter `promptSelector`: A SecKeychainPromptSelector selector.
305    ///
306    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
307    ///
308    /// # Safety
309    ///
310    /// `application_list` generic must be of the correct type.
311    #[doc(alias = "SecACLSetContents")]
312    #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
313    #[deprecated = "SecKeychain is deprecated"]
314    #[inline]
315    pub unsafe fn set_contents(
316        &self,
317        application_list: Option<&CFArray>,
318        description: &CFString,
319        prompt_selector: SecKeychainPromptSelector,
320    ) -> OSStatus {
321        extern "C-unwind" {
322            fn SecACLSetContents(
323                acl: &SecACL,
324                application_list: Option<&CFArray>,
325                description: &CFString,
326                prompt_selector: SecKeychainPromptSelector,
327            ) -> OSStatus;
328        }
329        unsafe { SecACLSetContents(self, application_list, description, prompt_selector) }
330    }
331
332    /// Retrieve the CSSM authorization tags of a given access control list entry.
333    ///
334    /// Parameter `acl`: An access control list entry reference.
335    ///
336    /// Parameter `tags`: On return, this points to the first item in an array of CSSM authorization tags.
337    ///
338    /// Parameter `tagCount`: On return, this points to the number of tags in the CSSM authorization tag array.
339    ///
340    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
341    ///
342    /// This function is deprecated in 10.7 and later;
343    /// use SecACLCopyAuthorizations instead.
344    ///
345    /// # Safety
346    ///
347    /// - `tags` must be a valid pointer.
348    /// - `tag_count` must be a valid pointer.
349    #[doc(alias = "SecACLGetAuthorizations")]
350    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
351    #[deprecated = "CSSM is not supported"]
352    #[inline]
353    pub unsafe fn get_authorizations(
354        &self,
355        tags: NonNull<CSSM_ACL_AUTHORIZATION_TAG>,
356        tag_count: NonNull<uint32>,
357    ) -> OSStatus {
358        extern "C-unwind" {
359            fn SecACLGetAuthorizations(
360                acl: &SecACL,
361                tags: NonNull<CSSM_ACL_AUTHORIZATION_TAG>,
362                tag_count: NonNull<uint32>,
363            ) -> OSStatus;
364        }
365        unsafe { SecACLGetAuthorizations(self, tags, tag_count) }
366    }
367
368    /// Retrieve the authorization tags of a given access control list entry.
369    ///
370    /// Parameter `acl`: An access control list entry reference.
371    ///
372    /// Returns: On return, a CFArrayRef of the authorizations for this ACL.
373    #[doc(alias = "SecACLCopyAuthorizations")]
374    #[cfg(feature = "SecBase")]
375    #[deprecated = "SecKeychain is deprecated"]
376    #[inline]
377    pub unsafe fn authorizations(&self) -> CFRetained<CFArray> {
378        extern "C-unwind" {
379            fn SecACLCopyAuthorizations(acl: &SecACL) -> Option<NonNull<CFArray>>;
380        }
381        let ret = unsafe { SecACLCopyAuthorizations(self) };
382        let ret =
383            ret.expect("function was marked as returning non-null, but actually returned NULL");
384        unsafe { CFRetained::from_raw(ret) }
385    }
386
387    /// Sets the CSSM authorization tags of a given access control list entry.
388    ///
389    /// Parameter `acl`: An access control list entry reference.
390    ///
391    /// Parameter `tags`: A pointer to the first item in an array of CSSM authorization tags.
392    ///
393    /// Parameter `tagCount`: The number of tags in the CSSM authorization tag array.
394    ///
395    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
396    ///
397    /// This function is deprecated in 10.7 and later;
398    /// use SecACLUpdateAuthorizations instead.
399    ///
400    /// # Safety
401    ///
402    /// `tags` must be a valid pointer.
403    #[doc(alias = "SecACLSetAuthorizations")]
404    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
405    #[deprecated = "CSSM is not supported"]
406    #[inline]
407    pub unsafe fn set_authorizations(
408        &self,
409        tags: NonNull<CSSM_ACL_AUTHORIZATION_TAG>,
410        tag_count: uint32,
411    ) -> OSStatus {
412        extern "C-unwind" {
413            fn SecACLSetAuthorizations(
414                acl: &SecACL,
415                tags: NonNull<CSSM_ACL_AUTHORIZATION_TAG>,
416                tag_count: uint32,
417            ) -> OSStatus;
418        }
419        unsafe { SecACLSetAuthorizations(self, tags, tag_count) }
420    }
421
422    /// Sets the authorization tags of a given access control list entry.
423    ///
424    /// Parameter `acl`: An access control list entry reference.
425    ///
426    /// Parameter `authorizations`: A pointer to an array of authorization tags.
427    ///
428    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
429    ///
430    /// # Safety
431    ///
432    /// `authorizations` generic must be of the correct type.
433    #[doc(alias = "SecACLUpdateAuthorizations")]
434    #[cfg(feature = "SecBase")]
435    #[deprecated = "SecKeychain is deprecated"]
436    #[inline]
437    pub unsafe fn update_authorizations(&self, authorizations: &CFArray) -> OSStatus {
438        extern "C-unwind" {
439            fn SecACLUpdateAuthorizations(acl: &SecACL, authorizations: &CFArray) -> OSStatus;
440        }
441        unsafe { SecACLUpdateAuthorizations(self, authorizations) }
442    }
443}
444
445extern "C-unwind" {
446    #[cfg(all(feature = "SecBase", feature = "cssmapple", feature = "cssmconfig"))]
447    #[deprecated = "renamed to `SecACL::create_from_simple_contents`"]
448    pub fn SecACLCreateFromSimpleContents(
449        access: &SecAccess,
450        application_list: Option<&CFArray>,
451        description: &CFString,
452        prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
453        new_acl: NonNull<*mut SecACL>,
454    ) -> OSStatus;
455}
456
457extern "C-unwind" {
458    #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
459    #[deprecated = "renamed to `SecACL::create_with_simple_contents`"]
460    pub fn SecACLCreateWithSimpleContents(
461        access: &SecAccess,
462        application_list: Option<&CFArray>,
463        description: &CFString,
464        prompt_selector: SecKeychainPromptSelector,
465        new_acl: NonNull<*mut SecACL>,
466    ) -> OSStatus;
467}
468
469extern "C-unwind" {
470    #[cfg(feature = "SecBase")]
471    #[deprecated = "renamed to `SecACL::remove`"]
472    pub fn SecACLRemove(acl_ref: &SecACL) -> OSStatus;
473}
474
475extern "C-unwind" {
476    #[cfg(all(feature = "SecBase", feature = "cssmapple", feature = "cssmconfig"))]
477    #[deprecated = "renamed to `SecACL::copy_simple_contents`"]
478    pub fn SecACLCopySimpleContents(
479        acl: &SecACL,
480        application_list: NonNull<*const CFArray>,
481        description: NonNull<*const CFString>,
482        prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
483    ) -> OSStatus;
484}
485
486extern "C-unwind" {
487    #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
488    #[deprecated = "renamed to `SecACL::copy_contents`"]
489    pub fn SecACLCopyContents(
490        acl: &SecACL,
491        application_list: NonNull<*const CFArray>,
492        description: NonNull<*const CFString>,
493        prompt_selector: NonNull<SecKeychainPromptSelector>,
494    ) -> OSStatus;
495}
496
497extern "C-unwind" {
498    #[cfg(all(feature = "SecBase", feature = "cssmapple", feature = "cssmconfig"))]
499    #[deprecated = "renamed to `SecACL::set_simple_contents`"]
500    pub fn SecACLSetSimpleContents(
501        acl: &SecACL,
502        application_list: Option<&CFArray>,
503        description: &CFString,
504        prompt_selector: NonNull<CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR>,
505    ) -> OSStatus;
506}
507
508extern "C-unwind" {
509    #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
510    #[deprecated = "renamed to `SecACL::set_contents`"]
511    pub fn SecACLSetContents(
512        acl: &SecACL,
513        application_list: Option<&CFArray>,
514        description: &CFString,
515        prompt_selector: SecKeychainPromptSelector,
516    ) -> OSStatus;
517}
518
519extern "C-unwind" {
520    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
521    #[deprecated = "renamed to `SecACL::get_authorizations`"]
522    pub fn SecACLGetAuthorizations(
523        acl: &SecACL,
524        tags: NonNull<CSSM_ACL_AUTHORIZATION_TAG>,
525        tag_count: NonNull<uint32>,
526    ) -> OSStatus;
527}
528
529#[cfg(feature = "SecBase")]
530#[deprecated = "renamed to `SecACL::authorizations`"]
531#[inline]
532pub unsafe extern "C-unwind" fn SecACLCopyAuthorizations(acl: &SecACL) -> CFRetained<CFArray> {
533    extern "C-unwind" {
534        fn SecACLCopyAuthorizations(acl: &SecACL) -> Option<NonNull<CFArray>>;
535    }
536    let ret = unsafe { SecACLCopyAuthorizations(acl) };
537    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
538    unsafe { CFRetained::from_raw(ret) }
539}
540
541extern "C-unwind" {
542    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
543    #[deprecated = "renamed to `SecACL::set_authorizations`"]
544    pub fn SecACLSetAuthorizations(
545        acl: &SecACL,
546        tags: NonNull<CSSM_ACL_AUTHORIZATION_TAG>,
547        tag_count: uint32,
548    ) -> OSStatus;
549}
550
551extern "C-unwind" {
552    #[cfg(feature = "SecBase")]
553    #[deprecated = "renamed to `SecACL::update_authorizations`"]
554    pub fn SecACLUpdateAuthorizations(acl: &SecACL, authorizations: &CFArray) -> OSStatus;
555}