Portability | unknown |
---|---|
Stability | experimental |
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Network.TLS
Contents
Description
- data TLSParams = TLSParams {
- pConnectVersion :: Version
- pAllowedVersions :: [Version]
- pCiphers :: [Cipher]
- pCompressions :: [Compression]
- pWantClientCert :: Bool
- pCertificates :: [(X509, Maybe PrivateKey)]
- onCertificatesRecv :: [X509] -> IO Bool
- defaultParams :: TLSParams
- data TLSCtx
- ctxHandle :: TLSCtx -> Handle
- client :: (MonadIO m, CryptoRandomGen g) => TLSParams -> g -> Handle -> m TLSCtx
- server :: (MonadIO m, CryptoRandomGen g) => TLSParams -> g -> Handle -> m TLSCtx
- bye :: MonadIO m => TLSCtx -> m ()
- handshake :: MonadIO m => TLSCtx -> m ()
- sendData :: MonadIO m => TLSCtx -> ByteString -> m ()
- recvData :: MonadIO m => TLSCtx -> m ByteString
- data PrivateKey = PrivRSA PrivateKey
- data Compression
- nullCompression :: Compression
- data Cipher
- data Version
- data TLSError
- = Error_Misc String
- | Error_Certificate String
- | Error_Random String
- | Error_Digest ([Word8], [Word8])
- | Error_Packet String
- | Error_Packet_Size_Mismatch (Int, Int)
- | Error_Packet_unexpected String String
- | Error_Packet_Parsing String
- | Error_Internal_Packet_ByteProcessed Int Int Int
- | Error_Unknown_Version Word8 Word8
- | Error_Unknown_Type String
Context configuration
data TLSParams
Constructors
TLSParams | |
Fields
|
Context object
data TLSCtx
A TLS Context is a handle augmented by tls specific state and parameters
Creating a context
client :: (MonadIO m, CryptoRandomGen g) => TLSParams -> g -> Handle -> m TLSCtx
Create a new Client context with a configuration, a RNG, and a Handle. It reconfigures the handle buffermode to noBuffering
server :: (MonadIO m, CryptoRandomGen g) => TLSParams -> g -> Handle -> m TLSCtx
Create a new Server context with a configuration, a RNG, and a Handle. It reconfigures the handle buffermode to noBuffering
Initialisation and Termination of context
bye :: MonadIO m => TLSCtx -> m ()
notify the context that this side wants to close connection. this is important that it is called before closing the handle, otherwise the session might not be resumable (for version < TLS1.2).
this doesn't actually close the handle
handshake :: MonadIO m => TLSCtx -> m ()
Handshake for a new TLS connection This is to be called at the beginning of a connection, and during renegociation
High level API
sendData :: MonadIO m => TLSCtx -> ByteString -> m ()
sendData sends a bunch of data. It will automatically chunk data to acceptable packet size
recvData :: MonadIO m => TLSCtx -> m ByteString
recvData get data out of Data packet, and automatically renegociate if a Handshake ClientHello is received
Crypto Key
Compressions & Predefined compressions
nullCompression :: Compression
default null compression
Ciphers & Predefined ciphers
Versions
data Version
Versions known to TLS
SSL2 is just defined, but this version is and will not be supported.
TLS12 is not yet supported
Errors
data TLSError
TLSError that might be returned through the TLS stack
Constructors