Skip to main content

Unlocked

Struct Unlocked 

Source
pub struct Unlocked {
    pub user_key: SymmetricCryptoKey,
    pub private_key: Option<RsaPrivateKey>,
    pub org_keys: HashMap<String, SymmetricCryptoKey>,
    pub failed_orgs: Vec<String>,
    pub user_key_fingerprint: String,
}
Expand description

An unlocked account’s keys: the user key every personal cipher inherits, the account private key, and any organization keys the profile carries.

The caller (the workspace’s VaultSession) owns these and is responsible for locking them; this type is the plain hand-off from the unlock path.

Fields§

§user_key: SymmetricCryptoKey§private_key: Option<RsaPrivateKey>§org_keys: HashMap<String, SymmetricCryptoKey>§failed_orgs: Vec<String>

Organizations whose key the profile carries but this unlock could not unwrap. A cipher in one of them fails with VaultError::MissingKey rather than being encrypted or decrypted with the wrong key.

§user_key_fingerprint: String

SHA-256 of the wrapped user key this unlock used, so a later sync can prove the account’s keys did not rotate while the session was open.

Implementations§

Source§

impl Unlocked

Source

fn base_key<'a>( &'a self, cipher: &Value, ) -> Result<&'a SymmetricCryptoKey, VaultError>

The key a cipher inherits: its organization’s when it carries one, else the user key. A personal cipher is the common case; an organization cipher whose key was not unlocked is refused rather than silently falling back to the user key.

Source

pub fn decrypt_item_str( &self, cipher: &Value, enc: &str, ) -> Result<String, VaultError>

Decrypt one of a cipher’s encrypted fields with the cipher’s own key.

Source

pub fn encrypt_item_str( &self, cipher: &Value, value: &str, ) -> Result<String, VaultError>

Encrypt one of a cipher’s fields with the cipher’s own key.

Source

pub fn decrypt_user_str(&self, enc: &str) -> Result<String>

Decrypt a folder name or another value encrypted with the user key.

Source

pub fn encrypt_user_str(&self, value: &str) -> Result<String>

Encrypt a folder name or another value with the user key.

Source

pub fn prepare_attachment( &self, cipher: &Value, name: &str, data: &[u8], ) -> Result<(String, String, Vec<u8>), VaultError>

Prepare one attachment: a fresh key wrapped with the item key, the encrypted file name, and the 0x02 blob the server stores.

Source

pub fn open_attachment( &self, cipher: &Value, wrapped_key: &str, blob: &[u8], ) -> Result<Vec<u8>, VaultError>

Open one downloaded attachment: unwrap its key with the item key and decrypt the 0x02 blob.

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
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

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
§

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

§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more