Safe Haskell | None |
---|
Network.CommSec
Contents
- data Connection = Conn {
- inCtx :: MVar InContext
- outCtx :: MVar OutContext
- socket :: Socket
- socketAddr :: SockAddr
- data CommSecError
- send :: Connection -> ByteString -> IO ()
- recv :: Connection -> IO ByteString
- sendPtr :: Connection -> Ptr Word8 -> Int -> IO ()
- recvPtr :: Connection -> Ptr Word8 -> Int -> IO Int
- accept :: ByteString -> PortNumber -> IO Connection
- connect :: ByteString -> HostName -> PortNumber -> IO Connection
- close :: Connection -> IO ()
- expandSecret :: ByteString -> Int -> ByteString
Types
data Connection Source
A connection is a secure bidirectional communication channel.
data CommSecError Source
Errors that can be returned by the decoding/receicing operations.
Constructors
OldContext | |
DuplicateSeq | |
InvalidICV | |
BadPadding | |
BuildKeyFailure |
Send and receive operations
send :: Connection -> ByteString -> IO ()Source
Send a datagram, first encrypting it, using the given secure connection.
recv :: Connection -> IO ByteStringSource
recvPtr :: Connection -> Ptr Word8 -> Int -> IO IntSource
Blocks till it receives a valid message, placing the resulting plaintext in the provided buffer. If the incoming message is larger that the provided buffer then the message is truncated. This process also incurs an additional copy.
Establishing a connection from a shared secret
accept :: ByteString -> PortNumber -> IO ConnectionSource
Expands the provided 128 (or more) bit secret into two keys to create a connection.
ex: accept ent 3134
connect :: ByteString -> HostName -> PortNumber -> IO ConnectionSource
Expands the provided 128 (or more) bit secret into two keys to create a connection.
close :: Connection -> IO ()Source
Close a connection
Establishing a connection from a public identity (PKI)
Utility
expandSecret :: ByteString -> Int -> ByteStringSource