cacophony-0.10.1: A library implementing the Noise protocol.

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

Crypto.Noise.Cipher

Contents

Description

 
Synopsis

Classes

class Cipher c where Source #

Typeclass for ciphers.

Associated Types

data Ciphertext c :: * Source #

Represents encrypted data containing an authentication tag.

data SymmetricKey c :: * Source #

Represents a symmetric key.

data Nonce c :: * Source #

Represents a nonce.

Methods

cipherName :: proxy c -> ScrubbedBytes Source #

Returns the name of the cipher. This is used when generating the handshake name.

cipherEncrypt :: SymmetricKey c -> Nonce c -> AssocData -> Plaintext -> Ciphertext c Source #

Encrypts data.

cipherDecrypt :: SymmetricKey c -> Nonce c -> AssocData -> Ciphertext c -> Maybe Plaintext Source #

Decrypts data, returning Nothing on error (such as when the auth tag is invalid).

cipherRekey :: SymmetricKey c -> SymmetricKey c Source #

Returns a new 32-byte cipher key as a pseudorandom function of k. Defaults to:

cipherEncrypt k maxNonce "" zeros

where maxNonce = 2^64 - 1 and zeros is a sequence of 32 bytes filed with zeros.

cipherZeroNonce :: Nonce c Source #

Returns a Nonce set to zero.

cipherMaxNonce :: Nonce c Source #

Returns the largest possible Nonce (2 ^ 64 - 1).

cipherIncNonce :: Nonce c -> Nonce c Source #

Increments a nonce.

cipherNonceEq :: Nonce c -> Nonce c -> Bool Source #

Tests if two Nonces are equal.

cipherNonceCmp :: Nonce c -> Nonce c -> Ordering Source #

Compares the value of two Nonces.

cipherBytesToSym :: ScrubbedBytes -> SymmetricKey c Source #

Imports a symmetric key. If the input is greater than 32 bytes, it is truncated.

cipherSymToBytes :: SymmetricKey c -> ScrubbedBytes Source #

Exports a symmetric key. Use with care.

cipherTextToBytes :: Ciphertext c -> ScrubbedBytes Source #

Exports a Ciphertext. The authentication tag follows the actual ciphertext.

cipherBytesToText :: ScrubbedBytes -> Ciphertext c Source #

Imports a Ciphertext.

Instances
Cipher AESGCM Source # 
Instance details

Defined in Crypto.Noise.Cipher.AESGCM

Associated Types

data Ciphertext AESGCM :: Type Source #

data SymmetricKey AESGCM :: Type Source #

data Nonce AESGCM :: Type Source #

Cipher ChaChaPoly1305 Source # 
Instance details

Defined in Crypto.Noise.Cipher.ChaChaPoly1305

Types

type AssocData = ScrubbedBytes Source #

Represents the associated data for AEAD.

type Plaintext = ScrubbedBytes Source #

Represents plaintext data that can be encrypted.