Skip to main content

BlockCipher

Trait BlockCipher 

Source
pub trait BlockCipher {
    const BLOCK_SIZE: usize;

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

A symmetric block cipher (single-block primitive).

Higher-level modes (CBC, CTR, GCM) compose on top by chaining encrypt_block / decrypt_block calls; see crate::sm4::mode_cbc for the v0.2 single-shot CBC and crate::sm4::cbc_streaming for the v0.3 W5 streaming Sm4CbcEncryptor / Sm4CbcDecryptor.

Required Associated Constants§

Source

const BLOCK_SIZE: usize

Block size in bytes (e.g. 16 for SM4).

Required Methods§

Source

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

Construct a cipher instance from a key.

Source

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

Encrypt one block in place.

Source

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

Decrypt one block in place.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§