c2_chacha::stream_cipher

Trait NewStreamCipher

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

    // Required method
    fn new(
        key: &GenericArray<u8, Self::KeySize>,
        nonce: &GenericArray<u8, Self::NonceSize>,
    ) -> Self;

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

Stream cipher creation trait.

It can be used for creation of synchronous and asynchronous 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: &GenericArray<u8, Self::KeySize>, nonce: &GenericArray<u8, Self::NonceSize>, ) -> Self

Create new stream cipher instance from variable length key and nonce.

Provided Methods§

Source

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

Create new stream cipher instance from variable length key and nonce.

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§