pub struct BareStreamKey { /* private fields */ }
Expand description

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

Implementations§

source§

impl BareStreamKey

source

pub fn new() -> Self

Generate a new random key.

source

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

Generate a new key, given a cryptographic RNG.

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

source§

fn default() -> Self

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

impl Drop for BareStreamKey

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl StreamInterface for BareStreamKey

source§

fn id(&self) -> &StreamId

Get the corresponding StreamId for the symmetric key.
source§

fn encrypt( &self, csprng: &mut dyn CryptoSrc, lock_type: LockboxType, content: &[u8] ) -> Vec<u8>

Encrypt raw data into a lockbox, following the StreamKey-recipient lockbox format (see lockbox.
source§

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

Decrypt a LockLockboxRef and return a temporary (not stored in Vault) LockKey on success.
source§

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

Decrypt a IdentityLockboxRef and return a temporary (not stored in Vault) IdentityKey on success.
source§

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

Decrypt a StreamLockboxRef and return a temporary (not stored in Vault) StreamKey on success.
source§

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

Decrypt a DataLockboxRef and return a the decoded raw data on success.
source§

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

Export the symmetric key in a StreamLockbox, 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<StreamLockbox>

Export the symmetric key in a StreamLockbox, with receive_stream as the recipient. If the key cannot be exported, this should return None. Additionally, if the underlying implementation does not allow moving the raw key into memory (i.e. it cannot call StreamInterface::encrypt or lock_id_encrypt) then None can also be returned.
source§

impl TryFrom<&[u8]> for BareStreamKey

§

type Error = CryptoError

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

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

Performs the conversion.

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.