Encryptor

Trait Encryptor 

Source
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§

Source

type Error: Error

Available on crate feature std only.

Compression/Decompression Error

Required Methods§

Source

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.

Source

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.

Source

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§

Source

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.

Source

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.

Implementors§