keychain/lib.rs
1//! Reading and writing macOS `.keychain` database files directly.
2//!
3//! This is the CDSA-era keychain format — the one `security create-keychain`
4//! still writes on macOS 26 — parsed and produced without the Security
5//! framework, so it works on any host and needs no entitlements.
6//!
7//! * [`mod@format`] is the `kych` container: tables, records, attribute values.
8//! * [`schema`] is the self-describing schema every keychain carries.
9//! * [`crypto`] is the encryption the container specification omits.
10//! * [`db`] ties them together: open, unlock, query, decrypt.
11//! * [`query`] defines typed, composable predicates shared with `kc get`.
12//! * [`mod@write`] creates keychains and adds items.
13//! * [`edit`] updates, deletes, re-seals and re-authorizes what is already there.
14//!
15//! See `README.md` for the format notes and the security caveats.
16
17pub mod access;
18pub mod acl;
19pub mod apple_schema;
20pub mod crypto;
21pub mod cssm;
22pub mod db;
23pub mod der;
24pub mod edit;
25pub mod error;
26pub mod format;
27pub mod index;
28pub mod locator;
29pub mod output;
30pub mod pkcs12;
31pub mod query;
32pub mod records;
33pub mod schema;
34pub mod secret;
35pub mod write;
36
37pub use access::{AccessDecision, AccessDefault, AccessMode, AccessPolicy};
38pub use acl::{AclBlob, ApplicationAccess, TrustedApplication};
39pub use db::{Info, Item, ItemRef, KeychainFile, Query};
40pub use der::decode_private_key;
41pub use edit::{ItemChanges, Settings, StoredIdentity};
42pub use error::{Error, Result};
43pub use format::{Keychain, Record, Value};
44pub use locator::{KeychainLocator, SYSTEM_KEYCHAIN};
45pub use pkcs12::{
46 Identity as Pkcs12Identity, decode as decode_pkcs12, decode_identity, encode as encode_pkcs12,
47 is_combined_pem,
48};
49pub use query::{Comparison, Expression, MatchOptions, Predicate};
50pub use schema::{AttributeFormat, RecordType, Schema};
51pub use write::{CreateOptions, NewIdentity, NewItem, create, now_timestamp};
52
53/// Reading an application's designated requirement out of its code signature.
54///
55/// Needed to name a trusted application in an item's ACL: the ACL embeds the
56/// application's requirement blob verbatim. Gated behind the `trust-apps`
57/// feature, which pulls in the `macho-codesign` crate; without it, a requirement
58/// can still be supplied as bytes (`csreq -b` output).
59pub mod requirement;