Skip to main content

SymBlockCipherKey

Struct SymBlockCipherKey 

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

A symmetric block cipher key.

Associate the raw key material with a symmetric block cipher algorithm identifier.

May get instantiate either through key generation or from an existing raw key via TryFrom.

Implementations§

Source§

impl SymBlockCipherKey

Source

pub fn get_block_cipher_alg(&self) -> SymBlockCipherAlg

Get the key’s associated symmetric block cipher algorithm identifier.

Source

pub fn take_key(self) -> Zeroizing<Vec<u8>>

Take the key.

Source

pub fn generate( block_cipher_alg: SymBlockCipherAlg, rng: &mut dyn RngCoreDispatchable, additional_rng_generate_input: Option<&[Option<&[u8]>]>, ) -> Result<Self, CryptoError>

Generate a new block cipher key.

§Arguments:
  • block_cipher_alg - The block cipher algorithm to generate a key for.
  • rng - The random number generator to obtain key material from.
  • additional_rng_generate_input - Additional input to pass along to the rng’s generate() primitive.
Source

pub fn instantiate_block_cipher_mode_enc( &self, mode: TpmiAlgCipherMode, ) -> Result<SymBlockCipherModeEncryptionInstance, CryptoError>

Instantiate a block cipher mode encryption instance for the key.

§Arguments:
  • mode - The block cipher mode to instantiate an encryption instance with the key for.
Source

pub fn instantiate_block_cipher_mode_dec( &self, mode: TpmiAlgCipherMode, ) -> Result<SymBlockCipherModeDecryptionInstance, CryptoError>

Instantiate a block cipher mode decryption instance for the key.

§Arguments:
  • mode - The block cipher mode to instantiate an decryption instance with the key for.

Trait Implementations§

Source§

impl TryFrom<(SymBlockCipherAlg, &[u8])> for SymBlockCipherKey

Source§

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

Construct a SymBlockCipherKey from a pair of symmetric block cipher algorithm identifier and a raw key byte slice.

Source§

type Error = CryptoError

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

impl TryFrom<(SymBlockCipherAlg, Zeroizing<Vec<u8>>)> for SymBlockCipherKey

Source§

fn try_from( value: (SymBlockCipherAlg, Zeroizing<Vec<u8>>), ) -> Result<Self, Self::Error>

Destructure a SymBlockCipherKey into a pair of symmetric block cipher algorithm identifier and a raw key byte Vec.

Source§

type Error = CryptoError

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

impl ZeroizeOnDrop for SymBlockCipherKey

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.