module Network.TLS.Types
( Version(..)
, SessionID
, SessionData(..)
, CertReqContext
, TLS13TicketInfo(..)
, CipherID
, CompressionID
, Role(..)
, invertRole
, Direction(..)
, HostName
, Second
, Millisecond
) where
import Network.TLS.Imports
import Network.TLS.Crypto.Types (Group)
type HostName = String
type Second = Word32
type Millisecond = Word64
data Version = SSL2 | SSL3 | TLS10 | TLS11 | TLS12 | TLS13 deriving (Show, Eq, Ord, Bounded)
type SessionID = ByteString
data SessionData = SessionData
{ sessionVersion :: Version
, sessionCipher :: CipherID
, sessionCompression :: CompressionID
, sessionClientSNI :: Maybe HostName
, sessionSecret :: ByteString
, sessionGroup :: Maybe Group
, sessionTicketInfo :: Maybe TLS13TicketInfo
, sessionALPN :: Maybe ByteString
, sessionMaxEarlyDataSize :: Int
} deriving (Show,Eq)
type CertReqContext = ByteString
data TLS13TicketInfo = TLS13TicketInfo
{ lifetime :: Second
, ageAdd :: Second
, txrxTime :: Millisecond
, estimatedRTT :: Maybe Millisecond
} deriving (Show, Eq)
type CipherID = Word16
type CompressionID = Word8
data Role = ClientRole | ServerRole
deriving (Show,Eq)
data Direction = Tx | Rx
deriving (Show,Eq)
invertRole :: Role -> Role
invertRole ClientRole = ServerRole
invertRole ServerRole = ClientRole