pub struct Rc564Engine { /* private fields */ }Expand description
RC5-64 engine with a 16-byte block.
It takes a 1- to 255-byte key and 0 to 255 rounds from
Rc5Params; Rc5ParamsRef is the
ready-made implementation.
Constant time on processors with operand-independent rotations, such as mainstream x86, x86-64 and AArch64; other processors can leak through data-dependent rotation counts. The expanded key is wiped when replaced and on drop.
§Example
use tc_block_cipher::{BlockCipher, BlockCipherInit, CipherDirection};
use tc_rc_cipher::{RC5_64_BLOCK_BYTES, Rc564Engine, Rc5ParamsRef};
let mut engine = Rc564Engine::new();
let params = Rc5ParamsRef::with_default_rounds(&[0x42; 16]);
let plaintext = [0x11; RC5_64_BLOCK_BYTES];
engine.init(CipherDirection::Encrypt, ¶ms)?;
let mut ciphertext = [0; RC5_64_BLOCK_BYTES];
engine.process_block(&plaintext, &mut ciphertext)?;
engine.init(CipherDirection::Decrypt, ¶ms)?;
let mut recovered = [0; RC5_64_BLOCK_BYTES];
engine.process_block(&ciphertext, &mut recovered)?;
assert_eq!(recovered, plaintext);Implementations§
Source§impl Rc564Engine
impl Rc564Engine
Trait Implementations§
Source§impl BlockCipher for Rc564Engine
impl BlockCipher for Rc564Engine
Source§fn block_size(&self) -> usize
fn block_size(&self) -> usize
Returns 16, the block size in bytes. Constant time.
Source§fn process_block(
&mut self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, BlockError>
fn process_block( &mut self, input: &[u8], output: &mut [u8], ) -> Result<usize, BlockError>
Encrypts or decrypts one 16-byte block from input into output and
returns 16.
Returns NotInitialised before a successful init, or BufferTooShort
when either buffer is shorter than 16 bytes; output is left untouched
on error. Constant time on processors with operand-independent
rotations, such as mainstream x86, x86-64 and AArch64.
Source§type Error = BlockError
type Error = BlockError
crate::BlockError.Source§impl<P: Rc5Params + ?Sized> BlockCipherInit<P> for Rc564Engine
impl<P: Rc5Params + ?Sized> BlockCipherInit<P> for Rc564Engine
Source§fn init(
&mut self,
direction: CipherDirection,
params: &P,
) -> Result<(), InitError>
fn init( &mut self, direction: CipherDirection, params: &P, ) -> Result<(), InitError>
Installs a 1- to 255-byte key and 0 to 255 rounds for direction.
On error the previous key and direction stay in use. Constant time on processors with operand-independent rotations, such as mainstream x86, x86-64 and AArch64.
Source§type Error = InitError
type Error = InitError
crate::InitError.