pub struct Hctr2pp<Aes: AesCipher> { /* private fields */ }Expand description
Generic HCTR2++ cipher parameterized by the master AES key size.
The master cipher is only used to derive the hash and re-keying subkeys. The re-keyed block cipher calls always use AES-128, since the R3 scheme produces n-bit ephemeral keys; the effective key strength is therefore 128 bits regardless of the master key size.
Implementations§
Source§impl<Aes: AesCipher> Hctr2pp<Aes>
impl<Aes: AesCipher> Hctr2pp<Aes>
Sourcepub const KEY_LENGTH: usize = Aes::KEY_LEN
pub const KEY_LENGTH: usize = Aes::KEY_LEN
Master key length in bytes.
Sourcepub const BLOCK_LENGTH: usize = BLOCK_LENGTH
pub const BLOCK_LENGTH: usize = BLOCK_LENGTH
AES block length in bytes (always 16).
Sourcepub const MIN_INPUT_LENGTH: usize = BLOCK_LENGTH
pub const MIN_INPUT_LENGTH: usize = BLOCK_LENGTH
Minimum input length in bytes.
Sourcepub fn encrypt(
&self,
plaintext: &[u8],
tweak: &[u8],
ciphertext: &mut [u8],
) -> Result<(), Error>
pub fn encrypt( &self, plaintext: &[u8], tweak: &[u8], ciphertext: &mut [u8], ) -> Result<(), Error>
Encrypt plaintext to ciphertext using HCTR2++.
§Arguments
plaintext- Input data to encrypt (minimum 16 bytes)tweak- Tweak value for domain separationciphertext- Output buffer (must be same length as plaintext)
§Errors
Returns Error::InputTooShort if plaintext is less than 16 bytes, and
Error::OutputLengthMismatch if the buffer lengths differ.
Sourcepub fn decrypt(
&self,
ciphertext: &[u8],
tweak: &[u8],
plaintext: &mut [u8],
) -> Result<(), Error>
pub fn decrypt( &self, ciphertext: &[u8], tweak: &[u8], plaintext: &mut [u8], ) -> Result<(), Error>
Decrypt ciphertext to plaintext using HCTR2++.
§Arguments
ciphertext- Input data to decrypt (minimum 16 bytes)tweak- Tweak value used during encryptionplaintext- Output buffer (must be same length as ciphertext)
§Errors
Returns Error::InputTooShort if ciphertext is less than 16 bytes, and
Error::OutputLengthMismatch if the buffer lengths differ.