cipher

Trait NewCipher

Source
pub trait NewCipher: Sized {
    type KeySize: ArrayLength<u8>;
    type NonceSize: ArrayLength<u8>;

    // Required method
    fn new(key: &CipherKey<Self>, nonce: &Nonce<Self>) -> Self;

    // Provided method
    fn new_from_slices(key: &[u8], nonce: &[u8]) -> Result<Self, InvalidLength> { ... }
}
Expand description

Cipher creation trait.

It can be used for creation of block modes, synchronous and asynchronous stream ciphers.

Required Associated Types§

Source

type KeySize: ArrayLength<u8>

Key size in bytes

Source

type NonceSize: ArrayLength<u8>

Nonce size in bytes

Required Methods§

Source

fn new(key: &CipherKey<Self>, nonce: &Nonce<Self>) -> Self

Create new stream cipher instance from key and nonce arrays.

Provided Methods§

Source

fn new_from_slices(key: &[u8], nonce: &[u8]) -> Result<Self, InvalidLength>

Create new stream cipher instance from variable length key and nonce given as byte slices.

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§