Maintainer | John Galt <jgalt@centromere.net> |
---|---|
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- class Monad m => MonadHandshake m where
- tokenPreLS :: m ()
- tokenPreRS :: m ()
- tokenPreLE :: m ()
- tokenPreRE :: m ()
- tokenRE :: ByteString -> m ByteString
- tokenRS :: ByteString -> m ByteString
- tokenWE :: MonadIO m => m ByteString
- tokenWS :: m ByteString
- tokenDHEE :: m ()
- tokenDHES :: m ()
- tokenDHSE :: m ()
- tokenDHSS :: m ()
- 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 = HandshakePattern ByteString (Maybe (MessagePattern c d h ())) [MessagePatternIO c d h ByteString] [ByteString -> MessagePattern c d h ByteString]
- data HandshakeState c d h
- runMessagePatternT :: Monad m => MessagePatternT c d h m a -> HandshakeState c d h -> m (a, HandshakeState c d h)
- getLocalStaticKey :: Curve d => HandshakeState c d h -> KeyPair d
- getLocalEphemeralKey :: Curve d => HandshakeState c d h -> KeyPair d
- getRemoteStaticKey :: Curve d => HandshakeState c d h -> PublicKey d
- getRemoteEphemeralKey :: Curve d => HandshakeState c d h -> PublicKey d
- handshakeState :: forall c d h. (Cipher c, Curve d, Hash h) => HandshakePattern c d h -> Plaintext -> Maybe 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)
Classes
class Monad m => MonadHandshake m where Source
tokenPreLS :: m () Source
tokenPreRS :: m () Source
tokenPreLE :: m () Source
tokenPreRE :: m () Source
tokenRE :: ByteString -> m ByteString Source
tokenRS :: ByteString -> m ByteString Source
tokenWE :: MonadIO m => m ByteString Source
tokenWS :: m ByteString Source
Types
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.
HandshakePattern ByteString (Maybe (MessagePattern c d h ())) [MessagePatternIO c d h ByteString] [ByteString -> MessagePattern c d h ByteString] |
data HandshakeState c d h Source
Contains the state of a handshake.
Functions
runMessagePatternT :: Monad m => MessagePatternT c d h m a -> HandshakeState c d h -> m (a, HandshakeState c d h) Source
getLocalStaticKey :: Curve d => HandshakeState c d h -> KeyPair d Source
getLocalEphemeralKey :: Curve d => HandshakeState c d h -> KeyPair d 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.
getRemoteEphemeralKey :: Curve d => HandshakeState c d h -> PublicKey d Source
:: (Cipher c, Curve d, Hash h) | |
=> HandshakePattern c d h | The handshake pattern to use |
-> Plaintext | Prologue |
-> Maybe Plaintext | Pre-shared key |
-> 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, or you provide
a static key which is supposed to be set during the exchange, you will
receive a HandshakeStateFailure
exception.
:: (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.
:: (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.
:: (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.
:: (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.
:: 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.
:: 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.