Skip to main content

KeychainFile

Struct KeychainFile 

Source
pub struct KeychainFile { /* private fields */ }
Expand description

A keychain database, optionally unlocked.

Implementations§

Source§

impl KeychainFile

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Source

pub fn path(&self) -> Option<&Path>

Source

pub fn keychain(&self) -> &Keychain

Source

pub fn schema(&self) -> &Schema

Source

pub fn is_unlocked(&self) -> bool

Source

pub fn db_blob(&self) -> Result<DbBlob>

The database blob, which holds the salt and the encrypted database keys.

Source

pub fn unlock(&mut self, password: &[u8]) -> Result<()>

Derive the database keys from a password and unwrap every item key.

Source

pub fn item_key_count(&self) -> usize

Number of item keys recovered by Self::unlock.

Source

pub fn items(&self) -> Vec<Item<'_>>

Every password item in the keychain, in table order.

Source

pub fn items_of_type(&self, record_type: RecordType) -> Vec<Item<'_>>

Source

pub fn records_of_type(&self, record_type: RecordType) -> Vec<&Record>

Records of any relation, for kc show --all.

Source

pub fn secret(&self, item: &Item<'_>) -> Result<SecretBytes>

Decrypt an item’s secret. Requires an unlocked keychain.

Source

pub fn find(&self, query: &Query) -> Vec<Item<'_>>

Items matching every supplied criterion.

Source

pub fn find_one(&self, query: &Query) -> Result<Item<'_>>

Exactly one match, or an error naming the ambiguity.

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<()>

Write the database back out.

Source

pub fn save_in_place(&self) -> Result<()>

Write back to the path this was opened from.

Source§

impl KeychainFile

Source

pub fn info(&self) -> Result<Info>

Source§

impl KeychainFile

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V