BareLockKey

Struct BareLockKey 

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

A self-contained implementor of LockInterface. It’s expected this will be used unless the decryption key is being managed by the OS or a hardware module.

Implementations§

Source§

impl BareLockKey

Source

pub fn new() -> Self

Generate a random new key.

Source

pub fn with_rng<R>(csprng: &mut R) -> Self
where R: CryptoRng + RngCore,

Generate a new key given a cryptographic random number generator.

Source

pub fn with_rng_and_version<R>( csprng: &mut R, version: u8, ) -> Result<Self, CryptoError>
where R: CryptoRng + RngCore,

Generate a new key with a specific version, given a cryptographic random number generator. Fails if the version isn’t supported.

Source

pub fn encode_vec(&self, buf: &mut Vec<u8>)

Encode directly to a byte vector. The resulting vector should be zeroized or overwritten before being dropped.

Trait Implementations§

Source§

impl Default for BareLockKey

Available on crate feature getrandom only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl LockInterface for BareLockKey

Source§

fn id(&self) -> &LockId

Get the corresponding LockId for the private key.
Source§

fn decrypt_lock_key( &self, lockbox: &LockLockboxRef, ) -> Result<LockKey, CryptoError>

Decrypt an exported LockKey.
Source§

fn decrypt_identity_key( &self, lockbox: &IdentityLockboxRef, ) -> Result<IdentityKey, CryptoError>

Decrypt an exported IdentityKey.
Source§

fn decrypt_stream_key( &self, lockbox: &StreamLockboxRef, ) -> Result<StreamKey, CryptoError>

Decrypt an exported StreamKey.
Source§

fn decrypt_data(&self, lockbox: &DataLockboxRef) -> Result<Vec<u8>, CryptoError>

Decrypt encrypted data.
Source§

fn self_export_lock( &self, csprng: &mut dyn CryptoSrc, receive_lock: &LockId, ) -> Option<LockLockbox>

Export the decryption key in a LockLockbox, with receive_lock as the recipient. If the key cannot be exported, this should return None.
Source§

fn self_export_stream( &self, csprng: &mut dyn CryptoSrc, receive_stream: &StreamKey, ) -> Option<LockLockbox>

Export the decryption key in a LockLockbox, with receive_stream as the recipient. If the key cannot be exported, this should return None.
Source§

impl TryFrom<&[u8]> for BareLockKey

Source§

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Try to decode a raw byte sequence into a private

Source§

type Error = CryptoError

The type returned in the event of a conversion error.

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