Skip to main content

BlockCipher

Trait BlockCipher 

Source
pub trait BlockCipher {
    type Key: AsRef<[u8]>;
    type Nonce: AsRef<[u8]>;

    // Required methods
    fn new_encrypt(key: &Self::Key, iv: &Self::Nonce) -> Self;
    fn new_decrypt(key: &Self::Key, iv: &Self::Nonce) -> Self;
    fn encrypt_padded(self, buffer: &[u8]) -> Result<Vec<u8>, CipherError>;
    fn decrypt_padded(self, buffer: &[u8]) -> Result<Vec<u8>, CipherError>;
}
Expand description

Synchronous block cipher trait.

Required Associated Types§

Source

type Key: AsRef<[u8]>

The byte array key type which specifies the size of the key used to instantiate the cipher.

Source

type Nonce: AsRef<[u8]>

The byte array nonce type which specifies the size of the nonce used in the cipher operations.

Required Methods§

Source

fn new_encrypt(key: &Self::Key, iv: &Self::Nonce) -> Self

Instantiate a new instance of a block cipher for encryption from a key and iv.

Source

fn new_decrypt(key: &Self::Key, iv: &Self::Nonce) -> Self

Instantiate a new instance of a block cipher for decryption from a key and iv.

Source

fn encrypt_padded(self, buffer: &[u8]) -> Result<Vec<u8>, CipherError>

Encrypts the given data in buffer, and returns the result (with padding) in a newly allocated vector, or a CipherError if the operation was unsuccessful.

Source

fn decrypt_padded(self, buffer: &[u8]) -> Result<Vec<u8>, CipherError>

Decrypts the given data in a buffer, and returns the result (with padding removed) in a newly allocated vector, or a CipherError if the operation was unsuccessful.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§