1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
module Network.TLS.Struct13 (
Packet13 (..),
Handshake13 (..),
typeOfHandshake13,
contentType,
KeyUpdate (..),
CertReqContext,
isKeyUpdate13,
) where
import Network.TLS.Imports
import Network.TLS.Struct
import Network.TLS.Types
data Packet13
= Handshake13 [Handshake13]
| Alert13 [(AlertLevel, AlertDescription)]
| ChangeCipherSpec13
| AppData13 ByteString
deriving (Show, Eq)
data KeyUpdate
= UpdateNotRequested
| UpdateRequested
deriving (Show, Eq)
type TicketNonce = ByteString
-- fixme: convert Word32 to proper data type
data Handshake13
= ServerHello13 ServerRandom Session CipherId [ExtensionRaw]
| NewSessionTicket13 Second Word32 TicketNonce SessionIDorTicket [ExtensionRaw]
| EndOfEarlyData13
| EncryptedExtensions13 [ExtensionRaw]
| Certificate13 CertReqContext TLSCertificateChain [[ExtensionRaw]]
| CertRequest13 CertReqContext [ExtensionRaw]
| CertVerify13 DigitallySigned
| Finished13 VerifyData
| KeyUpdate13 KeyUpdate
| CompressedCertificate13 CertReqContext TLSCertificateChain [[ExtensionRaw]]
deriving (Show, Eq)
-- | Certificate request context for TLS 1.3.
type CertReqContext = ByteString
{- FOURMOLU_DISABLE -}
typeOfHandshake13 :: Handshake13 -> HandshakeType
typeOfHandshake13 ServerHello13{} = HandshakeType_ServerHello
typeOfHandshake13 NewSessionTicket13{} = HandshakeType_NewSessionTicket
typeOfHandshake13 EndOfEarlyData13{} = HandshakeType_EndOfEarlyData
typeOfHandshake13 EncryptedExtensions13{} = HandshakeType_EncryptedExtensions
typeOfHandshake13 Certificate13{} = HandshakeType_Certificate
typeOfHandshake13 CertRequest13{} = HandshakeType_CertRequest
typeOfHandshake13 CertVerify13{} = HandshakeType_CertVerify
typeOfHandshake13 Finished13{} = HandshakeType_Finished
typeOfHandshake13 KeyUpdate13{} = HandshakeType_KeyUpdate
typeOfHandshake13 CompressedCertificate13{} = HandshakeType_CompressedCertificate
contentType :: Packet13 -> ProtocolType
contentType ChangeCipherSpec13 = ProtocolType_ChangeCipherSpec
contentType Handshake13{} = ProtocolType_Handshake
contentType Alert13{} = ProtocolType_Alert
contentType AppData13{} = ProtocolType_AppData
{- FOURMOLU_ENABLE -}
isKeyUpdate13 :: Handshake13 -> Bool
isKeyUpdate13 (KeyUpdate13 _) = True
isKeyUpdate13 _ = False
|