cacophony-0.5.0: A library implementing the Noise protocol.

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

Crypto.Noise.Handshake

Contents

Description

For more information regarding HandshakePatterns, please see the Crypto.Noise.HandshakePatterns module.

Synopsis

Types

data SendingCipherState c Source

Represents the Noise cipher state for outgoing data.

data ReceivingCipherState c Source

Represents the Noise cipher state for incoming data.

data HandshakeCallbacks Source

Contains the callbacks required by runHandshake. hscbSend and hscbRecv are called when handshake data needs to be sent to and received from the remote peer, respectively. hscbPayloadIn and hscbPayloadOut are called when handshake payloads are received and sent, respectively.

data HandshakeState c d h Source

Represents the state of a handshake.

data HandshakeStateParams c d Source

Contains the parameters required to initialize a handshake state. 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, or you provide a static key which is supposed to be set during the exchange, you will receive a HandshakeStateFailure exception.

Functions

handshakeState Source

Arguments

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

Handshake state parameters

-> HandshakeState c d h 

Constructs a HandshakeState.

runHandshake :: (Cipher c, Curve d, Hash h) => HandshakeState c d h -> HandshakeCallbacks -> IO (SendingCipherState c, ReceivingCipherState c) Source

Given a HandshakeState and HandshakeCallbacks, runs a handshake from start to finish. The SendingCipherState and ReceivingCipherState are intended to be used by encryptPayload and decryptPayload, respectively.

encryptPayload Source

Arguments

:: Cipher c 
=> Plaintext

The data to encrypt

-> SendingCipherState c

The CipherState to use for encryption

-> (ByteString, SendingCipherState c) 

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

decryptPayload Source

Arguments

:: Cipher c 
=> ByteString

The data to decrypt

-> ReceivingCipherState c

The CipherState to use for decryption

-> (Plaintext, ReceivingCipherState c) 

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