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§
Required Methods§
Sourcefn new_encrypt(key: &Self::Key, iv: &Self::Nonce) -> Self
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.
Sourcefn new_decrypt(key: &Self::Key, iv: &Self::Nonce) -> Self
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.
Sourcefn encrypt_padded(self, buffer: &[u8]) -> Result<Vec<u8>, CipherError>
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.
Sourcefn decrypt_padded(self, buffer: &[u8]) -> Result<Vec<u8>, CipherError>
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", so this trait is not object safe.