{-# 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(..)
, AnyTrafficSecret(..)
, ClientTrafficSecret(..)
, ServerTrafficSecret(..)
, TrafficSecrets
, 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 (Int -> Version -> ShowS
[Version] -> ShowS
Version -> String
(Int -> Version -> ShowS)
-> (Version -> String) -> ([Version] -> ShowS) -> Show Version
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Version] -> ShowS
$cshowList :: [Version] -> ShowS
show :: Version -> String
$cshow :: Version -> String
showsPrec :: Int -> Version -> ShowS
$cshowsPrec :: Int -> Version -> ShowS
Show, Version -> Version -> Bool
(Version -> Version -> Bool)
-> (Version -> Version -> Bool) -> Eq Version
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Version -> Version -> Bool
$c/= :: Version -> Version -> Bool
== :: Version -> Version -> Bool
$c== :: Version -> Version -> Bool
Eq, Eq Version
Eq Version
-> (Version -> Version -> Ordering)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Bool)
-> (Version -> Version -> Version)
-> (Version -> Version -> Version)
-> Ord Version
Version -> Version -> Bool
Version -> Version -> Ordering
Version -> Version -> Version
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Version -> Version -> Version
$cmin :: Version -> Version -> Version
max :: Version -> Version -> Version
$cmax :: Version -> Version -> Version
>= :: Version -> Version -> Bool
$c>= :: Version -> Version -> Bool
> :: Version -> Version -> Bool
$c> :: Version -> Version -> Bool
<= :: Version -> Version -> Bool
$c<= :: Version -> Version -> Bool
< :: Version -> Version -> Bool
$c< :: Version -> Version -> Bool
compare :: Version -> Version -> Ordering
$ccompare :: Version -> Version -> Ordering
$cp1Ord :: Eq Version
Ord, Version
Version -> Version -> Bounded Version
forall a. a -> a -> Bounded a
maxBound :: Version
$cmaxBound :: Version
minBound :: Version
$cminBound :: Version
Bounded)
type SessionID = ByteString
data SessionData = SessionData
{ SessionData -> Version
sessionVersion :: Version
, SessionData -> CipherID
sessionCipher :: CipherID
, SessionData -> CompressionID
sessionCompression :: CompressionID
, SessionData -> Maybe String
sessionClientSNI :: Maybe HostName
, SessionData -> ByteString
sessionSecret :: ByteString
, SessionData -> Maybe Group
sessionGroup :: Maybe Group
, SessionData -> Maybe TLS13TicketInfo
sessionTicketInfo :: Maybe TLS13TicketInfo
, SessionData -> Maybe ByteString
sessionALPN :: Maybe ByteString
, SessionData -> Int
sessionMaxEarlyDataSize :: Int
, SessionData -> [SessionFlag]
sessionFlags :: [SessionFlag]
} deriving (Int -> SessionData -> ShowS
[SessionData] -> ShowS
SessionData -> String
(Int -> SessionData -> ShowS)
-> (SessionData -> String)
-> ([SessionData] -> ShowS)
-> Show SessionData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionData] -> ShowS
$cshowList :: [SessionData] -> ShowS
show :: SessionData -> String
$cshow :: SessionData -> String
showsPrec :: Int -> SessionData -> ShowS
$cshowsPrec :: Int -> SessionData -> ShowS
Show,SessionData -> SessionData -> Bool
(SessionData -> SessionData -> Bool)
-> (SessionData -> SessionData -> Bool) -> Eq SessionData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionData -> SessionData -> Bool
$c/= :: SessionData -> SessionData -> Bool
== :: SessionData -> SessionData -> Bool
$c== :: SessionData -> SessionData -> Bool
Eq)
data SessionFlag
= SessionEMS
deriving (Int -> SessionFlag -> ShowS
[SessionFlag] -> ShowS
SessionFlag -> String
(Int -> SessionFlag -> ShowS)
-> (SessionFlag -> String)
-> ([SessionFlag] -> ShowS)
-> Show SessionFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionFlag] -> ShowS
$cshowList :: [SessionFlag] -> ShowS
show :: SessionFlag -> String
$cshow :: SessionFlag -> String
showsPrec :: Int -> SessionFlag -> ShowS
$cshowsPrec :: Int -> SessionFlag -> ShowS
Show,SessionFlag -> SessionFlag -> Bool
(SessionFlag -> SessionFlag -> Bool)
-> (SessionFlag -> SessionFlag -> Bool) -> Eq SessionFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionFlag -> SessionFlag -> Bool
$c/= :: SessionFlag -> SessionFlag -> Bool
== :: SessionFlag -> SessionFlag -> Bool
$c== :: SessionFlag -> SessionFlag -> Bool
Eq,Int -> SessionFlag
SessionFlag -> Int
SessionFlag -> [SessionFlag]
SessionFlag -> SessionFlag
SessionFlag -> SessionFlag -> [SessionFlag]
SessionFlag -> SessionFlag -> SessionFlag -> [SessionFlag]
(SessionFlag -> SessionFlag)
-> (SessionFlag -> SessionFlag)
-> (Int -> SessionFlag)
-> (SessionFlag -> Int)
-> (SessionFlag -> [SessionFlag])
-> (SessionFlag -> SessionFlag -> [SessionFlag])
-> (SessionFlag -> SessionFlag -> [SessionFlag])
-> (SessionFlag -> SessionFlag -> SessionFlag -> [SessionFlag])
-> Enum SessionFlag
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: SessionFlag -> SessionFlag -> SessionFlag -> [SessionFlag]
$cenumFromThenTo :: SessionFlag -> SessionFlag -> SessionFlag -> [SessionFlag]
enumFromTo :: SessionFlag -> SessionFlag -> [SessionFlag]
$cenumFromTo :: SessionFlag -> SessionFlag -> [SessionFlag]
enumFromThen :: SessionFlag -> SessionFlag -> [SessionFlag]
$cenumFromThen :: SessionFlag -> SessionFlag -> [SessionFlag]
enumFrom :: SessionFlag -> [SessionFlag]
$cenumFrom :: SessionFlag -> [SessionFlag]
fromEnum :: SessionFlag -> Int
$cfromEnum :: SessionFlag -> Int
toEnum :: Int -> SessionFlag
$ctoEnum :: Int -> SessionFlag
pred :: SessionFlag -> SessionFlag
$cpred :: SessionFlag -> SessionFlag
succ :: SessionFlag -> SessionFlag
$csucc :: SessionFlag -> SessionFlag
Enum)
type CertReqContext = ByteString
data TLS13TicketInfo = TLS13TicketInfo
{ TLS13TicketInfo -> Second
lifetime :: Second
, TLS13TicketInfo -> Second
ageAdd :: Second
, TLS13TicketInfo -> Millisecond
txrxTime :: Millisecond
, TLS13TicketInfo -> Maybe Millisecond
estimatedRTT :: Maybe Millisecond
} deriving (Int -> TLS13TicketInfo -> ShowS
[TLS13TicketInfo] -> ShowS
TLS13TicketInfo -> String
(Int -> TLS13TicketInfo -> ShowS)
-> (TLS13TicketInfo -> String)
-> ([TLS13TicketInfo] -> ShowS)
-> Show TLS13TicketInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TLS13TicketInfo] -> ShowS
$cshowList :: [TLS13TicketInfo] -> ShowS
show :: TLS13TicketInfo -> String
$cshow :: TLS13TicketInfo -> String
showsPrec :: Int -> TLS13TicketInfo -> ShowS
$cshowsPrec :: Int -> TLS13TicketInfo -> ShowS
Show, TLS13TicketInfo -> TLS13TicketInfo -> Bool
(TLS13TicketInfo -> TLS13TicketInfo -> Bool)
-> (TLS13TicketInfo -> TLS13TicketInfo -> Bool)
-> Eq TLS13TicketInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TLS13TicketInfo -> TLS13TicketInfo -> Bool
$c/= :: TLS13TicketInfo -> TLS13TicketInfo -> Bool
== :: TLS13TicketInfo -> TLS13TicketInfo -> Bool
$c== :: TLS13TicketInfo -> TLS13TicketInfo -> Bool
Eq)
type CipherID = Word16
type CompressionID = Word8
data Role = ClientRole | ServerRole
deriving (Int -> Role -> ShowS
[Role] -> ShowS
Role -> String
(Int -> Role -> ShowS)
-> (Role -> String) -> ([Role] -> ShowS) -> Show Role
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Role] -> ShowS
$cshowList :: [Role] -> ShowS
show :: Role -> String
$cshow :: Role -> String
showsPrec :: Int -> Role -> ShowS
$cshowsPrec :: Int -> Role -> ShowS
Show,Role -> Role -> Bool
(Role -> Role -> Bool) -> (Role -> Role -> Bool) -> Eq Role
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Role -> Role -> Bool
$c/= :: Role -> Role -> Bool
== :: Role -> Role -> Bool
$c== :: Role -> Role -> Bool
Eq)
data Direction = Tx | Rx
deriving (Int -> Direction -> ShowS
[Direction] -> ShowS
Direction -> String
(Int -> Direction -> ShowS)
-> (Direction -> String)
-> ([Direction] -> ShowS)
-> Show Direction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Direction] -> ShowS
$cshowList :: [Direction] -> ShowS
show :: Direction -> String
$cshow :: Direction -> String
showsPrec :: Int -> Direction -> ShowS
$cshowsPrec :: Int -> Direction -> ShowS
Show,Direction -> Direction -> Bool
(Direction -> Direction -> Bool)
-> (Direction -> Direction -> Bool) -> Eq Direction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Direction -> Direction -> Bool
$c/= :: Direction -> Direction -> Bool
== :: Direction -> Direction -> Bool
$c== :: Direction -> Direction -> Bool
Eq)
invertRole :: Role -> Role
invertRole :: Role -> Role
invertRole Role
ClientRole = Role
ServerRole
invertRole Role
ServerRole = Role
ClientRole
data EarlySecret
data HandshakeSecret
data ApplicationSecret
data ResumptionSecret
newtype BaseSecret a = BaseSecret ByteString deriving Int -> BaseSecret a -> ShowS
[BaseSecret a] -> ShowS
BaseSecret a -> String
(Int -> BaseSecret a -> ShowS)
-> (BaseSecret a -> String)
-> ([BaseSecret a] -> ShowS)
-> Show (BaseSecret a)
forall a. Int -> BaseSecret a -> ShowS
forall a. [BaseSecret a] -> ShowS
forall a. BaseSecret a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BaseSecret a] -> ShowS
$cshowList :: forall a. [BaseSecret a] -> ShowS
show :: BaseSecret a -> String
$cshow :: forall a. BaseSecret a -> String
showsPrec :: Int -> BaseSecret a -> ShowS
$cshowsPrec :: forall a. Int -> BaseSecret a -> ShowS
Show
newtype AnyTrafficSecret a = AnyTrafficSecret ByteString deriving Int -> AnyTrafficSecret a -> ShowS
[AnyTrafficSecret a] -> ShowS
AnyTrafficSecret a -> String
(Int -> AnyTrafficSecret a -> ShowS)
-> (AnyTrafficSecret a -> String)
-> ([AnyTrafficSecret a] -> ShowS)
-> Show (AnyTrafficSecret a)
forall a. Int -> AnyTrafficSecret a -> ShowS
forall a. [AnyTrafficSecret a] -> ShowS
forall a. AnyTrafficSecret a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnyTrafficSecret a] -> ShowS
$cshowList :: forall a. [AnyTrafficSecret a] -> ShowS
show :: AnyTrafficSecret a -> String
$cshow :: forall a. AnyTrafficSecret a -> String
showsPrec :: Int -> AnyTrafficSecret a -> ShowS
$cshowsPrec :: forall a. Int -> AnyTrafficSecret a -> ShowS
Show
newtype ClientTrafficSecret a = ClientTrafficSecret ByteString deriving Int -> ClientTrafficSecret a -> ShowS
[ClientTrafficSecret a] -> ShowS
ClientTrafficSecret a -> String
(Int -> ClientTrafficSecret a -> ShowS)
-> (ClientTrafficSecret a -> String)
-> ([ClientTrafficSecret a] -> ShowS)
-> Show (ClientTrafficSecret a)
forall a. Int -> ClientTrafficSecret a -> ShowS
forall a. [ClientTrafficSecret a] -> ShowS
forall a. ClientTrafficSecret a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClientTrafficSecret a] -> ShowS
$cshowList :: forall a. [ClientTrafficSecret a] -> ShowS
show :: ClientTrafficSecret a -> String
$cshow :: forall a. ClientTrafficSecret a -> String
showsPrec :: Int -> ClientTrafficSecret a -> ShowS
$cshowsPrec :: forall a. Int -> ClientTrafficSecret a -> ShowS
Show
newtype ServerTrafficSecret a = ServerTrafficSecret ByteString deriving Int -> ServerTrafficSecret a -> ShowS
[ServerTrafficSecret a] -> ShowS
ServerTrafficSecret a -> String
(Int -> ServerTrafficSecret a -> ShowS)
-> (ServerTrafficSecret a -> String)
-> ([ServerTrafficSecret a] -> ShowS)
-> Show (ServerTrafficSecret a)
forall a. Int -> ServerTrafficSecret a -> ShowS
forall a. [ServerTrafficSecret a] -> ShowS
forall a. ServerTrafficSecret a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerTrafficSecret a] -> ShowS
$cshowList :: forall a. [ServerTrafficSecret a] -> ShowS
show :: ServerTrafficSecret a -> String
$cshow :: forall a. ServerTrafficSecret a -> String
showsPrec :: Int -> ServerTrafficSecret a -> ShowS
$cshowsPrec :: forall a. Int -> ServerTrafficSecret a -> ShowS
Show
data SecretTriple a = SecretTriple
{ SecretTriple a -> BaseSecret a
triBase :: BaseSecret a
, SecretTriple a -> ClientTrafficSecret a
triClient :: ClientTrafficSecret a
, SecretTriple a -> ServerTrafficSecret a
triServer :: ServerTrafficSecret a
}
data SecretPair a = SecretPair
{ SecretPair a -> BaseSecret a
pairBase :: BaseSecret a
, SecretPair a -> ClientTrafficSecret a
pairClient :: ClientTrafficSecret a
}
type TrafficSecrets a = (ClientTrafficSecret a, ServerTrafficSecret a)
newtype MasterSecret = MasterSecret ByteString deriving Int -> MasterSecret -> ShowS
[MasterSecret] -> ShowS
MasterSecret -> String
(Int -> MasterSecret -> ShowS)
-> (MasterSecret -> String)
-> ([MasterSecret] -> ShowS)
-> Show MasterSecret
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MasterSecret] -> ShowS
$cshowList :: [MasterSecret] -> ShowS
show :: MasterSecret -> String
$cshow :: MasterSecret -> String
showsPrec :: Int -> MasterSecret -> ShowS
$cshowsPrec :: Int -> MasterSecret -> ShowS
Show