1use core::ptr::NonNull;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6use objc2_core_foundation::*;
7
8use crate::*;
9
10#[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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}