Struct noise_protocol::CipherState [] [src]

pub struct CipherState<C: Cipher> { /* fields omitted */ }

A CipherState can encrypt and decrypt data.

Mostly like CipherState in the spec, but must be created with a key.

Methods

impl<C> CipherState<C> where C: Cipher
[src]

Name of cipher, e.g. “ChaChaPoly”.

Create a new CipherState with a key and a nonce n.

AEAD encryption.

Panics

When nonce reaches maximum u64, i.e. 2 ^ 64 - 1.

AEAD decryption.

Panics

When nonce reaches maximum u64, i.e. 2 ^ 64 - 1.

Encryption.

Encryption, returns ciphertext as Vec<u8>.

Decryption.

Decryption, returns plaintext as Vec<u8>.

Get underlying cipher and nonce.

This is useful for e.g. WireGuard. Because packets may be lost or arrive out of order, they would likely want to deal with nonces themselves.