pub trait Encryptor {
type Error: Error;
// Required methods
fn encrypt(
dst: &mut [u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<(), Self::Error>;
fn encrypt_into_vec(
src: &[u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<Vec<u8>, Self::Error>;
fn encrypt_to(
src: &[u8],
dst: &mut [u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<(), Self::Error>;
// Provided methods
fn encrypt_into_bytes(
src: &[u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<Bytes, Self::Error> { ... }
fn is_valid_private_key(secret: &[u8], algo: EncryptionAlgorithm) -> bool { ... }
}Expand description
AES encryption extensions
Required Associated Types§
Required Methods§
Sourcefn encrypt(
dst: &mut [u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<(), Self::Error>
fn encrypt( dst: &mut [u8], key: &[u8], iv: &[u8], algo: EncryptionAlgorithm, ) -> Result<(), Self::Error>
Encrypts self with IV. Can be used for both encryption and decryption.
IV:
- EncryptionAlgorithm::Aes: IV is of AES block size.
- EncryptionAlgorithm::None: IV is ignored.
Sourcefn encrypt_into_vec(
src: &[u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<Vec<u8>, Self::Error>
fn encrypt_into_vec( src: &[u8], key: &[u8], iv: &[u8], algo: EncryptionAlgorithm, ) -> Result<Vec<u8>, Self::Error>
Encrypts self with IV to a new Vec.
Can be used for both encryption and decryption.
IV:
- EncryptionAlgorithm::Aes: IV is of AES block size.
- EncryptionAlgorithm::None: IV is ignored.
Sourcefn encrypt_to(
src: &[u8],
dst: &mut [u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<(), Self::Error>
fn encrypt_to( src: &[u8], dst: &mut [u8], key: &[u8], iv: &[u8], algo: EncryptionAlgorithm, ) -> Result<(), Self::Error>
Encrypts self with IV to dst.
Can be used for both encryption and decryption.
IV:
- EncryptionAlgorithm::Aes: IV is of AES block size.
- EncryptionAlgorithm::None: IV is ignored.
Provided Methods§
Sourcefn encrypt_into_bytes(
src: &[u8],
key: &[u8],
iv: &[u8],
algo: EncryptionAlgorithm,
) -> Result<Bytes, Self::Error>
fn encrypt_into_bytes( src: &[u8], key: &[u8], iv: &[u8], algo: EncryptionAlgorithm, ) -> Result<Bytes, Self::Error>
Encrypts self with IV to a new bytes::Bytes.
Can be used for both encryption and decryption.
IV:
- EncryptionAlgorithm::Aes: IV is of AES block size.
- EncryptionAlgorithm::None: IV is ignored.
Sourcefn is_valid_private_key(secret: &[u8], algo: EncryptionAlgorithm) -> bool
fn is_valid_private_key(secret: &[u8], algo: EncryptionAlgorithm) -> bool
Check if the private key length is valid
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.