cacophony-0.10.0: A library implementing the Noise protocol.

MaintainerJohn Galt <jgalt@centromere.net>
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Crypto.Noise.Internal.CipherState

Description

 

Synopsis

Documentation

data CipherState c Source #

Constructors

CipherState 

Fields

csn :: forall c. Lens' (CipherState c) (Nonce c) Source #

csk :: forall c. Lens' (CipherState c) (Maybe (SymmetricKey c)) Source #

cipherState :: Cipher c => Maybe (SymmetricKey c) -> CipherState c Source #

Creates a new CipherState with an optional symmetric key and a zero nonce.

encryptWithAd :: (MonadThrow m, Cipher c) => AssocData -> Plaintext -> CipherState c -> m (Ciphertext c, CipherState c) Source #

Encrypts the provided plaintext and increments the nonce. If this CipherState does not have a key associated with it, the plaintext will be returned.

decryptWithAd :: (MonadThrow m, Cipher c) => AssocData -> Ciphertext c -> CipherState c -> m (Plaintext, CipherState c) Source #

Decrypts the provided ciphertext and increments the nonce. If this CipherState does not have a key associated with it, the ciphertext will be returned. If the CipherState does have a key and decryption fails, a DecryptionError will be returned.

rekey :: Cipher c => CipherState c -> CipherState c Source #

Rekeys the CipherState. If a key has not been established yet, the CipherState is returned unmodified.

validNonce :: Cipher c => CipherState c -> Bool Source #

Tests whether the Nonce contained within a CipherState is valid (less than the maximum allowed).