Maintainer | John Galt <jgalt@centromere.net> |
---|---|
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
For more information regarding HandshakePatterns, please see the Crypto.Noise.HandshakePatterns module.
- data SendingCipherState c
- data ReceivingCipherState c
- data HandshakeCallbacks = HandshakeCallbacks {
- hscbSend :: ByteString -> IO ()
- hscbRecv :: IO ByteString
- hscbPayloadIn :: Plaintext -> IO ()
- hscbPayloadOut :: IO Plaintext
- data HandshakeState c d h
- data HandshakeStateParams c d = HandshakeStateParams {
- hspPattern :: HandshakePattern c
- hspPrologue :: Plaintext
- hspPreSharedKey :: Maybe Plaintext
- hspLocalStaticKey :: Maybe (KeyPair d)
- hspLocalEphemeralKey :: Maybe (KeyPair d)
- hspRemoteStaticKey :: Maybe (PublicKey d)
- hspRemoteEphemeralKey :: Maybe (PublicKey d)
- hspInitiator :: Bool
- handshakeState :: forall c d h. (Cipher c, Curve d, Hash h) => HandshakeStateParams c d -> HandshakeState c d h
- runHandshake :: (Cipher c, Curve d, Hash h) => HandshakeState c d h -> HandshakeCallbacks -> IO (SendingCipherState c, ReceivingCipherState c)
- encryptPayload :: Cipher c => Plaintext -> SendingCipherState c -> (ByteString, SendingCipherState c)
- decryptPayload :: Cipher c => ByteString -> ReceivingCipherState c -> (Plaintext, ReceivingCipherState c)
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.
HandshakeCallbacks | |
|
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.
HandshakeStateParams | |
|
Functions
:: (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.
:: 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.
:: 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.