Skip to main content

security_framework_sys/
keychain_item.rs

1#[cfg(target_os = "macos")]
2use crate::base::{SecKeychainAttributeList, SecKeychainItemRef};
3#[cfg(target_os = "macos")]
4use core_foundation_sys::base::CFTypeID;
5use core_foundation_sys::base::{CFTypeRef, OSStatus};
6use core_foundation_sys::dictionary::CFDictionaryRef;
7#[cfg(target_os = "macos")]
8use std::os::raw::c_void;
9
10extern "C" {
11
12    /// Returns the unique identifier of the opaque type to which a keychain item object belongs.
13    #[cfg(target_os = "macos")]
14    pub fn SecKeychainItemGetTypeID() -> CFTypeID;
15
16    /// Adds one or more items to a keychain.
17    pub fn SecItemAdd(attributes: CFDictionaryRef, result: *mut CFTypeRef) -> OSStatus;
18
19    /// Returns one or more keychain items that match a search query, or copies attributes of specific keychain items.
20    pub fn SecItemCopyMatching(query: CFDictionaryRef, result: *mut CFTypeRef) -> OSStatus;
21
22    /// Modifies items that match a search query.
23    pub fn SecItemUpdate(query: CFDictionaryRef, attributesToUpdate: CFDictionaryRef) -> OSStatus;
24
25    /// Deletes items that match a search query.
26    pub fn SecItemDelete(query: CFDictionaryRef) -> OSStatus;
27
28    /// # Legacy API
29    #[cfg(target_os = "macos")]
30    pub fn SecKeychainItemModifyAttributesAndData(
31        itemRef: SecKeychainItemRef,
32        attrList: *const SecKeychainAttributeList,
33        length: u32,
34        data: *const c_void,
35    ) -> OSStatus;
36
37    #[cfg(target_os = "macos")]
38    pub fn SecKeychainItemFreeContent(
39        attrList: *mut SecKeychainAttributeList,
40        data: *mut c_void,
41    ) -> OSStatus;
42
43    #[cfg(target_os = "macos")]
44    pub fn SecKeychainItemDelete(itemRef: SecKeychainItemRef) -> OSStatus;
45}