pub(super) struct Keychain {
aes: HashMap<String, AesKey>,
rsa: HashMap<String, RsaKey>,
}Expand description
A store of AES and RSA keys keyed by their kid.
Fields§
§aes: HashMap<String, AesKey>§rsa: HashMap<String, RsaKey>Implementations§
Source§impl Keychain
impl Keychain
pub(super) fn new() -> Keychain
pub(super) fn add_aes(&mut self, key: AesKey)
pub(super) fn add_rsa(&mut self, key: RsaKey)
Sourcepub(super) fn decrypt(
&self,
encrypted: &Encrypted,
) -> Result<Vec<u8>, OnePasswordError>
pub(super) fn decrypt( &self, encrypted: &Encrypted, ) -> Result<Vec<u8>, OnePasswordError>
Decrypts an envelope by dispatching on its scheme to the AES or RSA key named by its kid.
Sourcepub(super) fn can_decrypt(
&self,
encrypted: &Encrypted,
) -> Result<bool, OnePasswordError>
pub(super) fn can_decrypt( &self, encrypted: &Encrypted, ) -> Result<bool, OnePasswordError>
Whether the keychain currently holds the key needed to decrypt this envelope.
A scheme this module does not implement is an error, not a false: the caller cannot tell
“we lack the key” from “we cannot read this format” otherwise, and would silently drop data.
Sourcepub(super) fn decrypt_json<T: DeserializeOwned>(
&self,
envelope: &EncryptedEnvelope,
) -> Result<T, OnePasswordError>
pub(super) fn decrypt_json<T: DeserializeOwned>( &self, envelope: &EncryptedEnvelope, ) -> Result<T, OnePasswordError>
Decrypts an envelope and parses its JSON plaintext.
Sourcepub(super) fn decrypt_keysets(
&mut self,
keysets: &[KeysetInfo],
username: &str,
password: &str,
account_key: &AccountKey,
) -> Result<(), OnePasswordError>
pub(super) fn decrypt_keysets( &mut self, keysets: &[KeysetInfo], username: &str, password: &str, account_key: &AccountKey, ) -> Result<(), OnePasswordError>
Derives the master key from the credentials, then decrypts every keyset into the keychain.
Sourcefn decrypt_reachable(
&mut self,
keysets: &[KeysetInfo],
root_key: AesKey,
) -> Result<(), OnePasswordError>
fn decrypt_reachable( &mut self, keysets: &[KeysetInfo], root_key: AesKey, ) -> Result<(), OnePasswordError>
Seeds root_key and decrypts everything reachable from it.
Sourcefn decrypt_keyset(
&mut self,
keyset: &KeysetInfo,
) -> Result<(), OnePasswordError>
fn decrypt_keyset( &mut self, keyset: &KeysetInfo, ) -> Result<(), OnePasswordError>
Decrypts a keyset’s symmetric key then its private key into the keychain.
Sourcepub(super) fn decrypt_aes_key(
&mut self,
envelope: &EncryptedEnvelope,
) -> Result<(), OnePasswordError>
pub(super) fn decrypt_aes_key( &mut self, envelope: &EncryptedEnvelope, ) -> Result<(), OnePasswordError>
Decrypts an encrypted AES key and adds it to the keychain.
Sourcefn decrypt_rsa_key(
&mut self,
envelope: &EncryptedEnvelope,
) -> Result<(), OnePasswordError>
fn decrypt_rsa_key( &mut self, envelope: &EncryptedEnvelope, ) -> Result<(), OnePasswordError>
Decrypts an encrypted RSA key and adds it to the keychain.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Keychain
impl RefUnwindSafe for Keychain
impl Send for Keychain
impl Sync for Keychain
impl Unpin for Keychain
impl UnsafeUnpin for Keychain
impl UnwindSafe for Keychain
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more