pub struct SymBlockCipherModeDecryptionInstance { /* private fields */ }Implementations§
Source§impl SymBlockCipherModeDecryptionInstance
impl SymBlockCipherModeDecryptionInstance
Sourcepub fn new(
mode_id: TpmiAlgCipherMode,
alg_id: &SymBlockCipherAlg,
key: &[u8],
) -> Result<Self, CryptoError>
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:
mode_id- The block cipher mode to use.alg_id- The symmetric block cipher algorithm to be used for this instance.key- The raw key bytes. It’s length must match the expected key length foralgor an error will get returned.
Sourcepub fn try_clone(&self) -> Result<Self, CryptoError>
pub fn try_clone(&self) -> Result<Self, CryptoError>
Try to clone a SymBlockCipherDecryptionInstance.
Sourcepub fn block_cipher_block_len(&self) -> usize
pub fn block_cipher_block_len(&self) -> usize
Obtain the instance’s associated block cipher algorithm’s block length.
Equivalent to
SymBlockCipherAlg::block_len().
Sourcepub fn iv_len(&self) -> usize
pub fn iv_len(&self) -> usize
Determine the IV length for use with
SymBlockCipherModeDecryptionInstance.
Equivalent to
SymBlockCipherAlg::iv_len_for_mode().
Sourcepub fn decrypt<'a, 'b, DI: CryptoWalkableIoSlicesMutIter<'a>, SI: CryptoWalkableIoSlicesIter<'b>>(
&self,
iv: &[u8],
dst: DI,
src: SI,
iv_out: Option<&mut [u8]>,
) -> Result<(), CryptoError>
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.
Sourcepub fn decrypt_in_place<'a, 'b, DI: CryptoPeekableIoSlicesMutIter<'a>>(
&self,
iv: &[u8],
dst: DI,
iv_out: Option<&mut [u8]>,
) -> Result<(), CryptoError>
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
impl From<&SymBlockCipherModeDecryptionInstance> for SymBlockCipherAlg
Source§fn from(value: &SymBlockCipherModeDecryptionInstance) -> Self
fn from(value: &SymBlockCipherModeDecryptionInstance) -> Self
Source§impl From<&SymBlockCipherModeDecryptionInstance> for TpmiAlgCipherMode
impl From<&SymBlockCipherModeDecryptionInstance> for TpmiAlgCipherMode
Source§fn from(value: &SymBlockCipherModeDecryptionInstance) -> Self
fn from(value: &SymBlockCipherModeDecryptionInstance) -> Self
impl ZeroizeOnDrop for SymBlockCipherModeDecryptionInstance
zeroize only.