    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE PatternSynonyms #-}
    {-# OPTIONS_HADDOCK hide #-}

    -- | The Struct module contains all definitions and values of the TLS
    -- protocol.
    module Network.TLS.Struct (
        Version (..),
        CipherData (..),
        CertificateType (
            CertificateType,
            CertificateType_RSA_Sign,
            CertificateType_DSA_Sign,
            CertificateType_ECDSA_Sign,
            CertificateType_Ed25519_Sign,
            CertificateType_Ed448_Sign
        ),
        fromCertificateType,
        lastSupportedCertificateType,
        DigitallySigned (..),
        Signature,
        ProtocolType (
            ..,
            ProtocolType_ChangeCipherSpec,
            ProtocolType_Alert,
            ProtocolType_Handshake,
            ProtocolType_AppData
        ),
        TLSError (..),
        TLSException (..),
        DistinguishedName,
        ServerDHParams (..),
        serverDHParamsToParams,
        serverDHParamsToPublic,
        serverDHParamsFrom,
        ServerECDHParams (..),
        ServerRSAParams (..),
        ServerKeyXchgAlgorithmData (..),
        ClientKeyXchgAlgorithmData (..),
        Packet (..),
        Header (..),
        ServerRandom (..),
        ClientRandom (..),
        FinishedData,
        VerifyData (..),
        SessionID,
        Session (..),
        SessionData (..),
        AlertLevel (
            ..,
            AlertLevel_Warning,
            AlertLevel_Fatal
        ),
        AlertDescription (
            ..,
            CloseNotify,
            UnexpectedMessage,
            BadRecordMac,
            DecryptionFailed,
            RecordOverflow,
            DecompressionFailure,
            HandshakeFailure,
            BadCertificate,
            UnsupportedCertificate,
            CertificateRevoked,
            CertificateExpired,
            CertificateUnknown,
            IllegalParameter,
            UnknownCa,
            AccessDenied,
            DecodeError,
            DecryptError,
            ExportRestriction,
            ProtocolVersion,
            InsufficientSecurity,
            InternalError,
            InappropriateFallback,
            UserCanceled,
            NoRenegotiation,
            MissingExtension,
            UnsupportedExtension,
            CertificateUnobtainable,
            UnrecognizedName,
            BadCertificateStatusResponse,
            BadCertificateHashValue,
            UnknownPskIdentity,
            CertificateRequired,
            NoApplicationProtocol
        ),
        HandshakeType (
            ..,
            HandshakeType_HelloRequest,
            HandshakeType_ClientHello,
            HandshakeType_ServerHello,
            HandshakeType_NewSessionTicket,
            HandshakeType_EndOfEarlyData,
            HandshakeType_EncryptedExtensions,
            HandshakeType_Certificate,
            HandshakeType_ServerKeyXchg,
            HandshakeType_CertRequest,
            HandshakeType_ServerHelloDone,
            HandshakeType_CertVerify,
            HandshakeType_ClientKeyXchg,
            HandshakeType_Finished,
            HandshakeType_KeyUpdate,
            HandshakeType_CompressedCertificate
        ),
        TLSCertificateChain (..),
        emptyTLSCertificateChain,
        Handshake (..),
        CH (..),
        packetType,
        typeOfHandshake,
        module Network.TLS.HashAndSignature,
        ExtensionRaw (..),
        ExtensionID (..),
        showCertificateChain,
        isHelloRetryRequest,
        hrrRandom,
    ) where

    import Data.X509 (
        CertificateChain (..),
        DistinguishedName,
        certSubjectDN,
        getCharacterStringRawData,
        getDistinguishedElements,
        getSigned,
        signedObject,
     )

    import Network.TLS.Crypto
    import Network.TLS.Error
    import {-# SOURCE #-} Network.TLS.Extension
    import Network.TLS.HashAndSignature
    import Network.TLS.Imports
    import Network.TLS.Types

    ----------------------------------------------------------------

    data CipherData = CipherData
        { CipherData -> ByteString
    cipherDataContent :: ByteString
        , CipherData -> Maybe ByteString
    cipherDataMAC :: Maybe ByteString
        , CipherData -> Maybe (ByteString, Int)
    cipherDataPadding :: Maybe (ByteString, Int)
        }
        deriving (Int -> CipherData -> ShowS
    [CipherData] -> ShowS
    CipherData -> String
    (Int -> CipherData -> ShowS)
    -> (CipherData -> String)
    -> ([CipherData] -> ShowS)
    -> Show CipherData
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CipherData -> ShowS
    showsPrec :: Int -> CipherData -> ShowS
    $cshow :: CipherData -> String
    show :: CipherData -> String
    $cshowList :: [CipherData] -> ShowS
    showList :: [CipherData] -> ShowS
    Show, CipherData -> CipherData -> Bool
    (CipherData -> CipherData -> Bool)
    -> (CipherData -> CipherData -> Bool) -> Eq CipherData
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CipherData -> CipherData -> Bool
    == :: CipherData -> CipherData -> Bool
    $c/= :: CipherData -> CipherData -> Bool
    /= :: CipherData -> CipherData -> Bool
    Eq)

    ----------------------------------------------------------------

    -- | Some of the IANA registered code points for 'CertificateType' are not
    -- currently supported by the library.  Nor should they be, they're are either
    -- unwise, obsolete or both.  There's no point in conveying these to the user
    -- in the client certificate request callback.  The request callback will be
    -- filtered to exclude unsupported values.  If the user cannot find a certificate
    -- for a supported code point, we'll go ahead without a client certificate and
    -- hope for the best, unless the user's callback decides to throw an exception.
    newtype CertificateType = CertificateType {CertificateType -> Word8
    fromCertificateType :: Word8}
        deriving (CertificateType -> CertificateType -> Bool
    (CertificateType -> CertificateType -> Bool)
    -> (CertificateType -> CertificateType -> Bool)
    -> Eq CertificateType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CertificateType -> CertificateType -> Bool
    == :: CertificateType -> CertificateType -> Bool
    $c/= :: CertificateType -> CertificateType -> Bool
    /= :: CertificateType -> CertificateType -> Bool
    Eq, Eq CertificateType
    Eq CertificateType =>
    (CertificateType -> CertificateType -> Ordering)
    -> (CertificateType -> CertificateType -> Bool)
    -> (CertificateType -> CertificateType -> Bool)
    -> (CertificateType -> CertificateType -> Bool)
    -> (CertificateType -> CertificateType -> Bool)
    -> (CertificateType -> CertificateType -> CertificateType)
    -> (CertificateType -> CertificateType -> CertificateType)
    -> Ord CertificateType
    CertificateType -> CertificateType -> Bool
    CertificateType -> CertificateType -> Ordering
    CertificateType -> CertificateType -> CertificateType
    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
    $ccompare :: CertificateType -> CertificateType -> Ordering
    compare :: CertificateType -> CertificateType -> Ordering
    $c< :: CertificateType -> CertificateType -> Bool
    < :: CertificateType -> CertificateType -> Bool
    $c<= :: CertificateType -> CertificateType -> Bool
    <= :: CertificateType -> CertificateType -> Bool
    $c> :: CertificateType -> CertificateType -> Bool
    > :: CertificateType -> CertificateType -> Bool
    $c>= :: CertificateType -> CertificateType -> Bool
    >= :: CertificateType -> CertificateType -> Bool
    $cmax :: CertificateType -> CertificateType -> CertificateType
    max :: CertificateType -> CertificateType -> CertificateType
    $cmin :: CertificateType -> CertificateType -> CertificateType
    min :: CertificateType -> CertificateType -> CertificateType
    Ord)

    {- FOURMOLU_DISABLE -}
    -- | TLS10 and up, RFC5246
    pattern CertificateType_RSA_Sign     :: CertificateType
    pattern $mCertificateType_RSA_Sign :: forall {r}. CertificateType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bCertificateType_RSA_Sign :: CertificateType
    CertificateType_RSA_Sign      = CertificateType 1
    -- | TLS10 and up, RFC5246
    pattern CertificateType_DSA_Sign     :: CertificateType
    pattern $mCertificateType_DSA_Sign :: forall {r}. CertificateType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bCertificateType_DSA_Sign :: CertificateType
    CertificateType_DSA_Sign      = CertificateType 2
    -- | TLS10 and up, RFC8422
    pattern CertificateType_ECDSA_Sign   :: CertificateType
    pattern $mCertificateType_ECDSA_Sign :: forall {r}. CertificateType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bCertificateType_ECDSA_Sign :: CertificateType
    CertificateType_ECDSA_Sign    = CertificateType 64
    -- \| There are no code points that map to the below synthetic types, these
    -- are inferred indirectly from the @signature_algorithms@ extension of the
    -- TLS 1.3 @CertificateRequest@ message.  the value assignments are there
    -- only to avoid partial function warnings.
    pattern CertificateType_Ed25519_Sign :: CertificateType
    pattern $mCertificateType_Ed25519_Sign :: forall {r}. CertificateType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bCertificateType_Ed25519_Sign :: CertificateType
    CertificateType_Ed25519_Sign  = CertificateType 254 -- fixme: dummy value
    pattern CertificateType_Ed448_Sign   :: CertificateType
    pattern $mCertificateType_Ed448_Sign :: forall {r}. CertificateType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bCertificateType_Ed448_Sign :: CertificateType
    CertificateType_Ed448_Sign    = CertificateType 255 -- fixme:  dummy value

    instance Show CertificateType where
        show :: CertificateType -> String
    show CertificateType
    CertificateType_RSA_Sign     = String
    "rsa_sign"
        show CertificateType
    CertificateType_DSA_Sign     = String
    "dss_sign"
        show CertificateType
    CertificateType_ECDSA_Sign   = String
    "ecdsa_sign"
        show CertificateType
    CertificateType_Ed25519_Sign = String
    "ed25519_sign"
        show CertificateType
    CertificateType_Ed448_Sign   = String
    "ed448_sign"
        show (CertificateType Word8
    x)          = String
    "CertificateType " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word8 -> String
    forall a. Show a => a -> String
    show Word8
    x
    {- FOURMOLU_ENABLE -}

    -- | Last supported certificate type, no 'CertificateType that
    -- compares greater than this one (based on the 'Ord' instance,
    -- not on the wire code point) will be reported to the application
    -- via the client certificate request callback.
    lastSupportedCertificateType :: CertificateType
    lastSupportedCertificateType :: CertificateType
    lastSupportedCertificateType = CertificateType
    CertificateType_ECDSA_Sign

    ------------------------------------------------------------

    type Signature = ByteString

    data DigitallySigned = DigitallySigned HashAndSignatureAlgorithm Signature
        deriving (DigitallySigned -> DigitallySigned -> Bool
    (DigitallySigned -> DigitallySigned -> Bool)
    -> (DigitallySigned -> DigitallySigned -> Bool)
    -> Eq DigitallySigned
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: DigitallySigned -> DigitallySigned -> Bool
    == :: DigitallySigned -> DigitallySigned -> Bool
    $c/= :: DigitallySigned -> DigitallySigned -> Bool
    /= :: DigitallySigned -> DigitallySigned -> Bool
    Eq)

    instance Show DigitallySigned where
        show :: DigitallySigned -> String
    show (DigitallySigned HashAndSignatureAlgorithm
    hs ByteString
    _sig) = String
    "DigitallySigned " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ HashAndSignatureAlgorithm -> String
    forall a. Show a => a -> String
    show HashAndSignatureAlgorithm
    hs String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    " \"...\""

    ----------------------------------------------------------------

    newtype ProtocolType = ProtocolType {ProtocolType -> Word8
    fromProtocolType :: Word8} deriving (ProtocolType -> ProtocolType -> Bool
    (ProtocolType -> ProtocolType -> Bool)
    -> (ProtocolType -> ProtocolType -> Bool) -> Eq ProtocolType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ProtocolType -> ProtocolType -> Bool
    == :: ProtocolType -> ProtocolType -> Bool
    $c/= :: ProtocolType -> ProtocolType -> Bool
    /= :: ProtocolType -> ProtocolType -> Bool
    Eq)

    {- FOURMOLU_DISABLE -}
    pattern ProtocolType_ChangeCipherSpec :: ProtocolType
    pattern $mProtocolType_ChangeCipherSpec :: forall {r}. ProtocolType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bProtocolType_ChangeCipherSpec :: ProtocolType
    ProtocolType_ChangeCipherSpec  = ProtocolType 20

    pattern ProtocolType_Alert            :: ProtocolType
    pattern $mProtocolType_Alert :: forall {r}. ProtocolType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bProtocolType_Alert :: ProtocolType
    ProtocolType_Alert             = ProtocolType 21

    pattern ProtocolType_Handshake        :: ProtocolType
    pattern $mProtocolType_Handshake :: forall {r}. ProtocolType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bProtocolType_Handshake :: ProtocolType
    ProtocolType_Handshake         = ProtocolType 22

    pattern ProtocolType_AppData          :: ProtocolType
    pattern $mProtocolType_AppData :: forall {r}. ProtocolType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bProtocolType_AppData :: ProtocolType
    ProtocolType_AppData           = ProtocolType 23

    instance Show ProtocolType where
        show :: ProtocolType -> String
    show ProtocolType
    ProtocolType_ChangeCipherSpec = String
    "ChangeCipherSpec"
        show ProtocolType
    ProtocolType_Alert            = String
    "Alert"
        show ProtocolType
    ProtocolType_Handshake        = String
    "Handshake"
        show ProtocolType
    ProtocolType_AppData          = String
    "AppData"
        show (ProtocolType Word8
    x)              = String
    "ProtocolType " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word8 -> String
    forall a. Show a => a -> String
    show Word8
    x
    {- FOURMOLU_ENABLE -}

    ----------------------------------------------------------------

    data Packet
        = Handshake [Handshake]
        | Alert [(AlertLevel, AlertDescription)]
        | ChangeCipherSpec
        | AppData ByteString
        deriving (Packet -> Packet -> Bool
    (Packet -> Packet -> Bool)
    -> (Packet -> Packet -> Bool) -> Eq Packet
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Packet -> Packet -> Bool
    == :: Packet -> Packet -> Bool
    $c/= :: Packet -> Packet -> Bool
    /= :: Packet -> Packet -> Bool
    Eq)

    instance Show Packet where
        show :: Packet -> String
    show (Handshake [Handshake]
    hs) = String
    "Handshake " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Handshake] -> String
    forall a. Show a => a -> String
    show [Handshake]
    hs
        show (Alert [(AlertLevel, AlertDescription)]
    as) = String
    "Alert " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [(AlertLevel, AlertDescription)] -> String
    forall a. Show a => a -> String
    show [(AlertLevel, AlertDescription)]
    as
        show Packet
    ChangeCipherSpec = String
    "ChangeCipherSpec"
        show (AppData ByteString
    bs) = String
    "AppData " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ByteString -> String
    showBytesHex ByteString
    bs

    data Header = Header ProtocolType Version Word16 deriving (Int -> Header -> ShowS
    [Header] -> ShowS
    Header -> String
    (Int -> Header -> ShowS)
    -> (Header -> String) -> ([Header] -> ShowS) -> Show Header
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Header -> ShowS
    showsPrec :: Int -> Header -> ShowS
    $cshow :: Header -> String
    show :: Header -> String
    $cshowList :: [Header] -> ShowS
    showList :: [Header] -> ShowS
    Show, Header -> Header -> Bool
    (Header -> Header -> Bool)
    -> (Header -> Header -> Bool) -> Eq Header
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Header -> Header -> Bool
    == :: Header -> Header -> Bool
    $c/= :: Header -> Header -> Bool
    /= :: Header -> Header -> Bool
    Eq)

    newtype ServerRandom = ServerRandom {ServerRandom -> ByteString
    unServerRandom :: ByteString}
        deriving (ServerRandom -> ServerRandom -> Bool
    (ServerRandom -> ServerRandom -> Bool)
    -> (ServerRandom -> ServerRandom -> Bool) -> Eq ServerRandom
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ServerRandom -> ServerRandom -> Bool
    == :: ServerRandom -> ServerRandom -> Bool
    $c/= :: ServerRandom -> ServerRandom -> Bool
    /= :: ServerRandom -> ServerRandom -> Bool
    Eq)
    instance Show ServerRandom where
        show :: ServerRandom -> String
    show sr :: ServerRandom
    sr@(ServerRandom ByteString
    bs)
            | ServerRandom -> Bool
    isHelloRetryRequest ServerRandom
    sr = String
    "HelloRetryReqest"
            | Bool
    otherwise = String
    "ServerRandom " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ByteString -> String
    showBytesHex ByteString
    bs

    hrrRandom :: ServerRandom
    hrrRandom :: ServerRandom
    hrrRandom =
        ByteString -> ServerRandom
    ServerRandom
            ByteString
    "\xCF\x21\xAD\x74\xE5\x9A\x61\x11\xBE\x1D\x8C\x02\x1E\x65\xB8\x91\xC2\xA2\x11\x16\x7A\xBB\x8C\x5E\x07\x9E\x09\xE2\xC8\xA8\x33\x9C"

    isHelloRetryRequest :: ServerRandom -> Bool
    isHelloRetryRequest :: ServerRandom -> Bool
    isHelloRetryRequest = (ServerRandom -> ServerRandom -> Bool
    forall a. Eq a => a -> a -> Bool
    == ServerRandom
    hrrRandom)

    newtype ClientRandom = ClientRandom {ClientRandom -> ByteString
    unClientRandom :: ByteString}
        deriving (ClientRandom -> ClientRandom -> Bool
    (ClientRandom -> ClientRandom -> Bool)
    -> (ClientRandom -> ClientRandom -> Bool) -> Eq ClientRandom
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ClientRandom -> ClientRandom -> Bool
    == :: ClientRandom -> ClientRandom -> Bool
    $c/= :: ClientRandom -> ClientRandom -> Bool
    /= :: ClientRandom -> ClientRandom -> Bool
    Eq)

    instance Show ClientRandom where
        show :: ClientRandom -> String
    show (ClientRandom ByteString
    bs) = String
    "ClientRandom " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ByteString -> String
    showBytesHex ByteString
    bs

    newtype Session = Session (Maybe SessionID) deriving (Session -> Session -> Bool
    (Session -> Session -> Bool)
    -> (Session -> Session -> Bool) -> Eq Session
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Session -> Session -> Bool
    == :: Session -> Session -> Bool
    $c/= :: Session -> Session -> Bool
    /= :: Session -> Session -> Bool
    Eq)
    instance Show Session where
        show :: Session -> String
    show (Session Maybe ByteString
    Nothing) = String
    "Session \"\""
        show (Session (Just ByteString
    bs)) = String
    "Session " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ByteString -> String
    showBytesHex ByteString
    bs

    {-# DEPRECATED FinishedData "use VerifyData" #-}
    type FinishedData = ByteString

    newtype VerifyData = VerifyData ByteString deriving (VerifyData -> VerifyData -> Bool
    (VerifyData -> VerifyData -> Bool)
    -> (VerifyData -> VerifyData -> Bool) -> Eq VerifyData
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: VerifyData -> VerifyData -> Bool
    == :: VerifyData -> VerifyData -> Bool
    $c/= :: VerifyData -> VerifyData -> Bool
    /= :: VerifyData -> VerifyData -> Bool
    Eq)
    instance Show VerifyData where
        show :: VerifyData -> String
    show (VerifyData ByteString
    bs) = ByteString -> String
    showBytesHex ByteString
    bs

    ----------------------------------------------------------------

    newtype HandshakeType = HandshakeType {HandshakeType -> Word8
    fromHandshakeType :: Word8}
        deriving (HandshakeType -> HandshakeType -> Bool
    (HandshakeType -> HandshakeType -> Bool)
    -> (HandshakeType -> HandshakeType -> Bool) -> Eq HandshakeType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: HandshakeType -> HandshakeType -> Bool
    == :: HandshakeType -> HandshakeType -> Bool
    $c/= :: HandshakeType -> HandshakeType -> Bool
    /= :: HandshakeType -> HandshakeType -> Bool
    Eq)

    {- FOURMOLU_DISABLE -}
    pattern HandshakeType_HelloRequest          :: HandshakeType
    pattern $mHandshakeType_HelloRequest :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_HelloRequest :: HandshakeType
    HandshakeType_HelloRequest           = HandshakeType 0
    pattern HandshakeType_ClientHello           :: HandshakeType
    pattern $mHandshakeType_ClientHello :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_ClientHello :: HandshakeType
    HandshakeType_ClientHello            = HandshakeType 1
    pattern HandshakeType_ServerHello           :: HandshakeType
    pattern $mHandshakeType_ServerHello :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_ServerHello :: HandshakeType
    HandshakeType_ServerHello            = HandshakeType 2
    pattern HandshakeType_NewSessionTicket      :: HandshakeType
    pattern $mHandshakeType_NewSessionTicket :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_NewSessionTicket :: HandshakeType
    HandshakeType_NewSessionTicket       = HandshakeType 4
    pattern HandshakeType_EndOfEarlyData        :: HandshakeType
    pattern $mHandshakeType_EndOfEarlyData :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_EndOfEarlyData :: HandshakeType
    HandshakeType_EndOfEarlyData         = HandshakeType 5
    pattern HandshakeType_EncryptedExtensions   :: HandshakeType
    pattern $mHandshakeType_EncryptedExtensions :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_EncryptedExtensions :: HandshakeType
    HandshakeType_EncryptedExtensions    = HandshakeType 8
    pattern HandshakeType_Certificate           :: HandshakeType
    pattern $mHandshakeType_Certificate :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_Certificate :: HandshakeType
    HandshakeType_Certificate            = HandshakeType 11
    pattern HandshakeType_ServerKeyXchg         :: HandshakeType
    pattern $mHandshakeType_ServerKeyXchg :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_ServerKeyXchg :: HandshakeType
    HandshakeType_ServerKeyXchg          = HandshakeType 12
    pattern HandshakeType_CertRequest           :: HandshakeType
    pattern $mHandshakeType_CertRequest :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_CertRequest :: HandshakeType
    HandshakeType_CertRequest            = HandshakeType 13
    pattern HandshakeType_ServerHelloDone       :: HandshakeType
    pattern $mHandshakeType_ServerHelloDone :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_ServerHelloDone :: HandshakeType
    HandshakeType_ServerHelloDone        = HandshakeType 14
    pattern HandshakeType_CertVerify            :: HandshakeType
    pattern $mHandshakeType_CertVerify :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_CertVerify :: HandshakeType
    HandshakeType_CertVerify             = HandshakeType 15
    pattern HandshakeType_ClientKeyXchg         :: HandshakeType
    pattern $mHandshakeType_ClientKeyXchg :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_ClientKeyXchg :: HandshakeType
    HandshakeType_ClientKeyXchg          = HandshakeType 16
    pattern HandshakeType_Finished              :: HandshakeType
    pattern $mHandshakeType_Finished :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_Finished :: HandshakeType
    HandshakeType_Finished               = HandshakeType 20
    pattern HandshakeType_KeyUpdate             :: HandshakeType
    pattern $mHandshakeType_KeyUpdate :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_KeyUpdate :: HandshakeType
    HandshakeType_KeyUpdate              = HandshakeType 24
    pattern HandshakeType_CompressedCertificate :: HandshakeType
    pattern $mHandshakeType_CompressedCertificate :: forall {r}. HandshakeType -> ((# #) -> r) -> ((# #) -> r) -> r
    $bHandshakeType_CompressedCertificate :: HandshakeType
    HandshakeType_CompressedCertificate  = HandshakeType 25

    instance Show HandshakeType where
        show :: HandshakeType -> String
    show HandshakeType
    HandshakeType_HelloRequest          = String
    "HandshakeType_HelloRequest"
        show HandshakeType
    HandshakeType_ClientHello           = String
    "HandshakeType_ClientHello"
        show HandshakeType
    HandshakeType_ServerHello           = String
    "HandshakeType_ServerHello"
        show HandshakeType
    HandshakeType_Certificate           = String
    "HandshakeType_Certificate"
        show HandshakeType
    HandshakeType_ServerKeyXchg         = String
    "HandshakeType_ServerKeyXchg"
        show HandshakeType
    HandshakeType_CertRequest           = String
    "HandshakeType_CertRequest"
        show HandshakeType
    HandshakeType_ServerHelloDone       = String
    "HandshakeType_ServerHelloDone"
        show HandshakeType
    HandshakeType_CertVerify            = String
    "HandshakeType_CertVerify"
        show HandshakeType
    HandshakeType_ClientKeyXchg         = String
    "HandshakeType_ClientKeyXchg"
        show HandshakeType
    HandshakeType_Finished              = String
    "HandshakeType_Finished"
        show HandshakeType
    HandshakeType_NewSessionTicket      = String
    "HandshakeType_NewSessionTicket"
        show HandshakeType
    HandshakeType_CompressedCertificate = String
    "HandshakeType_CompressedCertificate"
        show (HandshakeType Word8
    x)                   = String
    "HandshakeType " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Word8 -> String
    forall a. Show a => a -> String
    show Word8
    x
    {- FOURMOLU_ENABLE -}

    ----------------------------------------------------------------

    data ServerDHParams = ServerDHParams
        { ServerDHParams -> BigNum
    serverDHParams_p :: BigNum
        , ServerDHParams -> BigNum
    serverDHParams_g :: BigNum
        , ServerDHParams -> BigNum
    serverDHParams_y :: BigNum
        }
        deriving (Int -> ServerDHParams -> ShowS
    [ServerDHParams] -> ShowS
    ServerDHParams -> String
    (Int -> ServerDHParams -> ShowS)
    -> (ServerDHParams -> String)
    -> ([ServerDHParams] -> ShowS)
    -> Show ServerDHParams
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ServerDHParams -> ShowS
    showsPrec :: Int -> ServerDHParams -> ShowS
    $cshow :: ServerDHParams -> String
    show :: ServerDHParams -> String
    $cshowList :: [ServerDHParams] -> ShowS
    showList :: [ServerDHParams] -> ShowS
    Show, ServerDHParams -> ServerDHParams -> Bool
    (ServerDHParams -> ServerDHParams -> Bool)
    -> (ServerDHParams -> ServerDHParams -> Bool) -> Eq ServerDHParams
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ServerDHParams -> ServerDHParams -> Bool
    == :: ServerDHParams -> ServerDHParams -> Bool
    $c/= :: ServerDHParams -> ServerDHParams -> Bool
    /= :: ServerDHParams -> ServerDHParams -> Bool
    Eq)

    serverDHParamsFrom :: DHParams -> DHPublic -> ServerDHParams
    serverDHParamsFrom :: DHParams -> DHPublic -> ServerDHParams
    serverDHParamsFrom DHParams
    params DHPublic
    dhPub =
        BigNum -> BigNum -> BigNum -> ServerDHParams
    ServerDHParams
            (Integer -> BigNum
    bigNumFromInteger (Integer -> BigNum) -> Integer -> BigNum
    forall a b. (a -> b) -> a -> b
    $ DHParams -> Integer
    dhParamsGetP DHParams
    params)
            (Integer -> BigNum
    bigNumFromInteger (Integer -> BigNum) -> Integer -> BigNum
    forall a b. (a -> b) -> a -> b
    $ DHParams -> Integer
    dhParamsGetG DHParams
    params)
            (Integer -> BigNum
    bigNumFromInteger (Integer -> BigNum) -> Integer -> BigNum
    forall a b. (a -> b) -> a -> b
    $ DHPublic -> Integer
    dhUnwrapPublic DHPublic
    dhPub)

    serverDHParamsToParams :: ServerDHParams -> DHParams
    serverDHParamsToParams :: ServerDHParams -> DHParams
    serverDHParamsToParams ServerDHParams
    serverParams =
        Integer -> Integer -> DHParams
    dhParams
            (BigNum -> Integer
    bigNumToInteger (BigNum -> Integer) -> BigNum -> Integer
    forall a b. (a -> b) -> a -> b
    $ ServerDHParams -> BigNum
    serverDHParams_p ServerDHParams
    serverParams)
            (BigNum -> Integer
    bigNumToInteger (BigNum -> Integer) -> BigNum -> Integer
    forall a b. (a -> b) -> a -> b
    $ ServerDHParams -> BigNum
    serverDHParams_g ServerDHParams
    serverParams)

    serverDHParamsToPublic :: ServerDHParams -> DHPublic
    serverDHParamsToPublic :: ServerDHParams -> DHPublic
    serverDHParamsToPublic ServerDHParams
    serverParams =
        Integer -> DHPublic
    dhPublic (BigNum -> Integer
    bigNumToInteger (BigNum -> Integer) -> BigNum -> Integer
    forall a b. (a -> b) -> a -> b
    $ ServerDHParams -> BigNum
    serverDHParams_y ServerDHParams
    serverParams)

    ----------------------------------------------------------------

    data ServerECDHParams = ServerECDHParams Group GroupPublic
        deriving (Int -> ServerECDHParams -> ShowS
    [ServerECDHParams] -> ShowS
    ServerECDHParams -> String
    (Int -> ServerECDHParams -> ShowS)
    -> (ServerECDHParams -> String)
    -> ([ServerECDHParams] -> ShowS)
    -> Show ServerECDHParams
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ServerECDHParams -> ShowS
    showsPrec :: Int -> ServerECDHParams -> ShowS
    $cshow :: ServerECDHParams -> String
    show :: ServerECDHParams -> String
    $cshowList :: [ServerECDHParams] -> ShowS
    showList :: [ServerECDHParams] -> ShowS
    Show, ServerECDHParams -> ServerECDHParams -> Bool
    (ServerECDHParams -> ServerECDHParams -> Bool)
    -> (ServerECDHParams -> ServerECDHParams -> Bool)
    -> Eq ServerECDHParams
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ServerECDHParams -> ServerECDHParams -> Bool
    == :: ServerECDHParams -> ServerECDHParams -> Bool
    $c/= :: ServerECDHParams -> ServerECDHParams -> Bool
    /= :: ServerECDHParams -> ServerECDHParams -> Bool
    Eq)

    ----------------------------------------------------------------

    data ServerRSAParams = ServerRSAParams
        { ServerRSAParams -> Integer
    rsa_modulus :: Integer
        , ServerRSAParams -> Integer
    rsa_exponent :: Integer
        }
        deriving (Int -> ServerRSAParams -> ShowS
    [ServerRSAParams] -> ShowS
    ServerRSAParams -> String
    (Int -> ServerRSAParams -> ShowS)
    -> (ServerRSAParams -> String)
    -> ([ServerRSAParams] -> ShowS)
    -> Show ServerRSAParams
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ServerRSAParams -> ShowS
    showsPrec :: Int -> ServerRSAParams -> ShowS
    $cshow :: ServerRSAParams -> String
    show :: ServerRSAParams -> String
    $cshowList :: [ServerRSAParams] -> ShowS
    showList :: [ServerRSAParams] -> ShowS
    Show, ServerRSAParams -> ServerRSAParams -> Bool
    (ServerRSAParams -> ServerRSAParams -> Bool)
    -> (ServerRSAParams -> ServerRSAParams -> Bool)
    -> Eq ServerRSAParams
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ServerRSAParams -> ServerRSAParams -> Bool
    == :: ServerRSAParams -> ServerRSAParams -> Bool
    $c/= :: ServerRSAParams -> ServerRSAParams -> Bool
    /= :: ServerRSAParams -> ServerRSAParams -> Bool
    Eq)

    ----------------------------------------------------------------

    data ServerDSAParams = ServerDSAParams deriving (Int -> ServerDSAParams -> ShowS
    [ServerDSAParams] -> ShowS
    ServerDSAParams -> String
    (Int -> ServerDSAParams -> ShowS)
    -> (ServerDSAParams -> String)
    -> ([ServerDSAParams] -> ShowS)
    -> Show ServerDSAParams
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ServerDSAParams -> ShowS
    showsPrec :: Int -> ServerDSAParams -> ShowS
    $cshow :: ServerDSAParams -> String
    show :: ServerDSAParams -> String
    $cshowList :: [ServerDSAParams] -> ShowS
    showList :: [ServerDSAParams] -> ShowS
    Show, ServerDSAParams -> ServerDSAParams -> Bool
    (ServerDSAParams -> ServerDSAParams -> Bool)
    -> (ServerDSAParams -> ServerDSAParams -> Bool)
    -> Eq ServerDSAParams
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ServerDSAParams -> ServerDSAParams -> Bool
    == :: ServerDSAParams -> ServerDSAParams -> Bool
    $c/= :: ServerDSAParams -> ServerDSAParams -> Bool
    /= :: ServerDSAParams -> ServerDSAParams -> Bool
    Eq)

    ----------------------------------------------------------------

    data ServerKeyXchgAlgorithmData
        = SKX_DH_Anon ServerDHParams
        | SKX_DHE_DSA ServerDHParams DigitallySigned
        | SKX_DHE_RSA ServerDHParams DigitallySigned
        | SKX_ECDHE_RSA ServerECDHParams DigitallySigned
        | SKX_ECDHE_ECDSA ServerECDHParams DigitallySigned
        | SKX_RSA (Maybe ServerRSAParams)
        | SKX_DH_DSA (Maybe ServerDSAParams)
        | SKX_DH_RSA (Maybe ServerRSAParams)
        | SKX_Unparsed ByteString -- if we parse the server key xchg before knowing the actual cipher, we end up with this structure.
        | SKX_Unknown ByteString
        deriving (ServerKeyXchgAlgorithmData -> ServerKeyXchgAlgorithmData -> Bool
    (ServerKeyXchgAlgorithmData -> ServerKeyXchgAlgorithmData -> Bool)
    -> (ServerKeyXchgAlgorithmData
        -> ServerKeyXchgAlgorithmData -> Bool)
    -> Eq ServerKeyXchgAlgorithmData
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ServerKeyXchgAlgorithmData -> ServerKeyXchgAlgorithmData -> Bool
    == :: ServerKeyXchgAlgorithmData -> ServerKeyXchgAlgorithmData -> Bool
    $c/= :: ServerKeyXchgAlgorithmData -> ServerKeyXchgAlgorithmData -> Bool
    /= :: ServerKeyXchgAlgorithmData -> ServerKeyXchgAlgorithmData -> Bool
    Eq)

    {- FOURMOLU_DISABLE -}
    instance Show ServerKeyXchgAlgorithmData where
        show :: ServerKeyXchgAlgorithmData -> String
    show (SKX_DH_Anon ServerDHParams
    _)       = String
    "SKX_DH_Anon"
        show (SKX_DHE_DSA ServerDHParams
    _ DigitallySigned
    _)     = String
    "SKX_DHE_DSA"
        show (SKX_DHE_RSA ServerDHParams
    _ DigitallySigned
    _)     = String
    "SKX_DHE_RSA"
        show (SKX_ECDHE_RSA ServerECDHParams
    _ DigitallySigned
    _)   = String
    "SKX_ECDHE_RSA"
        show (SKX_ECDHE_ECDSA ServerECDHParams
    _ DigitallySigned
    _) = String
    "SKX_ECDHE_ECDSA"
        show (SKX_RSA Maybe ServerRSAParams
    _)           = String
    "SKX_RSA"
        show (SKX_DH_DSA Maybe ServerDSAParams
    _)        = String
    "SKX_DH_DSA"
        show (SKX_DH_RSA Maybe ServerRSAParams
    _)        = String
    "SKX_DH_RSA"
        show (SKX_Unparsed ByteString
    _)      = String
    "SKX_Unparsed"
        show (SKX_Unknown ByteString
    _)       = String
    "SKX_Unknown"
    {- FOURMOLU_ENABLE -}

    ----------------------------------------------------------------

    data ClientKeyXchgAlgorithmData
        = CKX_RSA ByteString
        | CKX_DH DHPublic
        | CKX_ECDH ByteString
        deriving (ClientKeyXchgAlgorithmData -> ClientKeyXchgAlgorithmData -> Bool
    (ClientKeyXchgAlgorithmData -> ClientKeyXchgAlgorithmData -> Bool)
    -> (ClientKeyXchgAlgorithmData
        -> ClientKeyXchgAlgorithmData -> Bool)
    -> Eq ClientKeyXchgAlgorithmData
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ClientKeyXchgAlgorithmData -> ClientKeyXchgAlgorithmData -> Bool
    == :: ClientKeyXchgAlgorithmData -> ClientKeyXchgAlgorithmData -> Bool
    $c/= :: ClientKeyXchgAlgorithmData -> ClientKeyXchgAlgorithmData -> Bool
    /= :: ClientKeyXchgAlgorithmData -> ClientKeyXchgAlgorithmData -> Bool
    Eq)

    instance Show ClientKeyXchgAlgorithmData where
        show :: ClientKeyXchgAlgorithmData -> String
    show (CKX_RSA ByteString
    _bs) = String
    "CKX_RSA \"...\""
        show (CKX_DH DHPublic
    pub) = String
    "CKX_DH " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ DHPublic -> String
    forall a. Show a => a -> String
    show DHPublic
    pub
        show (CKX_ECDH ByteString
    _bs) = String
    "CKX_ECDH \"...\""

    ----------------------------------------------------------------

    data CH = CH
        { CH -> Session
    chSession :: Session
        , CH -> [CipherId]
    chCiphers :: [CipherId]
        , CH -> [ExtensionRaw]
    chExtensions :: [ExtensionRaw]
        }
        deriving (Int -> CH -> ShowS
    [CH] -> ShowS
    CH -> String
    (Int -> CH -> ShowS)
    -> (CH -> String) -> ([CH] -> ShowS) -> Show CH
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> CH -> ShowS
    showsPrec :: Int -> CH -> ShowS
    $cshow :: CH -> String
    show :: CH -> String
    $cshowList :: [CH] -> ShowS
    showList :: [CH] -> ShowS
    Show, CH -> CH -> Bool
    (CH -> CH -> Bool) -> (CH -> CH -> Bool) -> Eq CH
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: CH -> CH -> Bool
    == :: CH -> CH -> Bool
    $c/= :: CH -> CH -> Bool
    /= :: CH -> CH -> Bool
    Eq)

    newtype TLSCertificateChain = TLSCertificateChain CertificateChain deriving (TLSCertificateChain -> TLSCertificateChain -> Bool
    (TLSCertificateChain -> TLSCertificateChain -> Bool)
    -> (TLSCertificateChain -> TLSCertificateChain -> Bool)
    -> Eq TLSCertificateChain
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TLSCertificateChain -> TLSCertificateChain -> Bool
    == :: TLSCertificateChain -> TLSCertificateChain -> Bool
    $c/= :: TLSCertificateChain -> TLSCertificateChain -> Bool
    /= :: TLSCertificateChain -> TLSCertificateChain -> Bool
    Eq)
    instance Show TLSCertificateChain where
        show :: TLSCertificateChain -> String
    show (TLSCertificateChain CertificateChain
    cc) = CertificateChain -> String
    showCertificateChain CertificateChain
    cc

    emptyTLSCertificateChain :: TLSCertificateChain
    emptyTLSCertificateChain :: TLSCertificateChain
    emptyTLSCertificateChain = CertificateChain -> TLSCertificateChain
    TLSCertificateChain ([SignedExact Certificate] -> CertificateChain
    CertificateChain [])

    showCertificateChain :: CertificateChain -> String
    showCertificateChain :: CertificateChain -> String
    showCertificateChain (CertificateChain [SignedExact Certificate]
    xs) = [ByteString] -> String
    forall a. Show a => a -> String
    show ([ByteString] -> String) -> [ByteString] -> String
    forall a b. (a -> b) -> a -> b
    $ (SignedExact Certificate -> ByteString)
    -> [SignedExact Certificate] -> [ByteString]
    forall a b. (a -> b) -> [a] -> [b]
    map SignedExact Certificate -> ByteString
    getName [SignedExact Certificate]
    xs
      where
        getName :: SignedExact Certificate -> ByteString
    getName =
            ByteString
    -> (ASN1CharacterString -> ByteString)
    -> Maybe ASN1CharacterString
    -> ByteString
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe ByteString
    "" ASN1CharacterString -> ByteString
    getCharacterStringRawData
                (Maybe ASN1CharacterString -> ByteString)
    -> (SignedExact Certificate -> Maybe ASN1CharacterString)
    -> SignedExact Certificate
    -> ByteString
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Integer]
    -> [([Integer], ASN1CharacterString)] -> Maybe ASN1CharacterString
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup [Integer
    2, Integer
    5, Integer
    4, Integer
    3]
                ([([Integer], ASN1CharacterString)] -> Maybe ASN1CharacterString)
    -> (SignedExact Certificate -> [([Integer], ASN1CharacterString)])
    -> SignedExact Certificate
    -> Maybe ASN1CharacterString
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . DistinguishedName -> [([Integer], ASN1CharacterString)]
    getDistinguishedElements
                (DistinguishedName -> [([Integer], ASN1CharacterString)])
    -> (SignedExact Certificate -> DistinguishedName)
    -> SignedExact Certificate
    -> [([Integer], ASN1CharacterString)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Certificate -> DistinguishedName
    certSubjectDN
                (Certificate -> DistinguishedName)
    -> (SignedExact Certificate -> Certificate)
    -> SignedExact Certificate
    -> DistinguishedName
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Signed Certificate -> Certificate
    forall a. (Show a, Eq a, ASN1Object a) => Signed a -> a
    signedObject
                (Signed Certificate -> Certificate)
    -> (SignedExact Certificate -> Signed Certificate)
    -> SignedExact Certificate
    -> Certificate
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SignedExact Certificate -> Signed Certificate
    forall a. (Show a, Eq a, ASN1Object a) => SignedExact a -> Signed a
    getSigned

    data Handshake
        = ClientHello
            Version
            ClientRandom
            [CompressionID]
            CH
        | ServerHello
            Version
            ServerRandom
            Session
            CipherId
            CompressionID
            [ExtensionRaw]
        | Certificate TLSCertificateChain
        | HelloRequest
        | ServerHelloDone
        | ClientKeyXchg ClientKeyXchgAlgorithmData
        | ServerKeyXchg ServerKeyXchgAlgorithmData
        | CertRequest
            [CertificateType]
            [HashAndSignatureAlgorithm]
            [DistinguishedName]
        | CertVerify DigitallySigned
        | Finished VerifyData
        | NewSessionTicket Second Ticket
        deriving (Int -> Handshake -> ShowS
    [Handshake] -> ShowS
    Handshake -> String
    (Int -> Handshake -> ShowS)
    -> (Handshake -> String)
    -> ([Handshake] -> ShowS)
    -> Show Handshake
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Handshake -> ShowS
    showsPrec :: Int -> Handshake -> ShowS
    $cshow :: Handshake -> String
    show :: Handshake -> String
    $cshowList :: [Handshake] -> ShowS
    showList :: [Handshake] -> ShowS
    Show, Handshake -> Handshake -> Bool
    (Handshake -> Handshake -> Bool)
    -> (Handshake -> Handshake -> Bool) -> Eq Handshake
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Handshake -> Handshake -> Bool
    == :: Handshake -> Handshake -> Bool
    $c/= :: Handshake -> Handshake -> Bool
    /= :: Handshake -> Handshake -> Bool
    Eq)

    {- FOURMOLU_DISABLE -}
    packetType :: Packet -> ProtocolType
    packetType :: Packet -> ProtocolType
    packetType (Handshake [Handshake]
    _)    = ProtocolType
    ProtocolType_Handshake
    packetType (Alert [(AlertLevel, AlertDescription)]
    _)        = ProtocolType
    ProtocolType_Alert
    packetType Packet
    ChangeCipherSpec = ProtocolType
    ProtocolType_ChangeCipherSpec
    packetType (AppData ByteString
    _)      = ProtocolType
    ProtocolType_AppData

    typeOfHandshake :: Handshake -> HandshakeType
    typeOfHandshake :: Handshake -> HandshakeType
    typeOfHandshake ClientHello{}      = HandshakeType
    HandshakeType_ClientHello
    typeOfHandshake ServerHello{}      = HandshakeType
    HandshakeType_ServerHello
    typeOfHandshake Certificate{}      = HandshakeType
    HandshakeType_Certificate
    typeOfHandshake Handshake
    HelloRequest       = HandshakeType
    HandshakeType_HelloRequest
    typeOfHandshake Handshake
    ServerHelloDone    = HandshakeType
    HandshakeType_ServerHelloDone
    typeOfHandshake ClientKeyXchg{}    = HandshakeType
    HandshakeType_ClientKeyXchg
    typeOfHandshake ServerKeyXchg{}    = HandshakeType
    HandshakeType_ServerKeyXchg
    typeOfHandshake CertRequest{}      = HandshakeType
    HandshakeType_CertRequest
    typeOfHandshake CertVerify{}       = HandshakeType
    HandshakeType_CertVerify
    typeOfHandshake Finished{}         = HandshakeType
    HandshakeType_Finished
    typeOfHandshake NewSessionTicket{} = HandshakeType
    HandshakeType_NewSessionTicket
    {- FOURMOLU_ENABLE -}