Skip to main content

SymBlockCipherModeDecryptionInstance

Struct SymBlockCipherModeDecryptionInstance 

Source
pub struct SymBlockCipherModeDecryptionInstance { /* private fields */ }

Implementations§

Source§

impl SymBlockCipherModeDecryptionInstance

Source

pub fn new( mode_id: TpmiAlgCipherMode, alg_id: &SymBlockCipherAlg, key: &[u8], ) -> Result<Self, CryptoError>

Instantiate a SymBlockCipherModeDecryptionInstance from a triplet of block cipher mode identifier, symmetric block cipher algorithm identifier and a raw key byte slice.

§Arguments:
Source

pub fn try_clone(&self) -> Result<Self, CryptoError>

Try to clone a SymBlockCipherDecryptionInstance.

Source

pub fn block_cipher_block_len(&self) -> usize

Obtain the instance’s associated block cipher algorithm’s block length.

Equivalent to SymBlockCipherAlg::block_len().

Source

pub fn iv_len(&self) -> usize

Determine the IV length for use with SymBlockCipherModeDecryptionInstance.

Equivalent to SymBlockCipherAlg::iv_len_for_mode().

Source

pub fn decrypt<'a, 'b, DI: CryptoWalkableIoSlicesMutIter<'a>, SI: CryptoWalkableIoSlicesIter<'b>>( &self, iv: &[u8], dst: DI, src: SI, iv_out: Option<&mut [u8]>, ) -> Result<(), CryptoError>

Decrypt data from buffer to buffer.

The source and destination buffers must be equal in length or an error will get returned. Depending on the block cipher mode, their lengths must perhaps be aligned to the block cipher block length, an error will get returned otherwise. No padding format verification will be done.

Processing a request does not alter self’s state – in particular the IV must get provided for each new requst anew.

§Arguments:
  • iv - The IV to use. Its length must match the expected IV length.
  • dst - The destination buffers to write the decrypted message to.
  • src - The source buffers holding the encrypted message.
  • iv_out - Optional buffer receiving the final IV as ouput from the block cipher mode. Attempting to retrieve the final IV when the to be encrypted data’s length is not an integral multiple of the block cipher block size is ill-defined and considered an error.
Source

pub fn decrypt_in_place<'a, 'b, DI: CryptoPeekableIoSlicesMutIter<'a>>( &self, iv: &[u8], dst: DI, iv_out: Option<&mut [u8]>, ) -> Result<(), CryptoError>

Decrypt data in place.

Depending on the block cipher mode, the source/destination buffer’s length must perhaps be aligned to the block cipher block length, an error will get returned otherwise. . No padding format verification will be done.

Processing a request does not alter self’s state – in particular the IV must get provided for each new requst anew.

Unlike it’s the case with decrypt(), the source/destination buffer’s generic DI type is not dyn compatible. The compiler will emit a separate instance for each individual DI decrypt_in_place() gets invoked with. Be vigilant of template bloat, prefer decrypt() if feasible and try to not use too exotic types for DI here otherwise.

§Arguments:
  • iv - The IV to use. Its length must match the expected IV length.
  • dst - The source/destination buffers initially holding the encryted message and receiving the decrypted cleartext result.
  • iv_out - Optional buffer receiving the final IV as ouput from the block cipher mode. Attempting to retrieve the final IV when the to be encrypted data’s length is not an integral multiple of the block cipher block size is ill-defined and considered an error.

Trait Implementations§

Source§

impl From<&SymBlockCipherModeDecryptionInstance> for SymBlockCipherAlg

Source§

fn from(value: &SymBlockCipherModeDecryptionInstance) -> Self

Converts to this type from the input type.
Source§

impl From<&SymBlockCipherModeDecryptionInstance> for TpmiAlgCipherMode

Source§

fn from(value: &SymBlockCipherModeDecryptionInstance) -> Self

Converts to this type from the input type.
Source§

impl ZeroizeOnDrop for SymBlockCipherModeDecryptionInstance

Available on crate feature zeroize only.

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.