objc2_security/generated/
SecKeychainItem.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// Specifies a keychain item's class code.
12///
13///
14///
15/// Note: AppleShare passwords are no longer used by macOS, starting in Leopard (10.5). Use of this item class is deprecated in OS X 10.9 and later; kSecInternetPasswordItemClass should be used instead when storing or looking up passwords for an Apple Filing Protocol (AFP) server.
16///
17///
18///
19///
20///
21/// The SecItemClass enumeration defines constants your application can use to specify the type of the keychain item you wish to create, dispose, add, delete, update, copy, or locate. You can also use these constants with the tag constant SecItemAttr.
22///
23/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secitemclass?language=objc)
24// NS_ENUM
25#[repr(transparent)]
26#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
27pub struct SecItemClass(pub FourCharCode);
28impl SecItemClass {
29    #[doc(alias = "kSecInternetPasswordItemClass")]
30    pub const InternetPasswordItemClass: Self = Self(0x696e6574);
31    #[doc(alias = "kSecGenericPasswordItemClass")]
32    pub const GenericPasswordItemClass: Self = Self(0x67656e70);
33    #[doc(alias = "kSecAppleSharePasswordItemClass")]
34    #[deprecated]
35    pub const AppleSharePasswordItemClass: Self = Self(0x61736870);
36    #[doc(alias = "kSecCertificateItemClass")]
37    pub const CertificateItemClass: Self = Self(0x80001000);
38    #[doc(alias = "kSecPublicKeyItemClass")]
39    pub const PublicKeyItemClass: Self = Self(0x0000000F);
40    #[doc(alias = "kSecPrivateKeyItemClass")]
41    pub const PrivateKeyItemClass: Self = Self(0x00000010);
42    #[doc(alias = "kSecSymmetricKeyItemClass")]
43    pub const SymmetricKeyItemClass: Self = Self(0x00000011);
44}
45
46#[cfg(feature = "objc2")]
47unsafe impl Encode for SecItemClass {
48    const ENCODING: Encoding = FourCharCode::ENCODING;
49}
50
51#[cfg(feature = "objc2")]
52unsafe impl RefEncode for SecItemClass {
53    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
54}
55
56/// Specifies keychain item attributes.
57///
58///
59///
60///
61///
62///
63///
64///
65///
66///
67///
68///
69///
70///
71///
72///
73///
74///
75///
76///
77///
78///
79///
80///
81///
82///
83///
84///
85///
86/// To obtain information about a certificate, use the CDSA Certificate Library (CL) API. To obtain information about a key, use the SecKeyGetCSSMKey function and the CDSA Cryptographic Service Provider (CSP) API.
87///
88/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secitemattr?language=objc)
89// NS_ENUM
90#[repr(transparent)]
91#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
92pub struct SecItemAttr(pub FourCharCode);
93impl SecItemAttr {
94    #[doc(alias = "kSecCreationDateItemAttr")]
95    pub const CreationDateItemAttr: Self = Self(0x63646174);
96    #[doc(alias = "kSecModDateItemAttr")]
97    pub const ModDateItemAttr: Self = Self(0x6d646174);
98    #[doc(alias = "kSecDescriptionItemAttr")]
99    pub const DescriptionItemAttr: Self = Self(0x64657363);
100    #[doc(alias = "kSecCommentItemAttr")]
101    pub const CommentItemAttr: Self = Self(0x69636d74);
102    #[doc(alias = "kSecCreatorItemAttr")]
103    pub const CreatorItemAttr: Self = Self(0x63727472);
104    #[doc(alias = "kSecTypeItemAttr")]
105    pub const TypeItemAttr: Self = Self(0x74797065);
106    #[doc(alias = "kSecScriptCodeItemAttr")]
107    pub const ScriptCodeItemAttr: Self = Self(0x73637270);
108    #[doc(alias = "kSecLabelItemAttr")]
109    pub const LabelItemAttr: Self = Self(0x6c61626c);
110    #[doc(alias = "kSecInvisibleItemAttr")]
111    pub const InvisibleItemAttr: Self = Self(0x696e7669);
112    #[doc(alias = "kSecNegativeItemAttr")]
113    pub const NegativeItemAttr: Self = Self(0x6e656761);
114    #[doc(alias = "kSecCustomIconItemAttr")]
115    pub const CustomIconItemAttr: Self = Self(0x63757369);
116    #[doc(alias = "kSecAccountItemAttr")]
117    pub const AccountItemAttr: Self = Self(0x61636374);
118    #[doc(alias = "kSecServiceItemAttr")]
119    pub const ServiceItemAttr: Self = Self(0x73766365);
120    #[doc(alias = "kSecGenericItemAttr")]
121    pub const GenericItemAttr: Self = Self(0x67656e61);
122    #[doc(alias = "kSecSecurityDomainItemAttr")]
123    pub const SecurityDomainItemAttr: Self = Self(0x73646d6e);
124    #[doc(alias = "kSecServerItemAttr")]
125    pub const ServerItemAttr: Self = Self(0x73727672);
126    #[doc(alias = "kSecAuthenticationTypeItemAttr")]
127    pub const AuthenticationTypeItemAttr: Self = Self(0x61747970);
128    #[doc(alias = "kSecPortItemAttr")]
129    pub const PortItemAttr: Self = Self(0x706f7274);
130    #[doc(alias = "kSecPathItemAttr")]
131    pub const PathItemAttr: Self = Self(0x70617468);
132    #[doc(alias = "kSecVolumeItemAttr")]
133    pub const VolumeItemAttr: Self = Self(0x766c6d65);
134    #[doc(alias = "kSecAddressItemAttr")]
135    pub const AddressItemAttr: Self = Self(0x61646472);
136    #[doc(alias = "kSecSignatureItemAttr")]
137    pub const SignatureItemAttr: Self = Self(0x73736967);
138    #[doc(alias = "kSecProtocolItemAttr")]
139    pub const ProtocolItemAttr: Self = Self(0x7074636c);
140    #[doc(alias = "kSecCertificateType")]
141    pub const CertificateType: Self = Self(0x63747970);
142    #[doc(alias = "kSecCertificateEncoding")]
143    pub const CertificateEncoding: Self = Self(0x63656e63);
144    #[doc(alias = "kSecCrlType")]
145    pub const CrlType: Self = Self(0x63727470);
146    #[doc(alias = "kSecCrlEncoding")]
147    pub const CrlEncoding: Self = Self(0x63726e63);
148    #[doc(alias = "kSecAlias")]
149    pub const Alias: Self = Self(0x616c6973);
150}
151
152#[cfg(feature = "objc2")]
153unsafe impl Encode for SecItemAttr {
154    const ENCODING: Encoding = FourCharCode::ENCODING;
155}
156
157#[cfg(feature = "objc2")]
158unsafe impl RefEncode for SecItemAttr {
159    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
160}
161
162#[cfg(feature = "SecBase")]
163unsafe impl ConcreteType for SecKeychainItem {
164    /// Returns the type identifier of SecKeychainItem instances.
165    ///
166    /// Returns: The CFTypeID of SecKeychainItem instances.
167    #[doc(alias = "SecKeychainItemGetTypeID")]
168    #[inline]
169    fn type_id() -> CFTypeID {
170        extern "C-unwind" {
171            fn SecKeychainItemGetTypeID() -> CFTypeID;
172        }
173        unsafe { SecKeychainItemGetTypeID() }
174    }
175}
176
177#[cfg(feature = "SecBase")]
178impl SecKeychainItem {
179    /// Updates an existing keychain item after changing its attributes or data.
180    ///
181    /// Parameter `itemRef`: A reference to the keychain item to modify.
182    ///
183    /// Parameter `attrList`: The list of attributes to modify, along with their new values. Pass NULL if you don't need to modify any attributes.
184    ///
185    /// Parameter `length`: The length of the buffer pointed to by data.
186    ///
187    /// Parameter `data`: Pointer to a buffer containing the data to store. Pass NULL if you don't need to modify the data.
188    ///
189    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
190    ///
191    /// The keychain item is written to the keychain's permanent data store. If the keychain item has not previously been added to a keychain, a call to the SecKeychainItemModifyContent function does nothing and returns errSecSuccess.
192    ///
193    /// # Safety
194    ///
195    /// - `attr_list` must be a valid pointer or null.
196    /// - `data` must be a valid pointer or null.
197    #[doc(alias = "SecKeychainItemModifyAttributesAndData")]
198    #[cfg(feature = "SecBase")]
199    #[deprecated = "SecKeychain is deprecated"]
200    #[inline]
201    pub unsafe fn modify_attributes_and_data(
202        &self,
203        attr_list: *const SecKeychainAttributeList,
204        length: u32,
205        data: *const c_void,
206    ) -> OSStatus {
207        extern "C-unwind" {
208            fn SecKeychainItemModifyAttributesAndData(
209                item_ref: &SecKeychainItem,
210                attr_list: *const SecKeychainAttributeList,
211                length: u32,
212                data: *const c_void,
213            ) -> OSStatus;
214        }
215        unsafe { SecKeychainItemModifyAttributesAndData(self, attr_list, length, data) }
216    }
217
218    /// Creates a new keychain item from the supplied parameters.
219    ///
220    /// Parameter `itemClass`: A constant identifying the class of item to create.
221    ///
222    /// Parameter `attrList`: The list of attributes of the item to create.
223    ///
224    /// Parameter `length`: The length of the buffer pointed to by data.
225    ///
226    /// Parameter `data`: A pointer to a buffer containing the data to store.
227    ///
228    /// Parameter `initialAccess`: A reference to the access for this keychain item.
229    ///
230    /// Parameter `keychainRef`: A reference to the keychain in which to add the item.
231    ///
232    /// Parameter `itemRef`: On return, a pointer to a reference to the newly created keychain item (optional). When the item reference is no longer required, call CFRelease to deallocate memory occupied by the item.
233    ///
234    /// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if not enough valid parameters are supplied, or errSecAllocate (-108) if there is not enough memory in the current heap zone to create the object.
235    ///
236    /// # Safety
237    ///
238    /// - `attr_list` must be a valid pointer.
239    /// - `data` must be a valid pointer or null.
240    /// - `item_ref` must be a valid pointer or null.
241    #[doc(alias = "SecKeychainItemCreateFromContent")]
242    #[cfg(feature = "SecBase")]
243    #[deprecated = "SecKeychain is deprecated"]
244    #[inline]
245    pub unsafe fn create_from_content(
246        item_class: SecItemClass,
247        attr_list: NonNull<SecKeychainAttributeList>,
248        length: u32,
249        data: *const c_void,
250        keychain_ref: Option<&SecKeychain>,
251        initial_access: Option<&SecAccess>,
252        item_ref: *mut *mut SecKeychainItem,
253    ) -> OSStatus {
254        extern "C-unwind" {
255            fn SecKeychainItemCreateFromContent(
256                item_class: SecItemClass,
257                attr_list: NonNull<SecKeychainAttributeList>,
258                length: u32,
259                data: *const c_void,
260                keychain_ref: Option<&SecKeychain>,
261                initial_access: Option<&SecAccess>,
262                item_ref: *mut *mut SecKeychainItem,
263            ) -> OSStatus;
264        }
265        unsafe {
266            SecKeychainItemCreateFromContent(
267                item_class,
268                attr_list,
269                length,
270                data,
271                keychain_ref,
272                initial_access,
273                item_ref,
274            )
275        }
276    }
277
278    /// Updates an existing keychain item after changing its attributes or data. This call should only be used in conjunction with SecKeychainItemCopyContent().
279    ///
280    /// Parameter `itemRef`: A reference to the keychain item to modify.
281    ///
282    /// Parameter `attrList`: The list of attributes to modify, along with their new values. Pass NULL if you don't need to modify any attributes.
283    ///
284    /// Parameter `length`: The length of the buffer pointed to by data.
285    ///
286    /// Parameter `data`: A pointer to a buffer containing the data to store. Pass NULL if you don't need to modify the data.
287    ///
288    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
289    ///
290    /// # Safety
291    ///
292    /// - `attr_list` must be a valid pointer or null.
293    /// - `data` must be a valid pointer or null.
294    #[doc(alias = "SecKeychainItemModifyContent")]
295    #[cfg(feature = "SecBase")]
296    #[deprecated = "SecKeychain is deprecated"]
297    #[inline]
298    pub unsafe fn modify_content(
299        &self,
300        attr_list: *const SecKeychainAttributeList,
301        length: u32,
302        data: *const c_void,
303    ) -> OSStatus {
304        extern "C-unwind" {
305            fn SecKeychainItemModifyContent(
306                item_ref: &SecKeychainItem,
307                attr_list: *const SecKeychainAttributeList,
308                length: u32,
309                data: *const c_void,
310            ) -> OSStatus;
311        }
312        unsafe { SecKeychainItemModifyContent(self, attr_list, length, data) }
313    }
314
315    /// Copies the data and/or attributes stored in the given keychain item. It is recommended that you use SecKeychainItemCopyAttributesAndData(). You must call SecKeychainItemFreeContent when you no longer need the attributes and data. If you want to modify the attributes returned here, use SecKeychainModifyContent().
316    ///
317    /// Parameter `itemRef`: A reference to the keychain item to modify.
318    ///
319    /// Parameter `itemClass`: On return, the item's class. Pass NULL if you don't require this information.
320    ///
321    /// Parameter `attrList`: On input, the list of attributes to retrieve. On output, the attributes are filled in. Pass NULL if you don't need to retrieve any attributes. You must call SecKeychainItemFreeContent when you no longer need the attributes.
322    ///
323    /// Parameter `length`: On return, the length of the buffer pointed to by outData.
324    ///
325    /// Parameter `outData`: On return, a pointer to a buffer containing the data in this item. Pass NULL if you don't need to retrieve the data. You must call SecKeychainItemFreeContent when you no longer need the data.
326    ///
327    /// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if not enough valid parameters are supplied.
328    ///
329    /// # Safety
330    ///
331    /// - `item_class` must be a valid pointer or null.
332    /// - `attr_list` must be a valid pointer or null.
333    /// - `length` must be a valid pointer or null.
334    /// - `out_data` must be a valid pointer or null.
335    #[doc(alias = "SecKeychainItemCopyContent")]
336    #[cfg(feature = "SecBase")]
337    #[deprecated = "SecKeychain is deprecated"]
338    #[inline]
339    pub unsafe fn copy_content(
340        &self,
341        item_class: *mut SecItemClass,
342        attr_list: *mut SecKeychainAttributeList,
343        length: *mut u32,
344        out_data: *mut *mut c_void,
345    ) -> OSStatus {
346        extern "C-unwind" {
347            fn SecKeychainItemCopyContent(
348                item_ref: &SecKeychainItem,
349                item_class: *mut SecItemClass,
350                attr_list: *mut SecKeychainAttributeList,
351                length: *mut u32,
352                out_data: *mut *mut c_void,
353            ) -> OSStatus;
354        }
355        unsafe { SecKeychainItemCopyContent(self, item_class, attr_list, length, out_data) }
356    }
357
358    /// Releases the memory used by the keychain attribute list and the keychain data retrieved in a previous call to SecKeychainItemCopyContent.
359    ///
360    /// Parameter `attrList`: A pointer to the attribute list to release. Pass NULL to ignore this parameter.
361    ///
362    /// Parameter `data`: A pointer to the data buffer to release. Pass NULL to ignore this parameter.
363    ///
364    /// # Safety
365    ///
366    /// - `attr_list` must be a valid pointer or null.
367    /// - `data` must be a valid pointer or null.
368    #[doc(alias = "SecKeychainItemFreeContent")]
369    #[cfg(feature = "SecBase")]
370    #[deprecated = "SecKeychain is deprecated"]
371    #[inline]
372    pub unsafe fn free_content(
373        attr_list: *mut SecKeychainAttributeList,
374        data: *mut c_void,
375    ) -> OSStatus {
376        extern "C-unwind" {
377            fn SecKeychainItemFreeContent(
378                attr_list: *mut SecKeychainAttributeList,
379                data: *mut c_void,
380            ) -> OSStatus;
381        }
382        unsafe { SecKeychainItemFreeContent(attr_list, data) }
383    }
384
385    /// Copies the data and/or attributes stored in the given keychain item. You must call SecKeychainItemFreeAttributesAndData when you no longer need the attributes and data. If you want to modify the attributes returned here, use SecKeychainModifyAttributesAndData.
386    ///
387    /// Parameter `itemRef`: A reference to the keychain item to copy.
388    ///
389    /// Parameter `info`: A list of tags and formats of the attributes you wish to retrieve. Pass NULL if you don't need to retrieve any attributes. You can call SecKeychainAttributeInfoForItemID to obtain a list with all possible attribute tags and formats for the item's class.
390    ///
391    /// Parameter `itemClass`: On return, the item's class. Pass NULL if you don't require this information.
392    ///
393    /// Parameter `attrList`: On return, a pointer to the list of retrieved attributes. Pass NULL if you don't need to retrieve any attributes. You must call SecKeychainItemFreeAttributesAndData when you no longer need this list.
394    ///
395    /// Parameter `length`: On return, the length of the buffer pointed to by outData.
396    ///
397    /// Parameter `outData`: On return, a pointer to a buffer containing the data in this item. Pass NULL if you don't need to retrieve the data. You must call SecKeychainItemFreeAttributesAndData when you no longer need the data.
398    ///
399    /// Returns: A result code. See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if not enough valid parameters are supplied.
400    ///
401    /// # Safety
402    ///
403    /// - `info` must be a valid pointer or null.
404    /// - `item_class` must be a valid pointer or null.
405    /// - `attr_list` must be a valid pointer or null.
406    /// - `length` must be a valid pointer or null.
407    /// - `out_data` must be a valid pointer or null.
408    #[doc(alias = "SecKeychainItemCopyAttributesAndData")]
409    #[cfg(feature = "SecBase")]
410    #[deprecated = "SecKeychain is deprecated"]
411    #[inline]
412    pub unsafe fn copy_attributes_and_data(
413        &self,
414        info: *mut SecKeychainAttributeInfo,
415        item_class: *mut SecItemClass,
416        attr_list: *mut *mut SecKeychainAttributeList,
417        length: *mut u32,
418        out_data: *mut *mut c_void,
419    ) -> OSStatus {
420        extern "C-unwind" {
421            fn SecKeychainItemCopyAttributesAndData(
422                item_ref: &SecKeychainItem,
423                info: *mut SecKeychainAttributeInfo,
424                item_class: *mut SecItemClass,
425                attr_list: *mut *mut SecKeychainAttributeList,
426                length: *mut u32,
427                out_data: *mut *mut c_void,
428            ) -> OSStatus;
429        }
430        unsafe {
431            SecKeychainItemCopyAttributesAndData(
432                self, info, item_class, attr_list, length, out_data,
433            )
434        }
435    }
436
437    /// Releases the memory used by the keychain attribute list and the keychain data retrieved in a previous call to SecKeychainItemCopyAttributesAndData.
438    ///
439    /// Parameter `attrList`: A pointer to the attribute list to release. Pass NULL to ignore this parameter.
440    ///
441    /// Parameter `data`: A pointer to the data buffer to release. Pass NULL to ignore this parameter.
442    ///
443    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
444    ///
445    /// # Safety
446    ///
447    /// - `attr_list` must be a valid pointer or null.
448    /// - `data` must be a valid pointer or null.
449    #[doc(alias = "SecKeychainItemFreeAttributesAndData")]
450    #[cfg(feature = "SecBase")]
451    #[deprecated = "SecKeychain is deprecated"]
452    #[inline]
453    pub unsafe fn free_attributes_and_data(
454        attr_list: *mut SecKeychainAttributeList,
455        data: *mut c_void,
456    ) -> OSStatus {
457        extern "C-unwind" {
458            fn SecKeychainItemFreeAttributesAndData(
459                attr_list: *mut SecKeychainAttributeList,
460                data: *mut c_void,
461            ) -> OSStatus;
462        }
463        unsafe { SecKeychainItemFreeAttributesAndData(attr_list, data) }
464    }
465
466    /// Deletes a keychain item from the default keychain's permanent data store.
467    ///
468    /// Parameter `itemRef`: A keychain item reference of the item to delete.
469    ///
470    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
471    ///
472    /// If itemRef has not previously been added to the keychain, SecKeychainItemDelete does nothing and returns errSecSuccess. IMPORTANT: SecKeychainItemDelete does not dispose the memory occupied by the item reference itself; use the CFRelease function when you are completely finished with an item.
473    #[doc(alias = "SecKeychainItemDelete")]
474    #[cfg(feature = "SecBase")]
475    #[deprecated = "SecKeychain is deprecated"]
476    #[inline]
477    pub unsafe fn delete(&self) -> OSStatus {
478        extern "C-unwind" {
479            fn SecKeychainItemDelete(item_ref: &SecKeychainItem) -> OSStatus;
480        }
481        unsafe { SecKeychainItemDelete(self) }
482    }
483
484    /// Copies an existing keychain reference from a keychain item.
485    ///
486    /// Parameter `itemRef`: A keychain item reference.
487    ///
488    /// Parameter `keychainRef`: On return, the keychain reference for the specified item. Release this reference by calling the CFRelease function.
489    ///
490    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
491    ///
492    /// # Safety
493    ///
494    /// `keychain_ref` must be a valid pointer.
495    #[doc(alias = "SecKeychainItemCopyKeychain")]
496    #[cfg(feature = "SecBase")]
497    #[deprecated = "SecKeychain is deprecated"]
498    #[inline]
499    pub unsafe fn copy_keychain(&self, keychain_ref: NonNull<*mut SecKeychain>) -> OSStatus {
500        extern "C-unwind" {
501            fn SecKeychainItemCopyKeychain(
502                item_ref: &SecKeychainItem,
503                keychain_ref: NonNull<*mut SecKeychain>,
504            ) -> OSStatus;
505        }
506        unsafe { SecKeychainItemCopyKeychain(self, keychain_ref) }
507    }
508
509    /// Copies a keychain item.
510    ///
511    /// Parameter `itemRef`: A reference to the keychain item to copy.
512    ///
513    /// Parameter `destKeychainRef`: A reference to the keychain in which to insert the copied keychain item.
514    ///
515    /// Parameter `initialAccess`: The initial access for the copied keychain item.
516    ///
517    /// Parameter `itemCopy`: On return, a reference to the copied keychain item.
518    ///
519    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
520    ///
521    /// # Safety
522    ///
523    /// `item_copy` must be a valid pointer.
524    #[doc(alias = "SecKeychainItemCreateCopy")]
525    #[cfg(feature = "SecBase")]
526    #[deprecated = "SecKeychain is deprecated"]
527    #[inline]
528    pub unsafe fn create_copy(
529        &self,
530        dest_keychain_ref: Option<&SecKeychain>,
531        initial_access: Option<&SecAccess>,
532        item_copy: NonNull<*mut SecKeychainItem>,
533    ) -> OSStatus {
534        extern "C-unwind" {
535            fn SecKeychainItemCreateCopy(
536                item_ref: &SecKeychainItem,
537                dest_keychain_ref: Option<&SecKeychain>,
538                initial_access: Option<&SecAccess>,
539                item_copy: NonNull<*mut SecKeychainItem>,
540            ) -> OSStatus;
541        }
542        unsafe { SecKeychainItemCreateCopy(self, dest_keychain_ref, initial_access, item_copy) }
543    }
544
545    /// Returns a CFDataRef which can be used as a persistent reference to the given keychain item. The data obtained can be turned back into a SecKeychainItemRef later by calling SecKeychainItemCopyFromPersistentReference().
546    ///
547    /// Parameter `itemRef`: A reference to a keychain item.
548    ///
549    /// Parameter `persistentItemRef`: On return, a CFDataRef containing a persistent reference. You must release this data reference by calling the CFRelease function.
550    ///
551    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
552    ///
553    /// # Safety
554    ///
555    /// `persistent_item_ref` must be a valid pointer.
556    #[doc(alias = "SecKeychainItemCreatePersistentReference")]
557    #[cfg(feature = "SecBase")]
558    #[deprecated = "SecKeychain is deprecated"]
559    #[inline]
560    pub unsafe fn create_persistent_reference(
561        &self,
562        persistent_item_ref: NonNull<*const CFData>,
563    ) -> OSStatus {
564        extern "C-unwind" {
565            fn SecKeychainItemCreatePersistentReference(
566                item_ref: &SecKeychainItem,
567                persistent_item_ref: NonNull<*const CFData>,
568            ) -> OSStatus;
569        }
570        unsafe { SecKeychainItemCreatePersistentReference(self, persistent_item_ref) }
571    }
572
573    /// Returns a SecKeychainItemRef, given a persistent reference previously obtained by calling SecKeychainItemCreatePersistentReference().
574    ///
575    /// Parameter `persistentItemRef`: A CFDataRef containing a persistent reference to a keychain item.
576    ///
577    /// Parameter `itemRef`: On return, a SecKeychainItemRef for the keychain item described by the persistent reference. You must release this item reference by calling the CFRelease function.
578    ///
579    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
580    ///
581    /// # Safety
582    ///
583    /// `item_ref` must be a valid pointer.
584    #[doc(alias = "SecKeychainItemCopyFromPersistentReference")]
585    #[cfg(feature = "SecBase")]
586    #[deprecated = "SecKeychain is deprecated"]
587    #[inline]
588    pub unsafe fn copy_from_persistent_reference(
589        persistent_item_ref: &CFData,
590        item_ref: NonNull<*mut SecKeychainItem>,
591    ) -> OSStatus {
592        extern "C-unwind" {
593            fn SecKeychainItemCopyFromPersistentReference(
594                persistent_item_ref: &CFData,
595                item_ref: NonNull<*mut SecKeychainItem>,
596            ) -> OSStatus;
597        }
598        unsafe { SecKeychainItemCopyFromPersistentReference(persistent_item_ref, item_ref) }
599    }
600
601    /// Returns the CSSM_DL_DB_HANDLE for a given keychain item reference.
602    ///
603    /// Parameter `keyItemRef`: A keychain item reference.
604    ///
605    /// Parameter `dldbHandle`: On return, a CSSM_DL_DB_HANDLE for the keychain database containing the given item. The handle is valid until the keychain reference is released.
606    ///
607    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
608    ///
609    /// This API is deprecated for 10.7. It should no longer be needed.
610    ///
611    /// # Safety
612    ///
613    /// `dldb_handle` must be a valid pointer.
614    #[doc(alias = "SecKeychainItemGetDLDBHandle")]
615    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
616    #[deprecated = "CSSM is not supported"]
617    #[inline]
618    pub unsafe fn dldb_handle(&self, dldb_handle: NonNull<CSSM_DL_DB_HANDLE>) -> OSStatus {
619        extern "C-unwind" {
620            fn SecKeychainItemGetDLDBHandle(
621                key_item_ref: &SecKeychainItem,
622                dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
623            ) -> OSStatus;
624        }
625        unsafe { SecKeychainItemGetDLDBHandle(self, dldb_handle) }
626    }
627
628    /// Returns a CSSM_DB_UNIQUE_RECORD for the given keychain item reference.
629    ///
630    /// Parameter `itemRef`: A keychain item reference.
631    ///
632    /// Parameter `uniqueRecordID`: On return, a pointer to a CSSM_DB_UNIQUE_RECORD structure for the given item. The unique record is valid until the item reference is released.
633    ///
634    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
635    ///
636    /// This API is deprecated for 10.7. It should no longer be needed.
637    ///
638    /// # Safety
639    ///
640    /// `unique_record_id` must be a valid pointer.
641    #[doc(alias = "SecKeychainItemGetUniqueRecordID")]
642    #[cfg(all(
643        feature = "SecAsn1Types",
644        feature = "SecBase",
645        feature = "cssmconfig",
646        feature = "cssmtype"
647    ))]
648    #[deprecated = "CSSM is not supported"]
649    #[inline]
650    pub unsafe fn unique_record_id(
651        &self,
652        unique_record_id: NonNull<*const CSSM_DB_UNIQUE_RECORD>,
653    ) -> OSStatus {
654        extern "C-unwind" {
655            fn SecKeychainItemGetUniqueRecordID(
656                item_ref: &SecKeychainItem,
657                unique_record_id: NonNull<*const CSSM_DB_UNIQUE_RECORD>,
658            ) -> OSStatus;
659        }
660        unsafe { SecKeychainItemGetUniqueRecordID(self, unique_record_id) }
661    }
662
663    /// Copies the access of a given keychain item.
664    ///
665    /// Parameter `itemRef`: A reference to a keychain item.
666    ///
667    /// Parameter `access`: On return, a reference to the keychain item's access.
668    ///
669    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
670    ///
671    /// # Safety
672    ///
673    /// `access` must be a valid pointer.
674    #[doc(alias = "SecKeychainItemCopyAccess")]
675    #[cfg(feature = "SecBase")]
676    #[deprecated = "SecKeychain is deprecated"]
677    #[inline]
678    pub unsafe fn copy_access(&self, access: NonNull<*mut SecAccess>) -> OSStatus {
679        extern "C-unwind" {
680            fn SecKeychainItemCopyAccess(
681                item_ref: &SecKeychainItem,
682                access: NonNull<*mut SecAccess>,
683            ) -> OSStatus;
684        }
685        unsafe { SecKeychainItemCopyAccess(self, access) }
686    }
687
688    /// Sets the access of a given keychain item.
689    ///
690    /// Parameter `itemRef`: A reference to a keychain item.
691    ///
692    /// Parameter `access`: A reference to an access to replace the keychain item's current access.
693    ///
694    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
695    #[doc(alias = "SecKeychainItemSetAccess")]
696    #[cfg(feature = "SecBase")]
697    #[deprecated = "SecKeychain is deprecated"]
698    #[inline]
699    pub unsafe fn set_access(&self, access: &SecAccess) -> OSStatus {
700        extern "C-unwind" {
701            fn SecKeychainItemSetAccess(item_ref: &SecKeychainItem, access: &SecAccess)
702                -> OSStatus;
703        }
704        unsafe { SecKeychainItemSetAccess(self, access) }
705    }
706}
707
708extern "C-unwind" {
709    #[cfg(feature = "SecBase")]
710    #[deprecated = "renamed to `SecKeychainItem::modify_attributes_and_data`"]
711    pub fn SecKeychainItemModifyAttributesAndData(
712        item_ref: &SecKeychainItem,
713        attr_list: *const SecKeychainAttributeList,
714        length: u32,
715        data: *const c_void,
716    ) -> OSStatus;
717}
718
719extern "C-unwind" {
720    #[cfg(feature = "SecBase")]
721    #[deprecated = "renamed to `SecKeychainItem::create_from_content`"]
722    pub fn SecKeychainItemCreateFromContent(
723        item_class: SecItemClass,
724        attr_list: NonNull<SecKeychainAttributeList>,
725        length: u32,
726        data: *const c_void,
727        keychain_ref: Option<&SecKeychain>,
728        initial_access: Option<&SecAccess>,
729        item_ref: *mut *mut SecKeychainItem,
730    ) -> OSStatus;
731}
732
733extern "C-unwind" {
734    #[cfg(feature = "SecBase")]
735    #[deprecated = "renamed to `SecKeychainItem::modify_content`"]
736    pub fn SecKeychainItemModifyContent(
737        item_ref: &SecKeychainItem,
738        attr_list: *const SecKeychainAttributeList,
739        length: u32,
740        data: *const c_void,
741    ) -> OSStatus;
742}
743
744extern "C-unwind" {
745    #[cfg(feature = "SecBase")]
746    #[deprecated = "renamed to `SecKeychainItem::copy_content`"]
747    pub fn SecKeychainItemCopyContent(
748        item_ref: &SecKeychainItem,
749        item_class: *mut SecItemClass,
750        attr_list: *mut SecKeychainAttributeList,
751        length: *mut u32,
752        out_data: *mut *mut c_void,
753    ) -> OSStatus;
754}
755
756extern "C-unwind" {
757    #[cfg(feature = "SecBase")]
758    #[deprecated = "renamed to `SecKeychainItem::free_content`"]
759    pub fn SecKeychainItemFreeContent(
760        attr_list: *mut SecKeychainAttributeList,
761        data: *mut c_void,
762    ) -> OSStatus;
763}
764
765extern "C-unwind" {
766    #[cfg(feature = "SecBase")]
767    #[deprecated = "renamed to `SecKeychainItem::copy_attributes_and_data`"]
768    pub fn SecKeychainItemCopyAttributesAndData(
769        item_ref: &SecKeychainItem,
770        info: *mut SecKeychainAttributeInfo,
771        item_class: *mut SecItemClass,
772        attr_list: *mut *mut SecKeychainAttributeList,
773        length: *mut u32,
774        out_data: *mut *mut c_void,
775    ) -> OSStatus;
776}
777
778extern "C-unwind" {
779    #[cfg(feature = "SecBase")]
780    #[deprecated = "renamed to `SecKeychainItem::free_attributes_and_data`"]
781    pub fn SecKeychainItemFreeAttributesAndData(
782        attr_list: *mut SecKeychainAttributeList,
783        data: *mut c_void,
784    ) -> OSStatus;
785}
786
787extern "C-unwind" {
788    #[cfg(feature = "SecBase")]
789    #[deprecated = "renamed to `SecKeychainItem::delete`"]
790    pub fn SecKeychainItemDelete(item_ref: &SecKeychainItem) -> OSStatus;
791}
792
793extern "C-unwind" {
794    #[cfg(feature = "SecBase")]
795    #[deprecated = "renamed to `SecKeychainItem::copy_keychain`"]
796    pub fn SecKeychainItemCopyKeychain(
797        item_ref: &SecKeychainItem,
798        keychain_ref: NonNull<*mut SecKeychain>,
799    ) -> OSStatus;
800}
801
802extern "C-unwind" {
803    #[cfg(feature = "SecBase")]
804    #[deprecated = "renamed to `SecKeychainItem::create_copy`"]
805    pub fn SecKeychainItemCreateCopy(
806        item_ref: &SecKeychainItem,
807        dest_keychain_ref: Option<&SecKeychain>,
808        initial_access: Option<&SecAccess>,
809        item_copy: NonNull<*mut SecKeychainItem>,
810    ) -> OSStatus;
811}
812
813extern "C-unwind" {
814    #[cfg(feature = "SecBase")]
815    #[deprecated = "renamed to `SecKeychainItem::create_persistent_reference`"]
816    pub fn SecKeychainItemCreatePersistentReference(
817        item_ref: &SecKeychainItem,
818        persistent_item_ref: NonNull<*const CFData>,
819    ) -> OSStatus;
820}
821
822extern "C-unwind" {
823    #[cfg(feature = "SecBase")]
824    #[deprecated = "renamed to `SecKeychainItem::copy_from_persistent_reference`"]
825    pub fn SecKeychainItemCopyFromPersistentReference(
826        persistent_item_ref: &CFData,
827        item_ref: NonNull<*mut SecKeychainItem>,
828    ) -> OSStatus;
829}
830
831extern "C-unwind" {
832    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
833    #[deprecated = "renamed to `SecKeychainItem::dldb_handle`"]
834    pub fn SecKeychainItemGetDLDBHandle(
835        key_item_ref: &SecKeychainItem,
836        dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
837    ) -> OSStatus;
838}
839
840extern "C-unwind" {
841    #[cfg(all(
842        feature = "SecAsn1Types",
843        feature = "SecBase",
844        feature = "cssmconfig",
845        feature = "cssmtype"
846    ))]
847    #[deprecated = "renamed to `SecKeychainItem::unique_record_id`"]
848    pub fn SecKeychainItemGetUniqueRecordID(
849        item_ref: &SecKeychainItem,
850        unique_record_id: NonNull<*const CSSM_DB_UNIQUE_RECORD>,
851    ) -> OSStatus;
852}
853
854extern "C-unwind" {
855    #[cfg(feature = "SecBase")]
856    #[deprecated = "renamed to `SecKeychainItem::copy_access`"]
857    pub fn SecKeychainItemCopyAccess(
858        item_ref: &SecKeychainItem,
859        access: NonNull<*mut SecAccess>,
860    ) -> OSStatus;
861}
862
863extern "C-unwind" {
864    #[cfg(feature = "SecBase")]
865    #[deprecated = "renamed to `SecKeychainItem::set_access`"]
866    pub fn SecKeychainItemSetAccess(item_ref: &SecKeychainItem, access: &SecAccess) -> OSStatus;
867}