Skip to main content

BlockCipher

Trait BlockCipher 

Source
pub trait BlockCipher {
    const BLOCK_LEN: usize;
    const KEY_LENS: &'static [usize];

    // Required methods
    fn new(key: &[u8]) -> Self;
    fn encrypt_block(&self, block: &mut [u8]);
    fn decrypt_block(&self, block: &mut [u8]);
}
Expand description

Trait for symmetric block ciphers operating on a fixed block size.

Implementors include the AES family (cipher::Aes, cipher::Aes128, cipher::Aes192, cipher::Aes256) and the DES family (cipher::Des, cipher::TripleDes).

Required Associated Constants§

Source

const BLOCK_LEN: usize

Block size in bytes (16 for AES, 8 for DES / 3DES).

Source

const KEY_LENS: &'static [usize]

Key sizes supported by new, in bytes.

Required Methods§

Source

fn new(key: &[u8]) -> Self

Initialise the cipher with a key. The key length must be one of the values listed in Self::KEY_LENS.

Source

fn encrypt_block(&self, block: &mut [u8])

Encrypt block in place. The slice must be at least Self::BLOCK_LEN bytes long.

Source

fn decrypt_block(&self, block: &mut [u8])

Decrypt block in place. The slice must be at least Self::BLOCK_LEN bytes long.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§