objc2_security/generated/SecAccess.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2_core_foundation::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/security/secaccessownertype?language=objc)
10pub type SecAccessOwnerType = u32;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecuseonlyuid?language=objc)
13pub const kSecUseOnlyUID: c_uint = 1;
14/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecuseonlygid?language=objc)
15pub const kSecUseOnlyGID: c_uint = 2;
16/// [Apple's documentation](https://developer.apple.com/documentation/security/ksechonorroot?language=objc)
17pub const kSecHonorRoot: c_uint = 256;
18/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecmatchbits?language=objc)
19pub const kSecMatchBits: c_uint = 3;
20
21extern "C" {
22 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationany?language=objc)
23 pub static kSecACLAuthorizationAny: &'static CFString;
24}
25
26extern "C" {
27 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationlogin?language=objc)
28 pub static kSecACLAuthorizationLogin: &'static CFString;
29}
30
31extern "C" {
32 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationgenkey?language=objc)
33 pub static kSecACLAuthorizationGenKey: &'static CFString;
34}
35
36extern "C" {
37 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationdelete?language=objc)
38 pub static kSecACLAuthorizationDelete: &'static CFString;
39}
40
41extern "C" {
42 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationexportwrapped?language=objc)
43 pub static kSecACLAuthorizationExportWrapped: &'static CFString;
44}
45
46extern "C" {
47 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationexportclear?language=objc)
48 pub static kSecACLAuthorizationExportClear: &'static CFString;
49}
50
51extern "C" {
52 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationimportwrapped?language=objc)
53 pub static kSecACLAuthorizationImportWrapped: &'static CFString;
54}
55
56extern "C" {
57 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationimportclear?language=objc)
58 pub static kSecACLAuthorizationImportClear: &'static CFString;
59}
60
61extern "C" {
62 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationsign?language=objc)
63 pub static kSecACLAuthorizationSign: &'static CFString;
64}
65
66extern "C" {
67 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationencrypt?language=objc)
68 pub static kSecACLAuthorizationEncrypt: &'static CFString;
69}
70
71extern "C" {
72 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationdecrypt?language=objc)
73 pub static kSecACLAuthorizationDecrypt: &'static CFString;
74}
75
76extern "C" {
77 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationmac?language=objc)
78 pub static kSecACLAuthorizationMAC: &'static CFString;
79}
80
81extern "C" {
82 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationderive?language=objc)
83 pub static kSecACLAuthorizationDerive: &'static CFString;
84}
85
86extern "C" {
87 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationkeychaincreate?language=objc)
88 pub static kSecACLAuthorizationKeychainCreate: &'static CFString;
89}
90
91extern "C" {
92 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationkeychaindelete?language=objc)
93 pub static kSecACLAuthorizationKeychainDelete: &'static CFString;
94}
95
96extern "C" {
97 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationkeychainitemread?language=objc)
98 pub static kSecACLAuthorizationKeychainItemRead: &'static CFString;
99}
100
101extern "C" {
102 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationkeychainiteminsert?language=objc)
103 pub static kSecACLAuthorizationKeychainItemInsert: &'static CFString;
104}
105
106extern "C" {
107 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationkeychainitemmodify?language=objc)
108 pub static kSecACLAuthorizationKeychainItemModify: &'static CFString;
109}
110
111extern "C" {
112 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationkeychainitemdelete?language=objc)
113 pub static kSecACLAuthorizationKeychainItemDelete: &'static CFString;
114}
115
116extern "C" {
117 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationchangeacl?language=objc)
118 pub static kSecACLAuthorizationChangeACL: &'static CFString;
119}
120
121extern "C" {
122 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationchangeowner?language=objc)
123 pub static kSecACLAuthorizationChangeOwner: &'static CFString;
124}
125
126extern "C" {
127 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationpartitionid?language=objc)
128 pub static kSecACLAuthorizationPartitionID: &'static CFString;
129}
130
131extern "C" {
132 /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecaclauthorizationintegrity?language=objc)
133 pub static kSecACLAuthorizationIntegrity: &'static CFString;
134}
135
136#[cfg(feature = "SecBase")]
137unsafe impl ConcreteType for SecAccess {
138 /// Returns the type identifier of SecAccess instances.
139 ///
140 /// Returns: The CFTypeID of SecAccess instances.
141 #[doc(alias = "SecAccessGetTypeID")]
142 #[inline]
143 fn type_id() -> CFTypeID {
144 extern "C-unwind" {
145 fn SecAccessGetTypeID() -> CFTypeID;
146 }
147 unsafe { SecAccessGetTypeID() }
148 }
149}
150
151#[cfg(feature = "SecBase")]
152impl SecAccess {
153 /// Creates a new SecAccessRef that is set to the currently designated system default
154 /// configuration of a (newly created) security object. Note that the precise nature of
155 /// this default may change between releases.
156 ///
157 /// Parameter `descriptor`: The name of the item as it should appear in security dialogs
158 ///
159 /// Parameter `trustedlist`: A CFArray of TrustedApplicationRefs, specifying which applications
160 /// should be allowed to access an item without triggering confirmation dialogs.
161 /// If NULL, defaults to (just) the application creating the item. To set no applications,
162 /// pass a CFArray with no elements.
163 ///
164 /// Parameter `accessRef`: On return, a pointer to the new access reference.
165 ///
166 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
167 ///
168 /// # Safety
169 ///
170 /// - `trustedlist` generic must be of the correct type.
171 /// - `access_ref` must be a valid pointer.
172 #[doc(alias = "SecAccessCreate")]
173 #[cfg(feature = "SecBase")]
174 #[deprecated = "SecKeychain is deprecated"]
175 #[inline]
176 pub unsafe fn create(
177 descriptor: &CFString,
178 trustedlist: Option<&CFArray>,
179 access_ref: NonNull<*mut SecAccess>,
180 ) -> OSStatus {
181 extern "C-unwind" {
182 fn SecAccessCreate(
183 descriptor: &CFString,
184 trustedlist: Option<&CFArray>,
185 access_ref: NonNull<*mut SecAccess>,
186 ) -> OSStatus;
187 }
188 unsafe { SecAccessCreate(descriptor, trustedlist, access_ref) }
189 }
190
191 /// Creates a new SecAccessRef using the owner and access control list you provide.
192 ///
193 /// Parameter `owner`: A pointer to a CSSM access control list owner.
194 ///
195 /// Parameter `aclCount`: An unsigned 32-bit integer representing the number of items in the access control list.
196 ///
197 /// Parameter `acls`: A pointer to the access control list.
198 ///
199 /// Parameter `accessRef`: On return, a pointer to the new access reference.
200 ///
201 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
202 ///
203 /// For 10.7 and later please use the SecAccessCreateWithOwnerAndACL API
204 ///
205 /// # Safety
206 ///
207 /// - `owner` must be a valid pointer.
208 /// - `acls` must be a valid pointer.
209 /// - `access_ref` must be a valid pointer.
210 #[doc(alias = "SecAccessCreateFromOwnerAndACL")]
211 #[cfg(all(
212 feature = "SecAsn1Types",
213 feature = "SecBase",
214 feature = "cssmconfig",
215 feature = "cssmtype"
216 ))]
217 #[deprecated = "CSSM is not supported"]
218 #[inline]
219 pub unsafe fn create_from_owner_and_acl(
220 owner: NonNull<CSSM_ACL_OWNER_PROTOTYPE>,
221 acl_count: uint32,
222 acls: NonNull<CSSM_ACL_ENTRY_INFO>,
223 access_ref: NonNull<*mut SecAccess>,
224 ) -> OSStatus {
225 extern "C-unwind" {
226 fn SecAccessCreateFromOwnerAndACL(
227 owner: NonNull<CSSM_ACL_OWNER_PROTOTYPE>,
228 acl_count: uint32,
229 acls: NonNull<CSSM_ACL_ENTRY_INFO>,
230 access_ref: NonNull<*mut SecAccess>,
231 ) -> OSStatus;
232 }
233 unsafe { SecAccessCreateFromOwnerAndACL(owner, acl_count, acls, access_ref) }
234 }
235
236 /// Creates a new SecAccessRef using either for a user or a group with a list of ACLs
237 ///
238 /// Parameter `userId`: An user id that specifies the user to associate with this SecAccessRef.
239 ///
240 /// Parameter `groupId`: A group id that specifies the group to associate with this SecAccessRef.
241 ///
242 /// Parameter `ownerType`: Specifies the how the ownership of the new SecAccessRef is defined.
243 ///
244 /// Parameter `acls`: A CFArrayRef of the ACLs to associate with this SecAccessRef
245 ///
246 /// Parameter `error`: Optionally a pointer to a CFErrorRef to return any errors with may have occured
247 ///
248 /// Returns: A pointer to the new access reference.
249 ///
250 /// # Safety
251 ///
252 /// - `acls` generic must be of the correct type.
253 /// - `error` must be a valid pointer or null.
254 #[doc(alias = "SecAccessCreateWithOwnerAndACL")]
255 #[cfg(all(feature = "SecBase", feature = "libc"))]
256 #[deprecated = "SecKeychain is deprecated"]
257 #[inline]
258 pub unsafe fn with_owner_and_acl(
259 user_id: libc::uid_t,
260 group_id: libc::gid_t,
261 owner_type: SecAccessOwnerType,
262 acls: Option<&CFArray>,
263 error: *mut *mut CFError,
264 ) -> Option<CFRetained<SecAccess>> {
265 extern "C-unwind" {
266 fn SecAccessCreateWithOwnerAndACL(
267 user_id: libc::uid_t,
268 group_id: libc::gid_t,
269 owner_type: SecAccessOwnerType,
270 acls: Option<&CFArray>,
271 error: *mut *mut CFError,
272 ) -> Option<NonNull<SecAccess>>;
273 }
274 let ret =
275 unsafe { SecAccessCreateWithOwnerAndACL(user_id, group_id, owner_type, acls, error) };
276 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
277 }
278
279 /// Retrieves the owner and the access control list of a given access.
280 ///
281 /// Parameter `accessRef`: A reference to the access from which to retrieve the information.
282 ///
283 /// Parameter `owner`: On return, a pointer to the access control list owner.
284 ///
285 /// Parameter `aclCount`: On return, a pointer to an unsigned 32-bit integer representing the number of items in the access control list.
286 ///
287 /// Parameter `acls`: On return, a pointer to the access control list.
288 ///
289 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
290 ///
291 /// For 10.7 and later please use the SecAccessCopyOwnerAndACL API
292 ///
293 /// # Safety
294 ///
295 /// - `owner` must be a valid pointer.
296 /// - `acl_count` must be a valid pointer.
297 /// - `acls` must be a valid pointer.
298 #[doc(alias = "SecAccessGetOwnerAndACL")]
299 #[cfg(all(
300 feature = "SecAsn1Types",
301 feature = "SecBase",
302 feature = "cssmconfig",
303 feature = "cssmtype"
304 ))]
305 #[deprecated = "CSSM is not supported"]
306 #[inline]
307 pub unsafe fn get_owner_and_acl(
308 &self,
309 owner: NonNull<CSSM_ACL_OWNER_PROTOTYPE_PTR>,
310 acl_count: NonNull<uint32>,
311 acls: NonNull<CSSM_ACL_ENTRY_INFO_PTR>,
312 ) -> OSStatus {
313 extern "C-unwind" {
314 fn SecAccessGetOwnerAndACL(
315 access_ref: &SecAccess,
316 owner: NonNull<CSSM_ACL_OWNER_PROTOTYPE_PTR>,
317 acl_count: NonNull<uint32>,
318 acls: NonNull<CSSM_ACL_ENTRY_INFO_PTR>,
319 ) -> OSStatus;
320 }
321 unsafe { SecAccessGetOwnerAndACL(self, owner, acl_count, acls) }
322 }
323
324 /// Retrieves the owner and the access control list of a given access.
325 ///
326 /// Parameter `accessRef`: A reference to the access from which to retrieve the information.
327 ///
328 /// Parameter `userId`: On return, the user id of the owner
329 ///
330 /// Parameter `groupId`: On return, the group id of the owner
331 ///
332 /// Parameter `ownerType`: On return, the type of owner for this AccessRef
333 ///
334 /// Parameter `aclList`: On return, a pointer to a new created CFArray of SecACL instances. The caller is responsible for calling CFRelease on this array.
335 ///
336 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
337 ///
338 /// # Safety
339 ///
340 /// - `user_id` must be a valid pointer or null.
341 /// - `group_id` must be a valid pointer or null.
342 /// - `owner_type` must be a valid pointer or null.
343 /// - `acl_list` must be a valid pointer or null.
344 #[doc(alias = "SecAccessCopyOwnerAndACL")]
345 #[cfg(all(feature = "SecBase", feature = "libc"))]
346 #[deprecated = "SecKeychain is deprecated"]
347 #[inline]
348 pub unsafe fn copy_owner_and_acl(
349 &self,
350 user_id: *mut libc::uid_t,
351 group_id: *mut libc::gid_t,
352 owner_type: *mut SecAccessOwnerType,
353 acl_list: *mut *const CFArray,
354 ) -> OSStatus {
355 extern "C-unwind" {
356 fn SecAccessCopyOwnerAndACL(
357 access_ref: &SecAccess,
358 user_id: *mut libc::uid_t,
359 group_id: *mut libc::gid_t,
360 owner_type: *mut SecAccessOwnerType,
361 acl_list: *mut *const CFArray,
362 ) -> OSStatus;
363 }
364 unsafe { SecAccessCopyOwnerAndACL(self, user_id, group_id, owner_type, acl_list) }
365 }
366
367 /// Copies all the access control lists of a given access.
368 ///
369 /// Parameter `accessRef`: A reference to the access from which to retrieve the information.
370 ///
371 /// Parameter `aclList`: On return, a pointer to a new created CFArray of SecACL instances. The caller is responsible for calling CFRelease on this array.
372 ///
373 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
374 ///
375 /// # Safety
376 ///
377 /// `acl_list` must be a valid pointer.
378 #[doc(alias = "SecAccessCopyACLList")]
379 #[cfg(feature = "SecBase")]
380 #[deprecated = "SecKeychain is deprecated"]
381 #[inline]
382 pub unsafe fn copy_acl_list(&self, acl_list: NonNull<*const CFArray>) -> OSStatus {
383 extern "C-unwind" {
384 fn SecAccessCopyACLList(
385 access_ref: &SecAccess,
386 acl_list: NonNull<*const CFArray>,
387 ) -> OSStatus;
388 }
389 unsafe { SecAccessCopyACLList(self, acl_list) }
390 }
391
392 /// Copies selected access control lists from a given access.
393 ///
394 /// Parameter `accessRef`: A reference to the access from which to retrieve the information.
395 ///
396 /// Parameter `action`: An authorization tag specifying what action with which to select the action control lists.
397 ///
398 /// Parameter `aclList`: On return, a pointer to the selected access control lists.
399 ///
400 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
401 ///
402 /// For 10.7 and later please use the SecAccessCopyMatchingACLList API
403 ///
404 /// # Safety
405 ///
406 /// `acl_list` must be a valid pointer.
407 #[doc(alias = "SecAccessCopySelectedACLList")]
408 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
409 #[deprecated = "CSSM is not supported"]
410 #[inline]
411 pub unsafe fn copy_selected_acl_list(
412 &self,
413 action: CSSM_ACL_AUTHORIZATION_TAG,
414 acl_list: NonNull<*const CFArray>,
415 ) -> OSStatus {
416 extern "C-unwind" {
417 fn SecAccessCopySelectedACLList(
418 access_ref: &SecAccess,
419 action: CSSM_ACL_AUTHORIZATION_TAG,
420 acl_list: NonNull<*const CFArray>,
421 ) -> OSStatus;
422 }
423 unsafe { SecAccessCopySelectedACLList(self, action, acl_list) }
424 }
425
426 /// Copies selected access control lists from a given access.
427 ///
428 /// Parameter `accessRef`: A reference to the access from which to retrieve the information.
429 ///
430 /// Parameter `authorizationTag`: An authorization tag specifying what action with which to select the action control lists.
431 ///
432 /// Returns: A pointer to the selected access control lists.
433 ///
434 /// # Safety
435 ///
436 /// `authorization_tag` should be of the correct type.
437 #[doc(alias = "SecAccessCopyMatchingACLList")]
438 #[cfg(feature = "SecBase")]
439 #[deprecated = "SecKeychain is deprecated"]
440 #[inline]
441 pub unsafe fn matching_acl_list(
442 &self,
443 authorization_tag: &CFType,
444 ) -> Option<CFRetained<CFArray>> {
445 extern "C-unwind" {
446 fn SecAccessCopyMatchingACLList(
447 access_ref: &SecAccess,
448 authorization_tag: &CFType,
449 ) -> Option<NonNull<CFArray>>;
450 }
451 let ret = unsafe { SecAccessCopyMatchingACLList(self, authorization_tag) };
452 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
453 }
454}
455
456extern "C-unwind" {
457 #[cfg(feature = "SecBase")]
458 #[deprecated = "renamed to `SecAccess::create`"]
459 pub fn SecAccessCreate(
460 descriptor: &CFString,
461 trustedlist: Option<&CFArray>,
462 access_ref: NonNull<*mut SecAccess>,
463 ) -> OSStatus;
464}
465
466extern "C-unwind" {
467 #[cfg(all(
468 feature = "SecAsn1Types",
469 feature = "SecBase",
470 feature = "cssmconfig",
471 feature = "cssmtype"
472 ))]
473 #[deprecated = "renamed to `SecAccess::create_from_owner_and_acl`"]
474 pub fn SecAccessCreateFromOwnerAndACL(
475 owner: NonNull<CSSM_ACL_OWNER_PROTOTYPE>,
476 acl_count: uint32,
477 acls: NonNull<CSSM_ACL_ENTRY_INFO>,
478 access_ref: NonNull<*mut SecAccess>,
479 ) -> OSStatus;
480}
481
482#[cfg(all(feature = "SecBase", feature = "libc"))]
483#[deprecated = "renamed to `SecAccess::with_owner_and_acl`"]
484#[inline]
485pub unsafe extern "C-unwind" fn SecAccessCreateWithOwnerAndACL(
486 user_id: libc::uid_t,
487 group_id: libc::gid_t,
488 owner_type: SecAccessOwnerType,
489 acls: Option<&CFArray>,
490 error: *mut *mut CFError,
491) -> Option<CFRetained<SecAccess>> {
492 extern "C-unwind" {
493 fn SecAccessCreateWithOwnerAndACL(
494 user_id: libc::uid_t,
495 group_id: libc::gid_t,
496 owner_type: SecAccessOwnerType,
497 acls: Option<&CFArray>,
498 error: *mut *mut CFError,
499 ) -> Option<NonNull<SecAccess>>;
500 }
501 let ret = unsafe { SecAccessCreateWithOwnerAndACL(user_id, group_id, owner_type, acls, error) };
502 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
503}
504
505extern "C-unwind" {
506 #[cfg(all(
507 feature = "SecAsn1Types",
508 feature = "SecBase",
509 feature = "cssmconfig",
510 feature = "cssmtype"
511 ))]
512 #[deprecated = "renamed to `SecAccess::get_owner_and_acl`"]
513 pub fn SecAccessGetOwnerAndACL(
514 access_ref: &SecAccess,
515 owner: NonNull<CSSM_ACL_OWNER_PROTOTYPE_PTR>,
516 acl_count: NonNull<uint32>,
517 acls: NonNull<CSSM_ACL_ENTRY_INFO_PTR>,
518 ) -> OSStatus;
519}
520
521extern "C-unwind" {
522 #[cfg(all(feature = "SecBase", feature = "libc"))]
523 #[deprecated = "renamed to `SecAccess::copy_owner_and_acl`"]
524 pub fn SecAccessCopyOwnerAndACL(
525 access_ref: &SecAccess,
526 user_id: *mut libc::uid_t,
527 group_id: *mut libc::gid_t,
528 owner_type: *mut SecAccessOwnerType,
529 acl_list: *mut *const CFArray,
530 ) -> OSStatus;
531}
532
533extern "C-unwind" {
534 #[cfg(feature = "SecBase")]
535 #[deprecated = "renamed to `SecAccess::copy_acl_list`"]
536 pub fn SecAccessCopyACLList(
537 access_ref: &SecAccess,
538 acl_list: NonNull<*const CFArray>,
539 ) -> OSStatus;
540}
541
542extern "C-unwind" {
543 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
544 #[deprecated = "renamed to `SecAccess::copy_selected_acl_list`"]
545 pub fn SecAccessCopySelectedACLList(
546 access_ref: &SecAccess,
547 action: CSSM_ACL_AUTHORIZATION_TAG,
548 acl_list: NonNull<*const CFArray>,
549 ) -> OSStatus;
550}
551
552#[cfg(feature = "SecBase")]
553#[deprecated = "renamed to `SecAccess::matching_acl_list`"]
554#[inline]
555pub unsafe extern "C-unwind" fn SecAccessCopyMatchingACLList(
556 access_ref: &SecAccess,
557 authorization_tag: &CFType,
558) -> Option<CFRetained<CFArray>> {
559 extern "C-unwind" {
560 fn SecAccessCopyMatchingACLList(
561 access_ref: &SecAccess,
562 authorization_tag: &CFType,
563 ) -> Option<NonNull<CFArray>>;
564 }
565 let ret = unsafe { SecAccessCopyMatchingACLList(access_ref, authorization_tag) };
566 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
567}