| Maintainer | John Galt <jgalt@centromere.net> |
|---|---|
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.Noise.Handshake
Description
For more information regarding MessagePatterns, please see the Crypto.Noise.MessagePatterns module.
- data HandshakeState c d h
- type MessagePattern c d h a = MessagePatternT c d h Identity a
- type MessagePatternIO c d h a = MessagePatternT c d h IO a
- data HandshakePattern c d h
- data CipherState c
- getRemoteStaticKey :: Curve d => HandshakeState c d h -> PublicKey d
- handshakeState :: forall c d h. (Cipher c, Curve d, Hash h) => ByteString -> HandshakePattern c d h -> Plaintext -> Maybe (KeyPair d) -> Maybe (KeyPair d) -> Maybe (PublicKey d) -> Maybe (PublicKey d) -> HandshakeState c d h
- writeMessage :: (Cipher c, Curve d, Hash h) => HandshakeState c d h -> Plaintext -> IO (ByteString, HandshakeState c d h)
- readMessage :: (Cipher c, Curve d, Hash h) => HandshakeState c d h -> ByteString -> (Plaintext, HandshakeState c d h)
- writeMessageFinal :: (Cipher c, Curve d, Hash h) => HandshakeState c d h -> Plaintext -> IO (ByteString, CipherState c, CipherState c)
- readMessageFinal :: (Cipher c, Curve d, Hash h) => HandshakeState c d h -> ByteString -> (Plaintext, CipherState c, CipherState c)
- encryptPayload :: Cipher c => Plaintext -> CipherState c -> (ByteString, CipherState c)
- decryptPayload :: Cipher c => ByteString -> CipherState c -> (Plaintext, CipherState c)
Types
data HandshakeState c d h Source
Contains the state of a handshake.
type MessagePattern c d h a = MessagePatternT c d h Identity a Source
Represents a series of operations that can be performed on a Noise message.
type MessagePatternIO c d h a = MessagePatternT 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.
data HandshakePattern c d h Source
Represents a series of message patterns, the first for writing and the second for reading.
data CipherState c Source
Represents a symmetric key and associated nonce.
Functions
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.
Arguments
| :: (Cipher c, Curve d, Hash h) | |
| => ByteString | Handshake pattern name |
| -> HandshakePattern c d h | The handshake pattern to use |
| -> Plaintext | Prologue |
| -> 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 |
| -> 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".
Arguments
| :: (Cipher c, Curve d, Hash h) | |
| => HandshakeState c d h | The handshake state |
| -> 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.
Arguments
| :: (Cipher c, Curve d, Hash h) | |
| => HandshakeState c d h | The handshake state |
| -> ByteString | The handshake message received |
| -> (Plaintext, HandshakeState c d h) |
Reads a handshake message. All subsequent handshake processing must use the returned state.
Arguments
| :: (Cipher c, Curve d, Hash h) | |
| => HandshakeState c d h | The handshake state |
| -> 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.
Arguments
| :: (Cipher c, Curve d, Hash h) | |
| => HandshakeState c d h | The handshake state |
| -> ByteString | The handshake message received |
| -> (Plaintext, CipherState c, CipherState c) |
The final call of a handshake negotiation. Used to generate a pair of CipherStates, one for each transmission direction.
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.
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.