{-# LANGUAGE EmptyDataDecls #-}
module Network.TLS.Types
( Version(..)
, SessionID
, SessionData(..)
, SessionFlag(..)
, CertReqContext
, TLS13TicketInfo(..)
, CipherID
, CompressionID
, Role(..)
, invertRole
, Direction(..)
, HostName
, Second
, Millisecond
, EarlySecret
, HandshakeSecret
, ApplicationSecret
, ResumptionSecret
, BaseSecret(..)
, ClientTrafficSecret(..)
, ServerTrafficSecret(..)
, SecretTriple(..)
, SecretPair(..)
, MasterSecret(..)
) 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
, sessionFlags :: [SessionFlag]
} deriving (Show,Eq)
data SessionFlag
= SessionEMS
deriving (Show,Eq,Enum)
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
data EarlySecret
data HandshakeSecret
data ApplicationSecret
data ResumptionSecret
newtype BaseSecret a = BaseSecret ByteString deriving Show
newtype ClientTrafficSecret a = ClientTrafficSecret ByteString deriving Show
newtype ServerTrafficSecret a = ServerTrafficSecret ByteString deriving Show
data SecretTriple a = SecretTriple
{ triBase :: BaseSecret a
, triClient :: ClientTrafficSecret a
, triServer :: ServerTrafficSecret a
}
data SecretPair a = SecretPair
{ pairBase :: BaseSecret a
, pairClient :: ClientTrafficSecret a
}
newtype MasterSecret = MasterSecret ByteString deriving Show