objc2_security/generated/
SecKeychain.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/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecunlockstatestatus?language=objc)
12pub const kSecUnlockStateStatus: u32 = 1;
13/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecreadpermstatus?language=objc)
14pub const kSecReadPermStatus: u32 = 2;
15/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecwritepermstatus?language=objc)
16pub const kSecWritePermStatus: u32 = 4;
17
18/// Contains keychain settings.
19/// Field: version An unsigned 32-bit integer representing the keychain version.
20/// Field: lockOnSleep A boolean value indicating whether the keychain locks when the system sleeps.
21/// Field: useLockInterval A boolean value indicating whether the keychain automatically locks after a certain period of time.
22/// Field: lockInterval An unsigned 32-bit integer representing the number of seconds before the keychain locks.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychainsettings?language=objc)
25#[repr(C)]
26#[derive(Clone, Copy, Debug, PartialEq)]
27pub struct SecKeychainSettings {
28    pub version: u32,
29    pub lockOnSleep: Boolean,
30    pub useLockInterval: Boolean,
31    pub lockInterval: u32,
32}
33
34#[cfg(feature = "objc2")]
35unsafe impl Encode for SecKeychainSettings {
36    const ENCODING: Encoding = Encoding::Struct(
37        "SecKeychainSettings",
38        &[
39            <u32>::ENCODING,
40            <Boolean>::ENCODING,
41            <Boolean>::ENCODING,
42            <u32>::ENCODING,
43        ],
44    );
45}
46
47#[cfg(feature = "objc2")]
48unsafe impl RefEncode for SecKeychainSettings {
49    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
50}
51
52/// [Apple's documentation](https://developer.apple.com/documentation/security/secauthenticationtype?language=objc)
53// NS_ENUM
54#[repr(transparent)]
55#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
56pub struct SecAuthenticationType(pub FourCharCode);
57impl SecAuthenticationType {
58    #[doc(alias = "kSecAuthenticationTypeNTLM")]
59    pub const NTLM: Self = Self(AUTH_TYPE_FIX_!(0x6e746c6d));
60    #[doc(alias = "kSecAuthenticationTypeMSN")]
61    pub const MSN: Self = Self(AUTH_TYPE_FIX_!(0x6d736e61));
62    #[doc(alias = "kSecAuthenticationTypeDPA")]
63    pub const DPA: Self = Self(AUTH_TYPE_FIX_!(0x64706161));
64    #[doc(alias = "kSecAuthenticationTypeRPA")]
65    pub const RPA: Self = Self(AUTH_TYPE_FIX_!(0x72706161));
66    #[doc(alias = "kSecAuthenticationTypeHTTPBasic")]
67    pub const HTTPBasic: Self = Self(AUTH_TYPE_FIX_!(0x68747470));
68    #[doc(alias = "kSecAuthenticationTypeHTTPDigest")]
69    pub const HTTPDigest: Self = Self(AUTH_TYPE_FIX_!(0x68747464));
70    #[doc(alias = "kSecAuthenticationTypeHTMLForm")]
71    pub const HTMLForm: Self = Self(AUTH_TYPE_FIX_!(0x666f726d));
72    #[doc(alias = "kSecAuthenticationTypeDefault")]
73    pub const Default: Self = Self(AUTH_TYPE_FIX_!(0x64666c74));
74    #[doc(alias = "kSecAuthenticationTypeAny")]
75    pub const Any: Self = Self(AUTH_TYPE_FIX_!(0));
76}
77
78#[cfg(feature = "objc2")]
79unsafe impl Encode for SecAuthenticationType {
80    const ENCODING: Encoding = FourCharCode::ENCODING;
81}
82
83#[cfg(feature = "objc2")]
84unsafe impl RefEncode for SecAuthenticationType {
85    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
86}
87
88/// Defines the protocol type associated with an AppleShare or Internet password.
89///
90/// See also [Apple's documentation](https://developer.apple.com/documentation/security/secprotocoltype?language=objc)
91// NS_ENUM
92#[repr(transparent)]
93#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
94pub struct SecProtocolType(pub FourCharCode);
95impl SecProtocolType {
96    #[doc(alias = "kSecProtocolTypeFTP")]
97    pub const FTP: Self = Self(0x66747020);
98    #[doc(alias = "kSecProtocolTypeFTPAccount")]
99    pub const FTPAccount: Self = Self(0x66747061);
100    #[doc(alias = "kSecProtocolTypeHTTP")]
101    pub const HTTP: Self = Self(0x68747470);
102    #[doc(alias = "kSecProtocolTypeIRC")]
103    pub const IRC: Self = Self(0x69726320);
104    #[doc(alias = "kSecProtocolTypeNNTP")]
105    pub const NNTP: Self = Self(0x6e6e7470);
106    #[doc(alias = "kSecProtocolTypePOP3")]
107    pub const POP3: Self = Self(0x706f7033);
108    #[doc(alias = "kSecProtocolTypeSMTP")]
109    pub const SMTP: Self = Self(0x736d7470);
110    #[doc(alias = "kSecProtocolTypeSOCKS")]
111    pub const SOCKS: Self = Self(0x736f7820);
112    #[doc(alias = "kSecProtocolTypeIMAP")]
113    pub const IMAP: Self = Self(0x696d6170);
114    #[doc(alias = "kSecProtocolTypeLDAP")]
115    pub const LDAP: Self = Self(0x6c646170);
116    #[doc(alias = "kSecProtocolTypeAppleTalk")]
117    pub const AppleTalk: Self = Self(0x61746c6b);
118    #[doc(alias = "kSecProtocolTypeAFP")]
119    pub const AFP: Self = Self(0x61667020);
120    #[doc(alias = "kSecProtocolTypeTelnet")]
121    pub const Telnet: Self = Self(0x74656c6e);
122    #[doc(alias = "kSecProtocolTypeSSH")]
123    pub const SSH: Self = Self(0x73736820);
124    #[doc(alias = "kSecProtocolTypeFTPS")]
125    pub const FTPS: Self = Self(0x66747073);
126    #[doc(alias = "kSecProtocolTypeHTTPS")]
127    pub const HTTPS: Self = Self(0x68747073);
128    #[doc(alias = "kSecProtocolTypeHTTPProxy")]
129    pub const HTTPProxy: Self = Self(0x68747078);
130    #[doc(alias = "kSecProtocolTypeHTTPSProxy")]
131    pub const HTTPSProxy: Self = Self(0x68747378);
132    #[doc(alias = "kSecProtocolTypeFTPProxy")]
133    pub const FTPProxy: Self = Self(0x66747078);
134    #[doc(alias = "kSecProtocolTypeCIFS")]
135    pub const CIFS: Self = Self(0x63696673);
136    #[doc(alias = "kSecProtocolTypeSMB")]
137    pub const SMB: Self = Self(0x736d6220);
138    #[doc(alias = "kSecProtocolTypeRTSP")]
139    pub const RTSP: Self = Self(0x72747370);
140    #[doc(alias = "kSecProtocolTypeRTSPProxy")]
141    pub const RTSPProxy: Self = Self(0x72747378);
142    #[doc(alias = "kSecProtocolTypeDAAP")]
143    pub const DAAP: Self = Self(0x64616170);
144    #[doc(alias = "kSecProtocolTypeEPPC")]
145    pub const EPPC: Self = Self(0x65707063);
146    #[doc(alias = "kSecProtocolTypeIPP")]
147    pub const IPP: Self = Self(0x69707020);
148    #[doc(alias = "kSecProtocolTypeNNTPS")]
149    pub const NNTPS: Self = Self(0x6e747073);
150    #[doc(alias = "kSecProtocolTypeLDAPS")]
151    pub const LDAPS: Self = Self(0x6c647073);
152    #[doc(alias = "kSecProtocolTypeTelnetS")]
153    pub const TelnetS: Self = Self(0x74656c73);
154    #[doc(alias = "kSecProtocolTypeIMAPS")]
155    pub const IMAPS: Self = Self(0x696d7073);
156    #[doc(alias = "kSecProtocolTypeIRCS")]
157    pub const IRCS: Self = Self(0x69726373);
158    #[doc(alias = "kSecProtocolTypePOP3S")]
159    pub const POP3S: Self = Self(0x706f7073);
160    #[doc(alias = "kSecProtocolTypeCVSpserver")]
161    pub const CVSpserver: Self = Self(0x63767370);
162    #[doc(alias = "kSecProtocolTypeSVN")]
163    pub const SVN: Self = Self(0x73766e20);
164    #[doc(alias = "kSecProtocolTypeAny")]
165    pub const Any: Self = Self(0);
166}
167
168#[cfg(feature = "objc2")]
169unsafe impl Encode for SecProtocolType {
170    const ENCODING: Encoding = FourCharCode::ENCODING;
171}
172
173#[cfg(feature = "objc2")]
174unsafe impl RefEncode for SecProtocolType {
175    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
176}
177
178/// Defines the keychain-related event.
179///
180/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychainevent?language=objc)
181// NS_ENUM
182#[repr(transparent)]
183#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
184pub struct SecKeychainEvent(pub u32);
185impl SecKeychainEvent {
186    #[doc(alias = "kSecLockEvent")]
187    pub const LockEvent: Self = Self(1);
188    #[doc(alias = "kSecUnlockEvent")]
189    pub const UnlockEvent: Self = Self(2);
190    #[doc(alias = "kSecAddEvent")]
191    pub const AddEvent: Self = Self(3);
192    #[doc(alias = "kSecDeleteEvent")]
193    pub const DeleteEvent: Self = Self(4);
194    #[doc(alias = "kSecUpdateEvent")]
195    pub const UpdateEvent: Self = Self(5);
196    #[doc(alias = "kSecPasswordChangedEvent")]
197    pub const PasswordChangedEvent: Self = Self(6);
198    #[doc(alias = "kSecDefaultChangedEvent")]
199    pub const DefaultChangedEvent: Self = Self(9);
200    #[doc(alias = "kSecDataAccessEvent")]
201    #[deprecated = "Read events are no longer posted"]
202    pub const DataAccessEvent: Self = Self(10);
203    #[doc(alias = "kSecKeychainListChangedEvent")]
204    pub const KeychainListChangedEvent: Self = Self(11);
205    #[doc(alias = "kSecTrustSettingsChangedEvent")]
206    pub const TrustSettingsChangedEvent: Self = Self(12);
207}
208
209#[cfg(feature = "objc2")]
210unsafe impl Encode for SecKeychainEvent {
211    const ENCODING: Encoding = u32::ENCODING;
212}
213
214#[cfg(feature = "objc2")]
215unsafe impl RefEncode for SecKeychainEvent {
216    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
217}
218
219/// Defines keychain event constants
220///
221/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychaineventmask?language=objc)
222// NS_OPTIONS
223#[repr(transparent)]
224#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
225pub struct SecKeychainEventMask(pub u32);
226bitflags::bitflags! {
227    impl SecKeychainEventMask: u32 {
228        #[doc(alias = "kSecLockEventMask")]
229        const LockEventMask = 1<<SecKeychainEvent::LockEvent.0;
230        #[doc(alias = "kSecUnlockEventMask")]
231        const UnlockEventMask = 1<<SecKeychainEvent::UnlockEvent.0;
232        #[doc(alias = "kSecAddEventMask")]
233        const AddEventMask = 1<<SecKeychainEvent::AddEvent.0;
234        #[doc(alias = "kSecDeleteEventMask")]
235        const DeleteEventMask = 1<<SecKeychainEvent::DeleteEvent.0;
236        #[doc(alias = "kSecUpdateEventMask")]
237        const UpdateEventMask = 1<<SecKeychainEvent::UpdateEvent.0;
238        #[doc(alias = "kSecPasswordChangedEventMask")]
239        const PasswordChangedEventMask = 1<<SecKeychainEvent::PasswordChangedEvent.0;
240        #[doc(alias = "kSecDefaultChangedEventMask")]
241        const DefaultChangedEventMask = 1<<SecKeychainEvent::DefaultChangedEvent.0;
242        #[doc(alias = "kSecDataAccessEventMask")]
243#[deprecated = "Read events are no longer posted"]
244        const DataAccessEventMask = 1<<SecKeychainEvent::DataAccessEvent.0;
245        #[doc(alias = "kSecKeychainListChangedMask")]
246        const KeychainListChangedMask = 1<<SecKeychainEvent::KeychainListChangedEvent.0;
247        #[doc(alias = "kSecTrustSettingsChangedEventMask")]
248        const TrustSettingsChangedEventMask = 1<<SecKeychainEvent::TrustSettingsChangedEvent.0;
249        #[doc(alias = "kSecEveryEventMask")]
250        const EveryEventMask = 0xffffffff;
251    }
252}
253
254#[cfg(feature = "objc2")]
255unsafe impl Encode for SecKeychainEventMask {
256    const ENCODING: Encoding = u32::ENCODING;
257}
258
259#[cfg(feature = "objc2")]
260unsafe impl RefEncode for SecKeychainEventMask {
261    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
262}
263
264/// Contains information about a keychain event.
265/// Field: version The version of this structure.
266/// Field: item A reference to the keychain item associated with this event, if any. Note that some events do not involve a particular keychain item.
267/// Field: keychain A reference to the keychain in which the event occurred.
268/// Field: pid The id of the process that generated this event.
269///
270/// The SecKeychainCallbackInfo type represents a structure that contains information about the keychain event for which your application is being notified. For information on how to write a keychain event callback function, see SecKeychainCallback.
271///
272/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychaincallbackinfo?language=objc)
273#[cfg(all(feature = "SecBase", feature = "libc"))]
274#[repr(C)]
275#[derive(Clone, Copy, Debug, PartialEq)]
276pub struct SecKeychainCallbackInfo {
277    pub version: u32,
278    pub item: NonNull<SecKeychainItem>,
279    pub keychain: NonNull<SecKeychain>,
280    pub pid: libc::pid_t,
281}
282
283#[cfg(all(feature = "SecBase", feature = "libc", feature = "objc2"))]
284unsafe impl Encode for SecKeychainCallbackInfo {
285    const ENCODING: Encoding = Encoding::Struct(
286        "SecKeychainCallbackInfo",
287        &[
288            <u32>::ENCODING,
289            <NonNull<SecKeychainItem>>::ENCODING,
290            <NonNull<SecKeychain>>::ENCODING,
291            <libc::pid_t>::ENCODING,
292        ],
293    );
294}
295
296#[cfg(all(feature = "SecBase", feature = "libc", feature = "objc2"))]
297unsafe impl RefEncode for SecKeychainCallbackInfo {
298    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
299}
300
301#[cfg(feature = "SecBase")]
302unsafe impl ConcreteType for SecKeychain {
303    /// Returns the type identifier of SecKeychain instances.
304    ///
305    /// Returns: The CFTypeID of SecKeychain instances.
306    #[doc(alias = "SecKeychainGetTypeID")]
307    #[inline]
308    fn type_id() -> CFTypeID {
309        extern "C-unwind" {
310            fn SecKeychainGetTypeID() -> CFTypeID;
311        }
312        unsafe { SecKeychainGetTypeID() }
313    }
314}
315
316#[cfg(feature = "SecBase")]
317impl SecKeychain {
318    /// Determines the version of the Keychain Manager installed on the user�s system.
319    ///
320    /// Parameter `returnVers`: On return, a pointer to the version number of the Keychain Manager installed on the current system.
321    ///
322    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
323    ///
324    /// # Safety
325    ///
326    /// `return_vers` must be a valid pointer.
327    #[doc(alias = "SecKeychainGetVersion")]
328    #[deprecated = "SecKeychain is deprecated"]
329    #[inline]
330    pub unsafe fn version(return_vers: NonNull<u32>) -> OSStatus {
331        extern "C-unwind" {
332            fn SecKeychainGetVersion(return_vers: NonNull<u32>) -> OSStatus;
333        }
334        unsafe { SecKeychainGetVersion(return_vers) }
335    }
336
337    /// Create a SecKeychainRef for a keychain at pathName.  This keychain might
338    /// not currently exist, use SecKeychainGetStatus if you want to confirm the existence
339    /// of this keychain.
340    ///
341    /// Parameter `pathName`: The POSIX path to a keychain.
342    ///
343    /// Parameter `keychain`: On return, a pointer to the keychain reference. The memory that keychain occupies must be released by calling CFRelease when finished with it.
344    ///
345    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain parameter is invalid (NULL).
346    ///
347    /// # Safety
348    ///
349    /// - `path_name` must be a valid pointer.
350    /// - `keychain` must be a valid pointer.
351    #[doc(alias = "SecKeychainOpen")]
352    #[cfg(feature = "SecBase")]
353    #[deprecated = "SecKeychain is deprecated"]
354    #[inline]
355    pub unsafe fn open(
356        path_name: NonNull<c_char>,
357        keychain: NonNull<*mut SecKeychain>,
358    ) -> OSStatus {
359        extern "C-unwind" {
360            fn SecKeychainOpen(
361                path_name: NonNull<c_char>,
362                keychain: NonNull<*mut SecKeychain>,
363            ) -> OSStatus;
364        }
365        unsafe { SecKeychainOpen(path_name, keychain) }
366    }
367
368    /// Creates a new keychain.
369    ///
370    /// Parameter `pathName`: The POSIX path to a keychain file.
371    ///
372    /// Parameter `passwordLength`: An unsigned 32-bit integer representing the length of the password buffer.
373    ///
374    /// Parameter `password`: A pointer to the buffer containing the password. The password must be in canonical UTF8 encoding.
375    ///
376    /// Parameter `promptUser`: A boolean representing whether to display a password dialog to the user.
377    ///
378    /// Parameter `initialAccess`: An access reference.
379    ///
380    /// Parameter `keychain`: On return, a pointer to a keychain reference. The memory that keychain occupies must be released by calling CFRelease when finished with it.
381    ///
382    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain parameter is invalid (NULL).
383    ///
384    /// # Safety
385    ///
386    /// - `path_name` must be a valid pointer.
387    /// - `password` must be a valid pointer or null.
388    /// - `keychain` must be a valid pointer.
389    #[doc(alias = "SecKeychainCreate")]
390    #[cfg(feature = "SecBase")]
391    #[deprecated = "SecKeychain is deprecated"]
392    #[inline]
393    pub unsafe fn create(
394        path_name: NonNull<c_char>,
395        password_length: u32,
396        password: *const c_void,
397        prompt_user: bool,
398        initial_access: Option<&SecAccess>,
399        keychain: NonNull<*mut SecKeychain>,
400    ) -> OSStatus {
401        extern "C-unwind" {
402            fn SecKeychainCreate(
403                path_name: NonNull<c_char>,
404                password_length: u32,
405                password: *const c_void,
406                prompt_user: Boolean,
407                initial_access: Option<&SecAccess>,
408                keychain: NonNull<*mut SecKeychain>,
409            ) -> OSStatus;
410        }
411        unsafe {
412            SecKeychainCreate(
413                path_name,
414                password_length,
415                password,
416                prompt_user as _,
417                initial_access,
418                keychain,
419            )
420        }
421    }
422
423    /// Removes one or more keychains from the current keychain searchlist, and deletes the keychain storage (if the keychains are file-based).
424    ///
425    /// Parameter `keychainOrArray`: A single keychain reference or a reference to an array of keychains to delete. IMPORTANT: SecKeychainDelete does not dispose the memory occupied by keychain references; use the CFRelease function when you are completely finished with a keychain.
426    ///
427    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecInvalidKeychain (-25295) may be returned if the keychain parameter is invalid (NULL).
428    #[doc(alias = "SecKeychainDelete")]
429    #[cfg(feature = "SecBase")]
430    #[deprecated = "SecKeychain is deprecated"]
431    #[inline]
432    pub unsafe fn delete(keychain_or_array: Option<&SecKeychain>) -> OSStatus {
433        extern "C-unwind" {
434            fn SecKeychainDelete(keychain_or_array: Option<&SecKeychain>) -> OSStatus;
435        }
436        unsafe { SecKeychainDelete(keychain_or_array) }
437    }
438
439    /// Changes the settings of a keychain.
440    ///
441    /// Parameter `keychain`: A reference to a keychain.
442    ///
443    /// Parameter `newSettings`: A pointer to the new keychain settings.
444    ///
445    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
446    ///
447    /// # Safety
448    ///
449    /// `new_settings` must be a valid pointer.
450    #[doc(alias = "SecKeychainSetSettings")]
451    #[cfg(feature = "SecBase")]
452    #[deprecated = "SecKeychain is deprecated"]
453    #[inline]
454    pub unsafe fn set_settings(
455        keychain: Option<&SecKeychain>,
456        new_settings: NonNull<SecKeychainSettings>,
457    ) -> OSStatus {
458        extern "C-unwind" {
459            fn SecKeychainSetSettings(
460                keychain: Option<&SecKeychain>,
461                new_settings: NonNull<SecKeychainSettings>,
462            ) -> OSStatus;
463        }
464        unsafe { SecKeychainSetSettings(keychain, new_settings) }
465    }
466
467    /// Copy the keychain settings.
468    ///
469    /// Parameter `keychain`: A reference to the keychain from which to copy its settings.
470    ///
471    /// Parameter `outSettings`: A pointer to a keychain settings structure. Since this structure is versioned, you must preallocate it and fill in the version of the structure.
472    ///
473    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
474    ///
475    /// # Safety
476    ///
477    /// `out_settings` must be a valid pointer.
478    #[doc(alias = "SecKeychainCopySettings")]
479    #[cfg(feature = "SecBase")]
480    #[deprecated = "SecKeychain is deprecated"]
481    #[inline]
482    pub unsafe fn copy_settings(
483        keychain: Option<&SecKeychain>,
484        out_settings: NonNull<SecKeychainSettings>,
485    ) -> OSStatus {
486        extern "C-unwind" {
487            fn SecKeychainCopySettings(
488                keychain: Option<&SecKeychain>,
489                out_settings: NonNull<SecKeychainSettings>,
490            ) -> OSStatus;
491        }
492        unsafe { SecKeychainCopySettings(keychain, out_settings) }
493    }
494
495    /// Unlocks the specified keychain.
496    ///
497    /// Parameter `keychain`: A reference to the keychain to unlock. Pass NULL to specify the default keychain. If you pass NULL and the default keychain is currently locked, the keychain will appear as the default choice. If you pass a locked keychain, SecKeychainUnlock will use the password provided to unlock it. If the default keychain is currently unlocked, SecKeychainUnlock returns errSecSuccess.
498    ///
499    /// Parameter `passwordLength`: An unsigned 32-bit integer representing the length of the password buffer.
500    ///
501    /// Parameter `password`: A buffer containing the password for the keychain. Pass NULL if the user password is unknown. In this case, SecKeychainUnlock displays the Unlock Keychain dialog box, and the authentication user interface associated with the keychain about to be unlocked.
502    ///
503    /// Parameter `usePassword`: A boolean indicating whether the password parameter is used.  You should pass TRUE if it is used or FALSE if it is ignored.
504    ///
505    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
506    ///
507    /// In most cases, your application does not need to call the SecKeychainUnlock function directly, since most Keychain Manager functions that require an unlocked keychain call SecKeychainUnlock automatically. If your application needs to verify that a keychain is unlocked, call the function SecKeychainGetStatus.
508    ///
509    /// # Safety
510    ///
511    /// `password` must be a valid pointer or null.
512    #[doc(alias = "SecKeychainUnlock")]
513    #[cfg(feature = "SecBase")]
514    #[deprecated = "SecKeychain is deprecated"]
515    #[inline]
516    pub unsafe fn unlock(
517        keychain: Option<&SecKeychain>,
518        password_length: u32,
519        password: *const c_void,
520        use_password: bool,
521    ) -> OSStatus {
522        extern "C-unwind" {
523            fn SecKeychainUnlock(
524                keychain: Option<&SecKeychain>,
525                password_length: u32,
526                password: *const c_void,
527                use_password: Boolean,
528            ) -> OSStatus;
529        }
530        unsafe { SecKeychainUnlock(keychain, password_length, password, use_password as _) }
531    }
532
533    /// Locks the specified keychain.
534    ///
535    /// Parameter `keychain`: A reference to the keychain to lock.
536    ///
537    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
538    #[doc(alias = "SecKeychainLock")]
539    #[cfg(feature = "SecBase")]
540    #[deprecated = "SecKeychain is deprecated"]
541    #[inline]
542    pub unsafe fn lock(keychain: Option<&SecKeychain>) -> OSStatus {
543        extern "C-unwind" {
544            fn SecKeychainLock(keychain: Option<&SecKeychain>) -> OSStatus;
545        }
546        unsafe { SecKeychainLock(keychain) }
547    }
548
549    /// Locks all keychains belonging to the current user.
550    ///
551    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
552    #[doc(alias = "SecKeychainLockAll")]
553    #[deprecated = "SecKeychain is deprecated"]
554    #[inline]
555    pub unsafe fn lock_all() -> OSStatus {
556        extern "C-unwind" {
557            fn SecKeychainLockAll() -> OSStatus;
558        }
559        unsafe { SecKeychainLockAll() }
560    }
561
562    /// Retrieves a reference to the default keychain.
563    ///
564    /// Parameter `keychain`: On return, a pointer to the default keychain reference.
565    ///
566    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
567    ///
568    /// # Safety
569    ///
570    /// `keychain` must be a valid pointer.
571    #[doc(alias = "SecKeychainCopyDefault")]
572    #[cfg(feature = "SecBase")]
573    #[deprecated = "SecKeychain is deprecated"]
574    #[inline]
575    pub unsafe fn copy_default(keychain: NonNull<*mut SecKeychain>) -> OSStatus {
576        extern "C-unwind" {
577            fn SecKeychainCopyDefault(keychain: NonNull<*mut SecKeychain>) -> OSStatus;
578        }
579        unsafe { SecKeychainCopyDefault(keychain) }
580    }
581
582    /// Sets the default keychain.
583    ///
584    /// Parameter `keychain`: A reference to the keychain to set as default.
585    ///
586    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain parameter is invalid (NULL).
587    #[doc(alias = "SecKeychainSetDefault")]
588    #[cfg(feature = "SecBase")]
589    #[deprecated = "SecKeychain is deprecated"]
590    #[inline]
591    pub unsafe fn set_default(keychain: Option<&SecKeychain>) -> OSStatus {
592        extern "C-unwind" {
593            fn SecKeychainSetDefault(keychain: Option<&SecKeychain>) -> OSStatus;
594        }
595        unsafe { SecKeychainSetDefault(keychain) }
596    }
597
598    /// Retrieves a keychain search list.
599    ///
600    /// Parameter `searchList`: The returned list of keychains to search. When finished with the array, you must call CFRelease() to release the memory.
601    ///
602    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain list is not specified (NULL).
603    ///
604    /// # Safety
605    ///
606    /// `search_list` must be a valid pointer.
607    #[doc(alias = "SecKeychainCopySearchList")]
608    #[deprecated = "SecKeychain is deprecated"]
609    #[inline]
610    pub unsafe fn copy_search_list(search_list: NonNull<*const CFArray>) -> OSStatus {
611        extern "C-unwind" {
612            fn SecKeychainCopySearchList(search_list: NonNull<*const CFArray>) -> OSStatus;
613        }
614        unsafe { SecKeychainCopySearchList(search_list) }
615    }
616
617    /// Specifies the list of keychains to use in a keychain search list.
618    ///
619    /// Parameter `searchList`: The list of keychains to use in a search list when the SecKeychainCopySearchList function is called. An empty array clears the search list.
620    ///
621    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if the keychain list is not specified (NULL).
622    ///
623    /// # Safety
624    ///
625    /// `search_list` generic must be of the correct type.
626    #[doc(alias = "SecKeychainSetSearchList")]
627    #[deprecated = "SecKeychain is deprecated"]
628    #[inline]
629    pub unsafe fn set_search_list(search_list: &CFArray) -> OSStatus {
630        extern "C-unwind" {
631            fn SecKeychainSetSearchList(search_list: &CFArray) -> OSStatus;
632        }
633        unsafe { SecKeychainSetSearchList(search_list) }
634    }
635}
636
637/// [Apple's documentation](https://developer.apple.com/documentation/security/secpreferencesdomain?language=objc)
638// NS_ENUM
639#[repr(transparent)]
640#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
641pub struct SecPreferencesDomain(pub c_int);
642impl SecPreferencesDomain {
643    #[doc(alias = "kSecPreferencesDomainUser")]
644    pub const User: Self = Self(0);
645    #[doc(alias = "kSecPreferencesDomainSystem")]
646    pub const System: Self = Self(1);
647    #[doc(alias = "kSecPreferencesDomainCommon")]
648    pub const Common: Self = Self(2);
649    #[doc(alias = "kSecPreferencesDomainDynamic")]
650    pub const Dynamic: Self = Self(3);
651}
652
653#[cfg(feature = "objc2")]
654unsafe impl Encode for SecPreferencesDomain {
655    const ENCODING: Encoding = c_int::ENCODING;
656}
657
658#[cfg(feature = "objc2")]
659unsafe impl RefEncode for SecPreferencesDomain {
660    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
661}
662
663#[cfg(feature = "SecBase")]
664impl SecKeychain {
665    /// # Safety
666    ///
667    /// `keychain` must be a valid pointer.
668    #[doc(alias = "SecKeychainCopyDomainDefault")]
669    #[cfg(feature = "SecBase")]
670    #[deprecated = "SecKeychain is deprecated"]
671    #[inline]
672    pub unsafe fn copy_domain_default(
673        domain: SecPreferencesDomain,
674        keychain: NonNull<*mut SecKeychain>,
675    ) -> OSStatus {
676        extern "C-unwind" {
677            fn SecKeychainCopyDomainDefault(
678                domain: SecPreferencesDomain,
679                keychain: NonNull<*mut SecKeychain>,
680            ) -> OSStatus;
681        }
682        unsafe { SecKeychainCopyDomainDefault(domain, keychain) }
683    }
684
685    #[doc(alias = "SecKeychainSetDomainDefault")]
686    #[cfg(feature = "SecBase")]
687    #[deprecated = "SecKeychain is deprecated"]
688    #[inline]
689    pub unsafe fn set_domain_default(
690        domain: SecPreferencesDomain,
691        keychain: Option<&SecKeychain>,
692    ) -> OSStatus {
693        extern "C-unwind" {
694            fn SecKeychainSetDomainDefault(
695                domain: SecPreferencesDomain,
696                keychain: Option<&SecKeychain>,
697            ) -> OSStatus;
698        }
699        unsafe { SecKeychainSetDomainDefault(domain, keychain) }
700    }
701
702    /// # Safety
703    ///
704    /// `search_list` must be a valid pointer.
705    #[doc(alias = "SecKeychainCopyDomainSearchList")]
706    #[deprecated = "SecKeychain is deprecated"]
707    #[inline]
708    pub unsafe fn copy_domain_search_list(
709        domain: SecPreferencesDomain,
710        search_list: NonNull<*const CFArray>,
711    ) -> OSStatus {
712        extern "C-unwind" {
713            fn SecKeychainCopyDomainSearchList(
714                domain: SecPreferencesDomain,
715                search_list: NonNull<*const CFArray>,
716            ) -> OSStatus;
717        }
718        unsafe { SecKeychainCopyDomainSearchList(domain, search_list) }
719    }
720
721    /// # Safety
722    ///
723    /// `search_list` generic must be of the correct type.
724    #[doc(alias = "SecKeychainSetDomainSearchList")]
725    #[deprecated = "SecKeychain is deprecated"]
726    #[inline]
727    pub unsafe fn set_domain_search_list(
728        domain: SecPreferencesDomain,
729        search_list: &CFArray,
730    ) -> OSStatus {
731        extern "C-unwind" {
732            fn SecKeychainSetDomainSearchList(
733                domain: SecPreferencesDomain,
734                search_list: &CFArray,
735            ) -> OSStatus;
736        }
737        unsafe { SecKeychainSetDomainSearchList(domain, search_list) }
738    }
739
740    #[doc(alias = "SecKeychainSetPreferenceDomain")]
741    #[deprecated = "SecKeychain is deprecated"]
742    #[inline]
743    pub unsafe fn set_preference_domain(domain: SecPreferencesDomain) -> OSStatus {
744        extern "C-unwind" {
745            fn SecKeychainSetPreferenceDomain(domain: SecPreferencesDomain) -> OSStatus;
746        }
747        unsafe { SecKeychainSetPreferenceDomain(domain) }
748    }
749
750    /// # Safety
751    ///
752    /// `domain` must be a valid pointer.
753    #[doc(alias = "SecKeychainGetPreferenceDomain")]
754    #[deprecated = "SecKeychain is deprecated"]
755    #[inline]
756    pub unsafe fn preference_domain(domain: NonNull<SecPreferencesDomain>) -> OSStatus {
757        extern "C-unwind" {
758            fn SecKeychainGetPreferenceDomain(domain: NonNull<SecPreferencesDomain>) -> OSStatus;
759        }
760        unsafe { SecKeychainGetPreferenceDomain(domain) }
761    }
762
763    /// Retrieves status information for the specified keychain.
764    ///
765    /// Parameter `keychain`: A keychain reference. Pass NULL to specify the default keychain.
766    ///
767    /// Parameter `keychainStatus`: On return, a pointer to the status of the specified keychain.  See KeychainStatus for valid status constants.
768    ///
769    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
770    ///
771    /// # Safety
772    ///
773    /// `keychain_status` must be a valid pointer.
774    #[doc(alias = "SecKeychainGetStatus")]
775    #[cfg(feature = "SecBase")]
776    #[deprecated = "SecKeychain is deprecated"]
777    #[inline]
778    pub unsafe fn status(
779        keychain: Option<&SecKeychain>,
780        keychain_status: NonNull<SecKeychainStatus>,
781    ) -> OSStatus {
782        extern "C-unwind" {
783            fn SecKeychainGetStatus(
784                keychain: Option<&SecKeychain>,
785                keychain_status: NonNull<SecKeychainStatus>,
786            ) -> OSStatus;
787        }
788        unsafe { SecKeychainGetStatus(keychain, keychain_status) }
789    }
790
791    /// Get the path of the specified keychain.
792    ///
793    /// Parameter `keychain`: A reference to a keychain.
794    ///
795    /// Parameter `ioPathLength`: On input, a pointer to the size of the buffer pointed to by pathName. On return, the size of the buffer without the zero termination.
796    ///
797    /// Parameter `pathName`: On return, the POSIX path to the keychain.
798    ///
799    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
800    ///
801    /// # Safety
802    ///
803    /// - `io_path_length` must be a valid pointer.
804    /// - `path_name` must be a valid pointer.
805    #[doc(alias = "SecKeychainGetPath")]
806    #[cfg(feature = "SecBase")]
807    #[deprecated = "SecKeychain is deprecated"]
808    #[inline]
809    pub unsafe fn path(
810        keychain: Option<&SecKeychain>,
811        io_path_length: NonNull<u32>,
812        path_name: NonNull<c_char>,
813    ) -> OSStatus {
814        extern "C-unwind" {
815            fn SecKeychainGetPath(
816                keychain: Option<&SecKeychain>,
817                io_path_length: NonNull<u32>,
818                path_name: NonNull<c_char>,
819            ) -> OSStatus;
820        }
821        unsafe { SecKeychainGetPath(keychain, io_path_length, path_name) }
822    }
823
824    /// Obtains tags for all possible attributes for a given item class.
825    ///
826    /// Parameter `keychain`: A keychain reference.
827    ///
828    /// Parameter `itemID`: The relation identifier of the item tags (an itemID is a CSSM_DB_RECORDTYPE defined in cssmapple.h).
829    ///
830    /// Parameter `info`: On return, a pointer to the keychain attribute information. User should call the SecKeychainFreeAttributeInfo function to release the structure when done with it.
831    ///
832    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if not enough valid parameters were supplied (NULL).
833    ///
834    /// Warning, this call returns more attributes than are support by the old style Keychain API and passing them into older calls will yield an invalid attribute error. The recommended call to retrieve the attribute values is the SecKeychainItemCopyAttributesAndData function.
835    ///
836    /// # Safety
837    ///
838    /// `info` must be a valid pointer.
839    #[doc(alias = "SecKeychainAttributeInfoForItemID")]
840    #[cfg(feature = "SecBase")]
841    #[deprecated = "SecKeychain is deprecated"]
842    #[inline]
843    pub unsafe fn attribute_info_for_item_id(
844        keychain: Option<&SecKeychain>,
845        item_id: u32,
846        info: NonNull<*mut SecKeychainAttributeInfo>,
847    ) -> OSStatus {
848        extern "C-unwind" {
849            fn SecKeychainAttributeInfoForItemID(
850                keychain: Option<&SecKeychain>,
851                item_id: u32,
852                info: NonNull<*mut SecKeychainAttributeInfo>,
853            ) -> OSStatus;
854        }
855        unsafe { SecKeychainAttributeInfoForItemID(keychain, item_id, info) }
856    }
857
858    /// Releases the memory acquired by calling the SecKeychainAttributeInfoForItemID function.
859    ///
860    /// Parameter `info`: A pointer to the keychain attribute information to release.
861    ///
862    /// Returns: A result code.  See "Security Error Codes" (SecBase.h). In addition, errSecParam (-50) may be returned if not enough valid parameters were supplied (NULL).
863    ///
864    /// # Safety
865    ///
866    /// `info` must be a valid pointer.
867    #[doc(alias = "SecKeychainFreeAttributeInfo")]
868    #[cfg(feature = "SecBase")]
869    #[deprecated = "SecKeychain is deprecated"]
870    #[inline]
871    pub unsafe fn free_attribute_info(info: NonNull<SecKeychainAttributeInfo>) -> OSStatus {
872        extern "C-unwind" {
873            fn SecKeychainFreeAttributeInfo(info: NonNull<SecKeychainAttributeInfo>) -> OSStatus;
874        }
875        unsafe { SecKeychainFreeAttributeInfo(info) }
876    }
877}
878
879/// Defines a pointer to a customized callback function.  You supply the customized callback function to do a callback tailored to your application's needs.
880///
881/// Parameter `keychainEvent`: The keychain event that your application wishes to be notified of. See SecKeychainEvent for a description of possible values. The type of event that can trigger your callback depends on the bit mask you passed in the eventMask parameter of the function SecKeychainAddCallback. For more information, see the discussion.
882///
883/// Parameter `info`: A pointer to a structure of type SecKeychainCallbackInfo. On return, the structure contains information about the keychain event that occurred. The Keychain Manager passes this information to your callback function via the info parameter.
884///
885/// Parameter `context`: A pointer to application-defined storage that your application previously passed to the function SecKeychainAddCallback. You can use this value to perform operations like track which instance of a function is operating.
886///
887/// Returns: A result code.  See "Security Error Codes" (SecBase.h).
888///
889/// If you name your function MyKeychainEventCallback, you would declare it like this:
890/// OSStatus MyKeychainEventCallback (
891/// SecKeychainEvent keychainEvent,
892/// SecKeychainCallbackInfo *info,
893/// void *context);
894///
895/// To add your callback function, use the SecKeychainAddCallback function.  To remove your callback function, use the SecKeychainRemoveCallback function.
896///
897/// See also [Apple's documentation](https://developer.apple.com/documentation/security/seckeychaincallback?language=objc)
898#[deprecated = "SecKeychain is deprecated"]
899#[cfg(all(feature = "SecBase", feature = "libc"))]
900pub type SecKeychainCallback = Option<
901    unsafe extern "C-unwind" fn(
902        SecKeychainEvent,
903        NonNull<SecKeychainCallbackInfo>,
904        *mut c_void,
905    ) -> OSStatus,
906>;
907
908#[cfg(feature = "SecBase")]
909impl SecKeychain {
910    /// Registers your keychain event callback function
911    ///
912    /// Parameter `callbackFunction`: A pointer to your keychain event callback function, described in SecKeychainCallback. You indicate the type of keychain events you want to receive by passing a bit mask of the desired events in the eventMask parameter.
913    ///
914    /// Parameter `eventMask`: A bit mask indicating the keychain events that your application wishes to be notified of. See SecKeychainEventMask for a description of this bit mask. The Keychain Manager tests this mask to determine the keychain events that you wish to receive, and passes these events in the keychainEvent parameter of your callback function. See SecKeychainEvent for a description of these events.
915    ///
916    /// Parameter `userContext`: A pointer to application-defined storage that will be passed to your callback function. Your application can use this to associate any particular call of SecKeychainAddCallback with any particular call of your keychain event callback function.
917    ///
918    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
919    ///
920    /// # Safety
921    ///
922    /// - `callback_function` must be implemented correctly.
923    /// - `user_context` must be a valid pointer or null.
924    #[doc(alias = "SecKeychainAddCallback")]
925    #[cfg(all(feature = "SecBase", feature = "libc"))]
926    #[deprecated = "SecKeychain is deprecated"]
927    #[inline]
928    pub unsafe fn add_callback(
929        callback_function: SecKeychainCallback,
930        event_mask: SecKeychainEventMask,
931        user_context: *mut c_void,
932    ) -> OSStatus {
933        extern "C-unwind" {
934            fn SecKeychainAddCallback(
935                callback_function: SecKeychainCallback,
936                event_mask: SecKeychainEventMask,
937                user_context: *mut c_void,
938            ) -> OSStatus;
939        }
940        unsafe { SecKeychainAddCallback(callback_function, event_mask, user_context) }
941    }
942
943    /// Unregisters your keychain event callback function. Once removed, keychain events won't be sent to the owner of the callback.
944    ///
945    /// Parameter `callbackFunction`: The callback function pointer to remove
946    ///
947    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
948    ///
949    /// # Safety
950    ///
951    /// `callback_function` must be implemented correctly.
952    #[doc(alias = "SecKeychainRemoveCallback")]
953    #[cfg(all(feature = "SecBase", feature = "libc"))]
954    #[deprecated = "SecKeychain is deprecated"]
955    #[inline]
956    pub unsafe fn remove_callback(callback_function: SecKeychainCallback) -> OSStatus {
957        extern "C-unwind" {
958            fn SecKeychainRemoveCallback(callback_function: SecKeychainCallback) -> OSStatus;
959        }
960        unsafe { SecKeychainRemoveCallback(callback_function) }
961    }
962
963    /// Adds an Internet password to the specified keychain.
964    ///
965    /// Parameter `keychain`: A reference to a keychain in which to store an Internet password. Pass NULL to specify the user's default keychain.
966    ///
967    /// Parameter `serverNameLength`: The length of the buffer pointed to by serverName.
968    ///
969    /// Parameter `serverName`: A pointer to a string containing the server name associated with this password.
970    ///
971    /// Parameter `securityDomainLength`: The length of the buffer pointed to by securityDomain.
972    ///
973    /// Parameter `securityDomain`: A pointer to a string containing the security domain associated with this password, or NULL if there is no relevant security domain.
974    ///
975    /// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
976    ///
977    /// Parameter `accountName`: A pointer to a string containing the account name associated with this password.
978    ///
979    /// Parameter `pathLength`: The length of the buffer pointed to by path.
980    ///
981    /// Parameter `path`: A pointer to a string containing the path associated with this password, or NULL if there is no relevant path string.
982    ///
983    /// Parameter `port`: The TCP/IP port number. If no specific port number is associated with this item, pass 0.
984    ///
985    /// Parameter `protocol`: The protocol associated with this password. See SecProtocolType for a description of possible values.
986    ///
987    /// Parameter `authenticationType`: The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault to specify the default authentication scheme.
988    ///
989    /// Parameter `passwordLength`: The length of the buffer pointed to by passwordData.
990    ///
991    /// Parameter `passwordData`: A pointer to a buffer containing the password data to be stored in the keychain.
992    ///
993    /// Parameter `itemRef`: On return, a reference to the new keychain item.
994    ///
995    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
996    ///
997    /// The SecKeychainAddInternetPassword function adds a new Internet server password to the specified keychain. Required parameters to identify the password are serverName and accountName (you cannot pass NULL for both parameters). In addition, some protocols may require an optional securityDomain when authentication is requested. SecKeychainAddInternetPassword optionally returns a reference to the newly added item.
998    ///
999    /// # Safety
1000    ///
1001    /// - `server_name` must be a valid pointer or null.
1002    /// - `security_domain` must be a valid pointer or null.
1003    /// - `account_name` must be a valid pointer or null.
1004    /// - `path` must be a valid pointer or null.
1005    /// - `password_data` must be a valid pointer.
1006    /// - `item_ref` must be a valid pointer or null.
1007    #[doc(alias = "SecKeychainAddInternetPassword")]
1008    #[cfg(feature = "SecBase")]
1009    #[deprecated = "SecKeychain is deprecated"]
1010    #[inline]
1011    pub unsafe fn add_internet_password(
1012        keychain: Option<&SecKeychain>,
1013        server_name_length: u32,
1014        server_name: *const c_char,
1015        security_domain_length: u32,
1016        security_domain: *const c_char,
1017        account_name_length: u32,
1018        account_name: *const c_char,
1019        path_length: u32,
1020        path: *const c_char,
1021        port: u16,
1022        protocol: SecProtocolType,
1023        authentication_type: SecAuthenticationType,
1024        password_length: u32,
1025        password_data: NonNull<c_void>,
1026        item_ref: *mut *mut SecKeychainItem,
1027    ) -> OSStatus {
1028        extern "C-unwind" {
1029            fn SecKeychainAddInternetPassword(
1030                keychain: Option<&SecKeychain>,
1031                server_name_length: u32,
1032                server_name: *const c_char,
1033                security_domain_length: u32,
1034                security_domain: *const c_char,
1035                account_name_length: u32,
1036                account_name: *const c_char,
1037                path_length: u32,
1038                path: *const c_char,
1039                port: u16,
1040                protocol: SecProtocolType,
1041                authentication_type: SecAuthenticationType,
1042                password_length: u32,
1043                password_data: NonNull<c_void>,
1044                item_ref: *mut *mut SecKeychainItem,
1045            ) -> OSStatus;
1046        }
1047        unsafe {
1048            SecKeychainAddInternetPassword(
1049                keychain,
1050                server_name_length,
1051                server_name,
1052                security_domain_length,
1053                security_domain,
1054                account_name_length,
1055                account_name,
1056                path_length,
1057                path,
1058                port,
1059                protocol,
1060                authentication_type,
1061                password_length,
1062                password_data,
1063                item_ref,
1064            )
1065        }
1066    }
1067
1068    /// Finds an Internet password based on the attributes passed.
1069    ///
1070    /// Parameter `keychainOrArray`: A reference to an array of keychains to search, a single keychain, or NULL to search the user's default keychain search list.
1071    ///
1072    /// Parameter `serverNameLength`: The length of the buffer pointed to by serverName.
1073    ///
1074    /// Parameter `serverName`: A pointer to a string containing the server name.
1075    ///
1076    /// Parameter `securityDomainLength`: The length of the buffer pointed to by securityDomain.
1077    ///
1078    /// Parameter `securityDomain`: A pointer to a string containing the security domain. This parameter is optional, as not all protocols will require it.
1079    ///
1080    /// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
1081    ///
1082    /// Parameter `accountName`: A pointer to a string containing the account name.
1083    ///
1084    /// Parameter `pathLength`: The length of the buffer pointed to by path.
1085    ///
1086    /// Parameter `path`: A pointer to a string containing the path.
1087    ///
1088    /// Parameter `port`: The TCP/IP port number. Pass 0 to ignore the port number.
1089    ///
1090    /// Parameter `protocol`: The protocol associated with this password. See SecProtocolType for a description of possible values.
1091    ///
1092    /// Parameter `authenticationType`: The authentication scheme used. See SecAuthenticationType for a description of possible values. Pass the constant kSecAuthenticationTypeDefault to specify the default authentication scheme.
1093    ///
1094    /// Parameter `passwordLength`: On return, the length of the buffer pointed to by passwordData.
1095    ///
1096    /// Parameter `passwordData`: On return, a pointer to a data buffer containing the password. Your application must call SecKeychainItemFreeContent(NULL, passwordData) to release this data buffer when it is no longer needed. Pass NULL if you are not interested in retrieving the password data at this time, but simply want to find the item reference.
1097    ///
1098    /// Parameter `itemRef`: On return, a reference to the keychain item which was found.
1099    ///
1100    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1101    ///
1102    /// The SecKeychainFindInternetPassword function finds the first Internet password item which matches the attributes you provide. Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. SecKeychainFindInternetPassword optionally returns a reference to the found item.
1103    ///
1104    /// # Safety
1105    ///
1106    /// - `keychain_or_array` should be of the correct type.
1107    /// - `server_name` must be a valid pointer or null.
1108    /// - `security_domain` must be a valid pointer or null.
1109    /// - `account_name` must be a valid pointer or null.
1110    /// - `path` must be a valid pointer or null.
1111    /// - `password_length` must be a valid pointer or null.
1112    /// - `password_data` must be a valid pointer or null.
1113    /// - `item_ref` must be a valid pointer or null.
1114    #[doc(alias = "SecKeychainFindInternetPassword")]
1115    #[cfg(feature = "SecBase")]
1116    #[deprecated = "SecKeychain is deprecated"]
1117    #[inline]
1118    pub unsafe fn find_internet_password(
1119        keychain_or_array: Option<&CFType>,
1120        server_name_length: u32,
1121        server_name: *const c_char,
1122        security_domain_length: u32,
1123        security_domain: *const c_char,
1124        account_name_length: u32,
1125        account_name: *const c_char,
1126        path_length: u32,
1127        path: *const c_char,
1128        port: u16,
1129        protocol: SecProtocolType,
1130        authentication_type: SecAuthenticationType,
1131        password_length: *mut u32,
1132        password_data: *mut *mut c_void,
1133        item_ref: *mut *mut SecKeychainItem,
1134    ) -> OSStatus {
1135        extern "C-unwind" {
1136            fn SecKeychainFindInternetPassword(
1137                keychain_or_array: Option<&CFType>,
1138                server_name_length: u32,
1139                server_name: *const c_char,
1140                security_domain_length: u32,
1141                security_domain: *const c_char,
1142                account_name_length: u32,
1143                account_name: *const c_char,
1144                path_length: u32,
1145                path: *const c_char,
1146                port: u16,
1147                protocol: SecProtocolType,
1148                authentication_type: SecAuthenticationType,
1149                password_length: *mut u32,
1150                password_data: *mut *mut c_void,
1151                item_ref: *mut *mut SecKeychainItem,
1152            ) -> OSStatus;
1153        }
1154        unsafe {
1155            SecKeychainFindInternetPassword(
1156                keychain_or_array,
1157                server_name_length,
1158                server_name,
1159                security_domain_length,
1160                security_domain,
1161                account_name_length,
1162                account_name,
1163                path_length,
1164                path,
1165                port,
1166                protocol,
1167                authentication_type,
1168                password_length,
1169                password_data,
1170                item_ref,
1171            )
1172        }
1173    }
1174
1175    /// Adds a generic password to the specified keychain.
1176    ///
1177    /// Parameter `keychain`: A reference to the keychain in which to store a generic password. Pass NULL to specify the user's default keychain.
1178    ///
1179    /// Parameter `serviceNameLength`: The length of the buffer pointed to by serviceName.
1180    ///
1181    /// Parameter `serviceName`: A pointer to a string containing the service name associated with this password.
1182    ///
1183    /// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
1184    ///
1185    /// Parameter `accountName`: A pointer to a string containing the account name associated with this password.
1186    ///
1187    /// Parameter `passwordLength`: The length of the buffer pointed to by passwordData.
1188    ///
1189    /// Parameter `passwordData`: A pointer to a buffer containing the password data to be stored in the keychain.
1190    ///
1191    /// Parameter `itemRef`: On return, a reference to the new keychain item.
1192    ///
1193    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
1194    ///
1195    /// The SecKeychainAddGenericPassword function adds a new generic password to the default keychain. Required parameters to identify the password are serviceName and accountName, which are application-defined strings. SecKeychainAddGenericPassword optionally returns a reference to the newly added item.
1196    ///
1197    /// # Safety
1198    ///
1199    /// - `service_name` must be a valid pointer or null.
1200    /// - `account_name` must be a valid pointer or null.
1201    /// - `password_data` must be a valid pointer.
1202    /// - `item_ref` must be a valid pointer or null.
1203    #[doc(alias = "SecKeychainAddGenericPassword")]
1204    #[cfg(feature = "SecBase")]
1205    #[deprecated = "SecKeychain is deprecated"]
1206    #[inline]
1207    pub unsafe fn add_generic_password(
1208        keychain: Option<&SecKeychain>,
1209        service_name_length: u32,
1210        service_name: *const c_char,
1211        account_name_length: u32,
1212        account_name: *const c_char,
1213        password_length: u32,
1214        password_data: NonNull<c_void>,
1215        item_ref: *mut *mut SecKeychainItem,
1216    ) -> OSStatus {
1217        extern "C-unwind" {
1218            fn SecKeychainAddGenericPassword(
1219                keychain: Option<&SecKeychain>,
1220                service_name_length: u32,
1221                service_name: *const c_char,
1222                account_name_length: u32,
1223                account_name: *const c_char,
1224                password_length: u32,
1225                password_data: NonNull<c_void>,
1226                item_ref: *mut *mut SecKeychainItem,
1227            ) -> OSStatus;
1228        }
1229        unsafe {
1230            SecKeychainAddGenericPassword(
1231                keychain,
1232                service_name_length,
1233                service_name,
1234                account_name_length,
1235                account_name,
1236                password_length,
1237                password_data,
1238                item_ref,
1239            )
1240        }
1241    }
1242
1243    /// Find a generic password based on the attributes passed.
1244    ///
1245    /// Parameter `keychainOrArray`: A reference to an array of keychains to search, a single keychain, or NULL to search the user's default keychain search list.
1246    ///
1247    /// Parameter `serviceNameLength`: The length of the buffer pointed to by serviceName.
1248    ///
1249    /// Parameter `serviceName`: A pointer to a string containing the service name.
1250    ///
1251    /// Parameter `accountNameLength`: The length of the buffer pointed to by accountName.
1252    ///
1253    /// Parameter `accountName`: A pointer to a string containing the account name.
1254    ///
1255    /// Parameter `passwordLength`: On return, the length of the buffer pointed to by passwordData.
1256    ///
1257    /// Parameter `passwordData`: On return, a pointer to a data buffer containing the password. Your application must call SecKeychainItemFreeContent(NULL, passwordData) to release this data buffer when it is no longer needed. Pass NULL if you are not interested in retrieving the password data at this time, but simply want to find the item reference.
1258    ///
1259    /// Parameter `itemRef`: On return, a reference to the keychain item which was found.
1260    ///
1261    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1262    ///
1263    /// The SecKeychainFindGenericPassword function finds the first generic password item which matches the attributes you provide. Most attributes are optional; you should pass only as many as you need to narrow the search sufficiently for your application's intended use. SecKeychainFindGenericPassword optionally returns a reference to the found item.
1264    ///
1265    /// # Safety
1266    ///
1267    /// - `keychain_or_array` should be of the correct type.
1268    /// - `service_name` must be a valid pointer or null.
1269    /// - `account_name` must be a valid pointer or null.
1270    /// - `password_length` must be a valid pointer or null.
1271    /// - `password_data` must be a valid pointer or null.
1272    /// - `item_ref` must be a valid pointer or null.
1273    #[doc(alias = "SecKeychainFindGenericPassword")]
1274    #[cfg(feature = "SecBase")]
1275    #[deprecated = "SecKeychain is deprecated"]
1276    #[inline]
1277    pub unsafe fn find_generic_password(
1278        keychain_or_array: Option<&CFType>,
1279        service_name_length: u32,
1280        service_name: *const c_char,
1281        account_name_length: u32,
1282        account_name: *const c_char,
1283        password_length: *mut u32,
1284        password_data: *mut *mut c_void,
1285        item_ref: *mut *mut SecKeychainItem,
1286    ) -> OSStatus {
1287        extern "C-unwind" {
1288            fn SecKeychainFindGenericPassword(
1289                keychain_or_array: Option<&CFType>,
1290                service_name_length: u32,
1291                service_name: *const c_char,
1292                account_name_length: u32,
1293                account_name: *const c_char,
1294                password_length: *mut u32,
1295                password_data: *mut *mut c_void,
1296                item_ref: *mut *mut SecKeychainItem,
1297            ) -> OSStatus;
1298        }
1299        unsafe {
1300            SecKeychainFindGenericPassword(
1301                keychain_or_array,
1302                service_name_length,
1303                service_name,
1304                account_name_length,
1305                account_name,
1306                password_length,
1307                password_data,
1308                item_ref,
1309            )
1310        }
1311    }
1312
1313    /// Turns on or off any optional user interaction
1314    ///
1315    /// Parameter `state`: A boolean representing the state of user interaction.  You should pass TRUE to allow user interaction, and FALSE to disallow user interaction
1316    ///
1317    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1318    #[doc(alias = "SecKeychainSetUserInteractionAllowed")]
1319    #[deprecated = "SecKeychain is deprecated"]
1320    #[inline]
1321    pub unsafe fn set_user_interaction_allowed(state: bool) -> OSStatus {
1322        extern "C-unwind" {
1323            fn SecKeychainSetUserInteractionAllowed(state: Boolean) -> OSStatus;
1324        }
1325        unsafe { SecKeychainSetUserInteractionAllowed(state as _) }
1326    }
1327
1328    /// Retrieves the current state of user interaction.
1329    ///
1330    /// Parameter `state`: On return, a pointer to the current state of user interaction.  If this is TRUE then user interaction is allowed, if it is FALSE, then user interaction is not allowed.
1331    ///
1332    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1333    ///
1334    /// # Safety
1335    ///
1336    /// `state` must be a valid pointer.
1337    #[doc(alias = "SecKeychainGetUserInteractionAllowed")]
1338    #[deprecated = "SecKeychain is deprecated"]
1339    #[inline]
1340    pub unsafe fn user_interaction_allowed(state: NonNull<Boolean>) -> OSStatus {
1341        extern "C-unwind" {
1342            fn SecKeychainGetUserInteractionAllowed(state: NonNull<Boolean>) -> OSStatus;
1343        }
1344        unsafe { SecKeychainGetUserInteractionAllowed(state) }
1345    }
1346
1347    /// Returns the CSSM_CSP_HANDLE attachment for the given keychain reference. The handle is valid until the keychain reference is released.
1348    ///
1349    /// Parameter `keychain`: A keychain reference.
1350    ///
1351    /// Parameter `cspHandle`: On return, a pointer to the CSSM_CSP_HANDLE for the given keychain.
1352    ///
1353    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1354    ///
1355    /// This API is deprecated for 10.7. It should nho longer be needed.
1356    ///
1357    /// # Safety
1358    ///
1359    /// `csp_handle` must be a valid pointer.
1360    #[doc(alias = "SecKeychainGetCSPHandle")]
1361    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
1362    #[deprecated]
1363    #[inline]
1364    pub unsafe fn csp_handle(
1365        keychain: Option<&SecKeychain>,
1366        csp_handle: NonNull<CSSM_CSP_HANDLE>,
1367    ) -> OSStatus {
1368        extern "C-unwind" {
1369            fn SecKeychainGetCSPHandle(
1370                keychain: Option<&SecKeychain>,
1371                csp_handle: NonNull<CSSM_CSP_HANDLE>,
1372            ) -> OSStatus;
1373        }
1374        unsafe { SecKeychainGetCSPHandle(keychain, csp_handle) }
1375    }
1376
1377    /// Returns the CSSM_DL_DB_HANDLE for a given keychain reference. The handle is valid until the keychain reference is released.
1378    ///
1379    /// Parameter `keychain`: A keychain reference.
1380    ///
1381    /// Parameter `dldbHandle`: On return, a pointer to the CSSM_DL_DB_HANDLE for the given keychain.
1382    ///
1383    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1384    ///
1385    /// This API is deprecated for 10.7. It should nho longer be needed.
1386    ///
1387    /// # Safety
1388    ///
1389    /// `dldb_handle` must be a valid pointer.
1390    #[doc(alias = "SecKeychainGetDLDBHandle")]
1391    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
1392    #[deprecated]
1393    #[inline]
1394    pub unsafe fn dldb_handle(
1395        keychain: Option<&SecKeychain>,
1396        dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
1397    ) -> OSStatus {
1398        extern "C-unwind" {
1399            fn SecKeychainGetDLDBHandle(
1400                keychain: Option<&SecKeychain>,
1401                dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
1402            ) -> OSStatus;
1403        }
1404        unsafe { SecKeychainGetDLDBHandle(keychain, dldb_handle) }
1405    }
1406
1407    /// Retrieves the access for a keychain.
1408    ///
1409    /// Parameter `keychain`: A reference to the keychain from which to copy the access.
1410    ///
1411    /// Parameter `access`: On return, a pointer to the access reference.
1412    ///
1413    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1414    ///
1415    /// # Safety
1416    ///
1417    /// `access` must be a valid pointer.
1418    #[doc(alias = "SecKeychainCopyAccess")]
1419    #[cfg(feature = "SecBase")]
1420    #[deprecated = "SecKeychain is deprecated"]
1421    #[inline]
1422    pub unsafe fn copy_access(
1423        keychain: Option<&SecKeychain>,
1424        access: NonNull<*mut SecAccess>,
1425    ) -> OSStatus {
1426        extern "C-unwind" {
1427            fn SecKeychainCopyAccess(
1428                keychain: Option<&SecKeychain>,
1429                access: NonNull<*mut SecAccess>,
1430            ) -> OSStatus;
1431        }
1432        unsafe { SecKeychainCopyAccess(keychain, access) }
1433    }
1434
1435    /// Sets the access for a keychain.
1436    ///
1437    /// Parameter `keychain`: A reference to the keychain for which to set the access.
1438    ///
1439    /// Parameter `access`: An access reference.
1440    ///
1441    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
1442    #[doc(alias = "SecKeychainSetAccess")]
1443    #[cfg(feature = "SecBase")]
1444    #[deprecated = "SecKeychain is deprecated"]
1445    #[inline]
1446    pub unsafe fn set_access(keychain: Option<&SecKeychain>, access: &SecAccess) -> OSStatus {
1447        extern "C-unwind" {
1448            fn SecKeychainSetAccess(keychain: Option<&SecKeychain>, access: &SecAccess)
1449                -> OSStatus;
1450        }
1451        unsafe { SecKeychainSetAccess(keychain, access) }
1452    }
1453}
1454
1455extern "C-unwind" {
1456    #[deprecated = "renamed to `SecKeychain::version`"]
1457    pub fn SecKeychainGetVersion(return_vers: NonNull<u32>) -> OSStatus;
1458}
1459
1460extern "C-unwind" {
1461    #[cfg(feature = "SecBase")]
1462    #[deprecated = "renamed to `SecKeychain::open`"]
1463    pub fn SecKeychainOpen(
1464        path_name: NonNull<c_char>,
1465        keychain: NonNull<*mut SecKeychain>,
1466    ) -> OSStatus;
1467}
1468
1469#[cfg(feature = "SecBase")]
1470#[deprecated = "renamed to `SecKeychain::create`"]
1471#[inline]
1472pub unsafe extern "C-unwind" fn SecKeychainCreate(
1473    path_name: NonNull<c_char>,
1474    password_length: u32,
1475    password: *const c_void,
1476    prompt_user: bool,
1477    initial_access: Option<&SecAccess>,
1478    keychain: NonNull<*mut SecKeychain>,
1479) -> OSStatus {
1480    extern "C-unwind" {
1481        fn SecKeychainCreate(
1482            path_name: NonNull<c_char>,
1483            password_length: u32,
1484            password: *const c_void,
1485            prompt_user: Boolean,
1486            initial_access: Option<&SecAccess>,
1487            keychain: NonNull<*mut SecKeychain>,
1488        ) -> OSStatus;
1489    }
1490    unsafe {
1491        SecKeychainCreate(
1492            path_name,
1493            password_length,
1494            password,
1495            prompt_user as _,
1496            initial_access,
1497            keychain,
1498        )
1499    }
1500}
1501
1502extern "C-unwind" {
1503    #[cfg(feature = "SecBase")]
1504    #[deprecated = "renamed to `SecKeychain::delete`"]
1505    pub fn SecKeychainDelete(keychain_or_array: Option<&SecKeychain>) -> OSStatus;
1506}
1507
1508extern "C-unwind" {
1509    #[cfg(feature = "SecBase")]
1510    #[deprecated = "renamed to `SecKeychain::set_settings`"]
1511    pub fn SecKeychainSetSettings(
1512        keychain: Option<&SecKeychain>,
1513        new_settings: NonNull<SecKeychainSettings>,
1514    ) -> OSStatus;
1515}
1516
1517extern "C-unwind" {
1518    #[cfg(feature = "SecBase")]
1519    #[deprecated = "renamed to `SecKeychain::copy_settings`"]
1520    pub fn SecKeychainCopySettings(
1521        keychain: Option<&SecKeychain>,
1522        out_settings: NonNull<SecKeychainSettings>,
1523    ) -> OSStatus;
1524}
1525
1526#[cfg(feature = "SecBase")]
1527#[deprecated = "renamed to `SecKeychain::unlock`"]
1528#[inline]
1529pub unsafe extern "C-unwind" fn SecKeychainUnlock(
1530    keychain: Option<&SecKeychain>,
1531    password_length: u32,
1532    password: *const c_void,
1533    use_password: bool,
1534) -> OSStatus {
1535    extern "C-unwind" {
1536        fn SecKeychainUnlock(
1537            keychain: Option<&SecKeychain>,
1538            password_length: u32,
1539            password: *const c_void,
1540            use_password: Boolean,
1541        ) -> OSStatus;
1542    }
1543    unsafe { SecKeychainUnlock(keychain, password_length, password, use_password as _) }
1544}
1545
1546extern "C-unwind" {
1547    #[cfg(feature = "SecBase")]
1548    #[deprecated = "renamed to `SecKeychain::lock`"]
1549    pub fn SecKeychainLock(keychain: Option<&SecKeychain>) -> OSStatus;
1550}
1551
1552extern "C-unwind" {
1553    #[deprecated = "renamed to `SecKeychain::lock_all`"]
1554    pub fn SecKeychainLockAll() -> OSStatus;
1555}
1556
1557extern "C-unwind" {
1558    #[cfg(feature = "SecBase")]
1559    #[deprecated = "renamed to `SecKeychain::copy_default`"]
1560    pub fn SecKeychainCopyDefault(keychain: NonNull<*mut SecKeychain>) -> OSStatus;
1561}
1562
1563extern "C-unwind" {
1564    #[cfg(feature = "SecBase")]
1565    #[deprecated = "renamed to `SecKeychain::set_default`"]
1566    pub fn SecKeychainSetDefault(keychain: Option<&SecKeychain>) -> OSStatus;
1567}
1568
1569extern "C-unwind" {
1570    #[deprecated = "renamed to `SecKeychain::copy_search_list`"]
1571    pub fn SecKeychainCopySearchList(search_list: NonNull<*const CFArray>) -> OSStatus;
1572}
1573
1574extern "C-unwind" {
1575    #[deprecated = "renamed to `SecKeychain::set_search_list`"]
1576    pub fn SecKeychainSetSearchList(search_list: &CFArray) -> OSStatus;
1577}
1578
1579extern "C-unwind" {
1580    #[cfg(feature = "SecBase")]
1581    #[deprecated = "renamed to `SecKeychain::copy_domain_default`"]
1582    pub fn SecKeychainCopyDomainDefault(
1583        domain: SecPreferencesDomain,
1584        keychain: NonNull<*mut SecKeychain>,
1585    ) -> OSStatus;
1586}
1587
1588extern "C-unwind" {
1589    #[cfg(feature = "SecBase")]
1590    #[deprecated = "renamed to `SecKeychain::set_domain_default`"]
1591    pub fn SecKeychainSetDomainDefault(
1592        domain: SecPreferencesDomain,
1593        keychain: Option<&SecKeychain>,
1594    ) -> OSStatus;
1595}
1596
1597extern "C-unwind" {
1598    #[deprecated = "renamed to `SecKeychain::copy_domain_search_list`"]
1599    pub fn SecKeychainCopyDomainSearchList(
1600        domain: SecPreferencesDomain,
1601        search_list: NonNull<*const CFArray>,
1602    ) -> OSStatus;
1603}
1604
1605extern "C-unwind" {
1606    #[deprecated = "renamed to `SecKeychain::set_domain_search_list`"]
1607    pub fn SecKeychainSetDomainSearchList(
1608        domain: SecPreferencesDomain,
1609        search_list: &CFArray,
1610    ) -> OSStatus;
1611}
1612
1613extern "C-unwind" {
1614    #[deprecated = "renamed to `SecKeychain::set_preference_domain`"]
1615    pub fn SecKeychainSetPreferenceDomain(domain: SecPreferencesDomain) -> OSStatus;
1616}
1617
1618extern "C-unwind" {
1619    #[deprecated = "renamed to `SecKeychain::preference_domain`"]
1620    pub fn SecKeychainGetPreferenceDomain(domain: NonNull<SecPreferencesDomain>) -> OSStatus;
1621}
1622
1623extern "C-unwind" {
1624    #[cfg(feature = "SecBase")]
1625    #[deprecated = "renamed to `SecKeychain::status`"]
1626    pub fn SecKeychainGetStatus(
1627        keychain: Option<&SecKeychain>,
1628        keychain_status: NonNull<SecKeychainStatus>,
1629    ) -> OSStatus;
1630}
1631
1632extern "C-unwind" {
1633    #[cfg(feature = "SecBase")]
1634    #[deprecated = "renamed to `SecKeychain::path`"]
1635    pub fn SecKeychainGetPath(
1636        keychain: Option<&SecKeychain>,
1637        io_path_length: NonNull<u32>,
1638        path_name: NonNull<c_char>,
1639    ) -> OSStatus;
1640}
1641
1642extern "C-unwind" {
1643    #[cfg(feature = "SecBase")]
1644    #[deprecated = "renamed to `SecKeychain::attribute_info_for_item_id`"]
1645    pub fn SecKeychainAttributeInfoForItemID(
1646        keychain: Option<&SecKeychain>,
1647        item_id: u32,
1648        info: NonNull<*mut SecKeychainAttributeInfo>,
1649    ) -> OSStatus;
1650}
1651
1652extern "C-unwind" {
1653    #[cfg(feature = "SecBase")]
1654    #[deprecated = "renamed to `SecKeychain::free_attribute_info`"]
1655    pub fn SecKeychainFreeAttributeInfo(info: NonNull<SecKeychainAttributeInfo>) -> OSStatus;
1656}
1657
1658extern "C-unwind" {
1659    #[cfg(all(feature = "SecBase", feature = "libc"))]
1660    #[deprecated = "renamed to `SecKeychain::add_callback`"]
1661    pub fn SecKeychainAddCallback(
1662        callback_function: SecKeychainCallback,
1663        event_mask: SecKeychainEventMask,
1664        user_context: *mut c_void,
1665    ) -> OSStatus;
1666}
1667
1668extern "C-unwind" {
1669    #[cfg(all(feature = "SecBase", feature = "libc"))]
1670    #[deprecated = "renamed to `SecKeychain::remove_callback`"]
1671    pub fn SecKeychainRemoveCallback(callback_function: SecKeychainCallback) -> OSStatus;
1672}
1673
1674extern "C-unwind" {
1675    #[cfg(feature = "SecBase")]
1676    #[deprecated = "renamed to `SecKeychain::add_internet_password`"]
1677    pub fn SecKeychainAddInternetPassword(
1678        keychain: Option<&SecKeychain>,
1679        server_name_length: u32,
1680        server_name: *const c_char,
1681        security_domain_length: u32,
1682        security_domain: *const c_char,
1683        account_name_length: u32,
1684        account_name: *const c_char,
1685        path_length: u32,
1686        path: *const c_char,
1687        port: u16,
1688        protocol: SecProtocolType,
1689        authentication_type: SecAuthenticationType,
1690        password_length: u32,
1691        password_data: NonNull<c_void>,
1692        item_ref: *mut *mut SecKeychainItem,
1693    ) -> OSStatus;
1694}
1695
1696extern "C-unwind" {
1697    #[cfg(feature = "SecBase")]
1698    #[deprecated = "renamed to `SecKeychain::find_internet_password`"]
1699    pub fn SecKeychainFindInternetPassword(
1700        keychain_or_array: Option<&CFType>,
1701        server_name_length: u32,
1702        server_name: *const c_char,
1703        security_domain_length: u32,
1704        security_domain: *const c_char,
1705        account_name_length: u32,
1706        account_name: *const c_char,
1707        path_length: u32,
1708        path: *const c_char,
1709        port: u16,
1710        protocol: SecProtocolType,
1711        authentication_type: SecAuthenticationType,
1712        password_length: *mut u32,
1713        password_data: *mut *mut c_void,
1714        item_ref: *mut *mut SecKeychainItem,
1715    ) -> OSStatus;
1716}
1717
1718extern "C-unwind" {
1719    #[cfg(feature = "SecBase")]
1720    #[deprecated = "renamed to `SecKeychain::add_generic_password`"]
1721    pub fn SecKeychainAddGenericPassword(
1722        keychain: Option<&SecKeychain>,
1723        service_name_length: u32,
1724        service_name: *const c_char,
1725        account_name_length: u32,
1726        account_name: *const c_char,
1727        password_length: u32,
1728        password_data: NonNull<c_void>,
1729        item_ref: *mut *mut SecKeychainItem,
1730    ) -> OSStatus;
1731}
1732
1733extern "C-unwind" {
1734    #[cfg(feature = "SecBase")]
1735    #[deprecated = "renamed to `SecKeychain::find_generic_password`"]
1736    pub fn SecKeychainFindGenericPassword(
1737        keychain_or_array: Option<&CFType>,
1738        service_name_length: u32,
1739        service_name: *const c_char,
1740        account_name_length: u32,
1741        account_name: *const c_char,
1742        password_length: *mut u32,
1743        password_data: *mut *mut c_void,
1744        item_ref: *mut *mut SecKeychainItem,
1745    ) -> OSStatus;
1746}
1747
1748#[deprecated = "renamed to `SecKeychain::set_user_interaction_allowed`"]
1749#[inline]
1750pub unsafe extern "C-unwind" fn SecKeychainSetUserInteractionAllowed(state: bool) -> OSStatus {
1751    extern "C-unwind" {
1752        fn SecKeychainSetUserInteractionAllowed(state: Boolean) -> OSStatus;
1753    }
1754    unsafe { SecKeychainSetUserInteractionAllowed(state as _) }
1755}
1756
1757extern "C-unwind" {
1758    #[deprecated = "renamed to `SecKeychain::user_interaction_allowed`"]
1759    pub fn SecKeychainGetUserInteractionAllowed(state: NonNull<Boolean>) -> OSStatus;
1760}
1761
1762extern "C-unwind" {
1763    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
1764    #[deprecated = "renamed to `SecKeychain::csp_handle`"]
1765    pub fn SecKeychainGetCSPHandle(
1766        keychain: Option<&SecKeychain>,
1767        csp_handle: NonNull<CSSM_CSP_HANDLE>,
1768    ) -> OSStatus;
1769}
1770
1771extern "C-unwind" {
1772    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
1773    #[deprecated = "renamed to `SecKeychain::dldb_handle`"]
1774    pub fn SecKeychainGetDLDBHandle(
1775        keychain: Option<&SecKeychain>,
1776        dldb_handle: NonNull<CSSM_DL_DB_HANDLE>,
1777    ) -> OSStatus;
1778}
1779
1780extern "C-unwind" {
1781    #[cfg(feature = "SecBase")]
1782    #[deprecated = "renamed to `SecKeychain::copy_access`"]
1783    pub fn SecKeychainCopyAccess(
1784        keychain: Option<&SecKeychain>,
1785        access: NonNull<*mut SecAccess>,
1786    ) -> OSStatus;
1787}
1788
1789extern "C-unwind" {
1790    #[cfg(feature = "SecBase")]
1791    #[deprecated = "renamed to `SecKeychain::set_access`"]
1792    pub fn SecKeychainSetAccess(keychain: Option<&SecKeychain>, access: &SecAccess) -> OSStatus;
1793}