pub struct KeychainFile { /* private fields */ }Expand description
A keychain database, optionally unlocked.
Implementations§
Source§impl KeychainFile
impl KeychainFile
pub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn path(&self) -> Option<&Path>
pub fn keychain(&self) -> &Keychain
pub fn schema(&self) -> &Schema
pub fn is_unlocked(&self) -> bool
Sourcepub fn db_blob(&self) -> Result<DbBlob>
pub fn db_blob(&self) -> Result<DbBlob>
The database blob, which holds the salt and the encrypted database keys.
Sourcepub fn unlock(&mut self, password: &[u8]) -> Result<()>
pub fn unlock(&mut self, password: &[u8]) -> Result<()>
Derive the database keys from a password and unwrap every item key.
Sourcepub fn item_key_count(&self) -> usize
pub fn item_key_count(&self) -> usize
Number of item keys recovered by Self::unlock.
pub fn items_of_type(&self, record_type: RecordType) -> Vec<Item<'_>>
Sourcepub fn records_of_type(&self, record_type: RecordType) -> Vec<&Record>
pub fn records_of_type(&self, record_type: RecordType) -> Vec<&Record>
Records of any relation, for kc show --all.
Sourcepub fn secret(&self, item: &Item<'_>) -> Result<SecretBytes>
pub fn secret(&self, item: &Item<'_>) -> Result<SecretBytes>
Decrypt an item’s secret. Requires an unlocked keychain.
Sourcepub fn find_one(&self, query: &Query) -> Result<Item<'_>>
pub fn find_one(&self, query: &Query) -> Result<Item<'_>>
Exactly one match, or an error naming the ambiguity.
Sourcepub fn save_in_place(&self) -> Result<()>
pub fn save_in_place(&self) -> Result<()>
Write back to the path this was opened from.
Source§impl KeychainFile
impl KeychainFile
Sourcepub fn add_password(
&mut self,
record_type: RecordType,
item: &NewItem,
secret: &[u8],
timestamp: &str,
) -> Result<()>
pub fn add_password( &mut self, record_type: RecordType, item: &NewItem, secret: &[u8], timestamp: &str, ) -> Result<()>
Store a password item, creating the item key that protects it.
Requires an unlocked keychain: the item key is wrapped with the database’s encryption key and both blobs are signed with its signing key.
Sourcepub fn add_identity(&mut self, identity: &NewIdentity) -> Result<[u8; 20]>
pub fn add_identity(&mut self, identity: &NewIdentity) -> Result<[u8; 20]>
Store an identity: the certificate in the clear, the private key wrapped.
The two records are linked by the certificate’s public key hash, which the
key record carries as its Label — that is how SecIdentity pairs them,
and how crate::db::KeychainFile and security both find
them.
Requires an unlocked keychain: the private key is wrapped with the database’s encryption key, and both blobs are signed with its signing key.