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) -> Selfwhere 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

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

§

type Error = CryptoError

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.