Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Dec 9, 2023
1 parent f6eb002 commit d5e7da5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/Network/TLS/Handshake/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ handshake cparams ctx groups mparams = do
| otherwise -> do
recvServerFirstFlight12 cparams ctx hss
sendClientSecondFlight12 cparams ctx
recvServerSecondFlight12 ctx
where
groupToSend = listToMaybe groups
{- FOURMOLU_ENABLE -}
Expand Down
16 changes: 12 additions & 4 deletions core/Network/TLS/Handshake/Client/TLS12.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Network.TLS.Handshake.Client.TLS12 (
recvServerFirstFlight12,
sendClientSecondFlight12,
recvServerSecondFlight12,
) where

import Control.Monad.State.Strict
Expand Down Expand Up @@ -82,9 +83,13 @@ sendClientSecondFlight12 cparams ctx = do
if sessionResuming
then sendChangeCipherAndFinish ctx ClientRole
else do
sendClientData cparams ctx
sendClientCCC cparams ctx
sendChangeCipherAndFinish ctx ClientRole
recvChangeCipherAndFinish ctx

recvServerSecondFlight12 :: Context -> IO ()
recvServerSecondFlight12 ctx = do
sessionResuming <- usingState_ ctx isSessionResuming
unless sessionResuming $ recvChangeCipherAndFinish ctx
handshakeDone ctx

----------------------------------------------------------------
Expand All @@ -102,8 +107,11 @@ sendClientSecondFlight12 cparams ctx = do
-- -> [certificate]
-- -> client key exchange
-- -> [cert verify]
sendClientData :: ClientParams -> Context -> IO ()
sendClientData cparams ctx = sendCertificate >> sendClientKeyXchg >> sendCertificateVerify
sendClientCCC :: ClientParams -> Context -> IO ()
sendClientCCC cparams ctx = do
sendCertificate
sendClientKeyXchg
sendCertificateVerify
where
sendCertificate = do
usingHState ctx $ setClientCertSent False
Expand Down

0 comments on commit d5e7da5

Please sign in to comment.