···11+//! iOS Keychain storage for identity-wallet credentials.
22+//!
33+//! All items are stored as `kSecClassGenericPassword` under
44+//! service `"ezpds-identity-wallet"`. Use the `SERVICE` constant
55+//! to ensure consistency.
66+77+// Suppressed until Phase 2 wires up the IPC command that calls these functions.
88+#![allow(dead_code)]
99+1010+use security_framework::passwords::{get_generic_password, set_generic_password};
1111+1212+pub const SERVICE: &str = "ezpds-identity-wallet";
1313+1414+#[derive(Debug, thiserror::Error)]
1515+pub enum KeychainError {
1616+ #[error("keychain error: {0}")]
1717+ Security(#[from] security_framework::base::Error),
1818+}
1919+2020+/// Store arbitrary bytes in the Keychain under the given account name.
2121+///
2222+/// Creates the entry if it doesn't exist, or updates it if it does.
2323+pub fn store_item(account: &str, data: &[u8]) -> Result<(), KeychainError> {
2424+ set_generic_password(SERVICE, account, data).map_err(KeychainError::Security)
2525+}
2626+2727+/// Retrieve bytes from the Keychain for the given account name.
2828+///
2929+/// Returns `Err` with `errSecItemNotFound` if no entry exists.
3030+pub fn get_item(account: &str) -> Result<Vec<u8>, KeychainError> {
3131+ get_generic_password(SERVICE, account).map_err(KeychainError::Security)
3232+}