pub struct SymBlockCipherModeEncryptionInstance { /* private fields */ }Implementations§
Source§impl SymBlockCipherModeEncryptionInstance
impl SymBlockCipherModeEncryptionInstance
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 SymBlockCipherModeEncryptionInstance 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 SymBlockModeCipherEncryptionInstance.
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
SymBlockCipherModeEncryptionInstance.
Equivalent to
SymBlockCipherAlg::iv_len_for_mode().
Sourcepub fn encrypt<'a, 'b, DI: CryptoWalkableIoSlicesMutIter<'a>, SI: CryptoWalkableIoSlicesIter<'b>>(
&self,
iv: &[u8],
dst: DI,
src: SI,
iv_out: Option<&mut [u8]>,
) -> Result<(), CryptoError>
pub fn encrypt<'a, 'b, DI: CryptoWalkableIoSlicesMutIter<'a>, SI: CryptoWalkableIoSlicesIter<'b>>( &self, iv: &[u8], dst: DI, src: SI, iv_out: Option<&mut [u8]>, ) -> Result<(), CryptoError>
Encrypt 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 will get inserted.
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 encrypted message to.src- The source buffers holding the cleartext message to encrypt.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 encrypt_in_place<'a, 'b, DI: CryptoPeekableIoSlicesMutIter<'a>>(
&self,
iv: &[u8],
dst: DI,
iv_out: Option<&mut [u8]>,
) -> Result<(), CryptoError>
pub fn encrypt_in_place<'a, 'b, DI: CryptoPeekableIoSlicesMutIter<'a>>( &self, iv: &[u8], dst: DI, iv_out: Option<&mut [u8]>, ) -> Result<(), CryptoError>
Encrypt 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 will get inserted.
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 encrypt(), the
source/destination buffer’s generic DI type is not dyn
compatible. The compiler will emit a separate instance for each
individual DI encrypt_in_place() gets invoked with. Be vigilant
of template bloat, prefer encrypt() 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 cleartext message and receiving the encrypted 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<&SymBlockCipherModeEncryptionInstance> for SymBlockCipherAlg
impl From<&SymBlockCipherModeEncryptionInstance> for SymBlockCipherAlg
Source§fn from(value: &SymBlockCipherModeEncryptionInstance) -> Self
fn from(value: &SymBlockCipherModeEncryptionInstance) -> Self
Source§impl From<&SymBlockCipherModeEncryptionInstance> for TpmiAlgCipherMode
impl From<&SymBlockCipherModeEncryptionInstance> for TpmiAlgCipherMode
Source§fn from(value: &SymBlockCipherModeEncryptionInstance) -> Self
fn from(value: &SymBlockCipherModeEncryptionInstance) -> Self
impl ZeroizeOnDrop for SymBlockCipherModeEncryptionInstance
zeroize only.