-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Secure point-to-point connectivity library
--
-- This library simplifies the task of securely connecting two servers to
-- each other, with strong authentication and encryption on the wire.
@package secure-sockets
@version 1.2.3
-- | This library simplifies the task of securely connecting two servers to
-- each other. It closely mimicks the regular socket API, and adds the
-- concept of identity: each communicating server has an identity, and
-- connections can only be established between two servers who know each
-- other and expect to be communicating.
--
-- Under the hood, the library takes care of strongly authenticating the
-- connection, and of encrypting all traffic. If you successfully
-- establish a connection using this library, you have the guarantee that
-- the connection is secure.
module Network.Secure
-- | An identity, public or private.
class Identity a
identityName :: Identity a => a -> String
writeIdentity :: (Identity a, Functor m, MonadIO m) => a -> m ByteString
readIdentity :: (Identity a, Functor m, MonadIO m) => ByteString -> m a
-- | The public identity of a peer. This kind of identity can be used to
-- authenticate the remote ends of connections.
data PeerIdentity
-- | A local identity. This kind of identity can be used to authenticate
-- to remote ends of connections.
data LocalIdentity
-- | Extract the public parts of a LocalIdentity into a
-- PeerIdentity suitable for sharing with peers. The resulting
-- PeerIdentity will allow them to verify your identity when you
-- authenticate using the corresponding LocalIdentity.
toPeerIdentity :: LocalIdentity -> PeerIdentity
-- | Generate a new LocalIdentity, giving it an identifying name and
-- a validity period in days.
--
-- Note that this function may take quite a while to execute, as it is
-- generating key material for the identity.
newLocalIdentity :: MonadIO m => String -> Int -> m LocalIdentity
-- | Connect securely to the given host/port. The Connection is
-- returned only if the peer accepts the given LocalIdentity, and
-- if the remote endpoint successfully authenticates as one of the given
-- PeerIdentity.
connect :: LocalIdentity -> [PeerIdentity] -> (HostName, ServiceName) -> IO Connection
-- | A server socket that accepts only secure connections.
data Socket
-- | Create a new secure socket server, listening on the given
-- address/port. The host may be Nothing to signify that the
-- socket should listen on all available addresses.
newServer :: (Maybe HostName, ServiceName) -> IO Socket
-- | Accept one secure connection from a remote peer. The peer may
-- authenticate as any of the given peer identities. A Connection
-- is returned iff the autentication completes successfully.
accept :: LocalIdentity -> [PeerIdentity] -> Socket -> IO Connection
-- | An established authenticated connection to a peer. It is guaranteed
-- that all Connection objects are with a known peer, and that the
-- connection is strongly encrypted.
data Connection
-- | Return the PeerIdentity of the remote end of the connection.
peer :: Connection -> PeerIdentity
-- | Read at most n bytes from the given connection.
read :: Connection -> Int -> IO ByteString
-- | Send data to the connected peer.
write :: Connection -> ByteString -> IO ()
-- | Close the connection. No other operations on Connections should
-- be used after closing it.
close :: Connection -> IO ()
-- | Either a host name e.g., "haskell.org" or a numeric host
-- address string consisting of a dotted decimal IPv4 address or an IPv6
-- address e.g., "192.168.0.1".
type HostName = String
type ServiceName = String