cacophony-0.1.0.0: A library implementing the Noise protocol.

MaintainerJohn Galt <centromere@users.noreply.github.com>
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Crypto.Noise.Internal.HandshakeState

Contents

Description

 

Synopsis

Classes

Types

data HandshakeState c d h Source

Contains the state of a handshake.

type Descriptor c d h a = DescriptorT c d h Identity a Source

Represents a series of operations that can be performed on a Noise message.

type DescriptorIO c d h a = DescriptorT c d h IO a Source

Represents a series of operations that will result in a Noise message. This must be done in IO to facilitate the generation of ephemeral keys.

Functions

runDescriptorT :: Monad m => DescriptorT c d h m a -> HandshakeState c d h -> m (a, HandshakeState c d h) Source

getRemoteStaticKey :: Curve d => HandshakeState c d h -> PublicKey d Source

Returns the remote party's public static key. This is useful when the static key has been transmitted to you and you want to save it for future use.

handshakeState Source

Arguments

:: (Cipher c, Curve d, Hash h) 
=> ScrubbedBytes

Handshake name

-> Maybe (KeyPair d)

Local static key

-> Maybe (KeyPair d)

Local ephemeral key

-> Maybe (PublicKey d)

Remote public static key

-> Maybe (PublicKey d)

Remote public ephemeral key

-> Maybe (Descriptor c d h ())

Pre-message processing descriptor

-> HandshakeState c d h 

Constructs a HandshakeState. The keys you need to provide are dependent on the type of handshake you are using. If you fail to provide a key that your handshake type depends on, you will receive an error such as "local static key not set".

writeHandshakeMsg Source

Arguments

:: (Cipher c, Curve d, Hash h) 
=> HandshakeState c d h

The handshake state

-> DescriptorIO c d h ByteString

A descriptor for this particular message

-> Plaintext

Optional message to transmit

-> IO (ByteString, HandshakeState c d h) 

Creates a handshake message. The plaintext can be left empty if no plaintext is to be transmitted. All subsequent handshake processing must use the returned state.

readHandshakeMsg Source

Arguments

:: (Cipher c, Curve d, Hash h) 
=> HandshakeState c d h

The handshake state

-> ByteString

The handshake message received

-> (ByteString -> Descriptor c d h ByteString)

A descriptor for this particular message

-> (Plaintext, HandshakeState c d h) 

Reads a handshake message. All subsequent handshake processing must use the returned state.

writeHandshakeMsgFinal Source

Arguments

:: (Cipher c, Curve d, Hash h) 
=> HandshakeState c d h

The handshake state

-> DescriptorIO c d h ByteString

A descriptor for this particular message

-> Plaintext

Optional message to transmit

-> IO (ByteString, CipherState c, CipherState c) 

The final call of a handshake negotiation. Used to generate a pair of CipherStates, one for each transmission direction.

readHandshakeMsgFinal Source

Arguments

:: (Cipher c, Curve d, Hash h) 
=> HandshakeState c d h

The handshake state

-> ByteString

The handshake message received

-> (ByteString -> Descriptor c d h ByteString)

A descriptor for this particular message

-> (Plaintext, CipherState c, CipherState c) 

The final call of a handshake negotiation. Used to generate a pair of CipherStates, one for each transmission direction.

encryptPayload Source

Arguments

:: Cipher c 
=> Plaintext

The data to encrypt

-> CipherState c

The CipherState to use for encryption

-> (ByteString, CipherState c) 

Encrypts a payload. The returned CipherState must be used for all subsequent calls.

decryptPayload Source

Arguments

:: Cipher c 
=> ByteString

The data to decrypt

-> CipherState c

The CipherState to use for decryption

-> (Plaintext, CipherState c) 

Decrypts a payload. The returned CipherState must be used for all subsequent calls.