Skip to main content

Crate keychain_core

Crate keychain_core 

Source
Expand description

Pure-Rust, byte-oriented offline reader for macOS login.keychain-db.

keychain-core parses Apple’s AppleDatabase keychain container and, given the account login password, decrypts generic-password secrets — the macOS analogue of Windows DPAPI offline recovery. This includes the Chromium Safe Storage key (service Chrome Safe Storage), which unlocks Chrome / Edge cookie and login databases on a mounted, acquired disk.

Every entry point takes &[u8] and performs no I/O, so the same code serves a live file, a file carved from a disk image, or a byte buffer from memory.

The unlock chain (all via audited RustCrypto crates — no hand-rolled math):

  1. master = PBKDF2-HMAC-SHA1(password, DbBlob.salt, 1000, dklen=24);
  2. DBKey = 3DES-EDE3-CBC-decrypt of the DbBlob ciphertext under master;
  3. each per-record key is CMS-unwrapped from the symmetric-key table;
  4. each secret is 3DES-CBC-decrypted with its per-record key.

A wrong or absent password is reported as KeychainError::Locked — the store is present-but-locked, never a fabricated secret.

Format reference: the community chainbreaker tool (n0fate) and Apple’s open-source securityd / libsecurity_cdsa_*.

Re-exports§

pub use container::Container;
pub use container::DbBlob;
pub use container::GenericRecord;
pub use container::KeyBlobRecord;
pub use container::SsgpBlob;
pub use container::COMMON_BLOB_MAGIC;
pub use container::KEYCHAIN_SIGNATURE;
pub use container::RECORD_GENERIC_PASSWORD;
pub use container::RECORD_METADATA;
pub use container::RECORD_SYMMETRIC_KEY;
pub use crypto::derive_master_key;
pub use crypto::kcdecrypt;
pub use crypto::unwrap_key_blob;
pub use crypto::MAGIC_CMS_IV;
pub use crypto::MASTER_KEY_LEN;
pub use crypto::PBKDF2_ROUNDS;
pub use error::KeychainError;
pub use keychain::GenericSecret;
pub use keychain::Keychain;
pub use keychain::UnlockedKeychain;

Modules§

container
The Apple AppleDatabase container that backs a login.keychain-db.
crypto
Cryptographic primitives for login.keychain-db, all via audited RustCrypto crates — no hand-rolled math.
error
Error type shared across the keychain container parser, the crypto layer, and the high-level decryptor.
keychain
The high-level offline decryptor: open a login.keychain-db, unlock it with the login password, and recover generic-password secrets.