trivial code movement for decryptRSA

This commit is contained in:
Vincent Hanquez 2011-12-20 07:47:46 +00:00
parent 89ad99004b
commit f3e5603bc8

View file

@ -78,6 +78,12 @@ processHandshake hs = do
-- unknown extensions
processClientExtension _ = return ()
decryptRSA :: ByteString -> TLSSt (Either KxError ByteString)
decryptRSA econtent = do
ver <- stVersion <$> get
rsapriv <- fromJust "rsa private key" . hstRSAPrivateKey . fromJust "handshake" . stHandshake <$> get
return $ kxDecrypt rsapriv (if ver < TLS10 then econtent else B.drop 2 econtent)
processServerHello :: Handshake -> TLSSt ()
processServerHello (ServerHello sver ran _ _ _ ex) = do
-- FIXME notify the user to take action if the extension requested is missing
@ -97,12 +103,6 @@ processServerHello (ServerHello sver ran _ _ _ ex) = do
processServerExtension _ = return ()
processServerHello _ = error "processServerHello called on wrong type"
decryptRSA :: ByteString -> TLSSt (Either KxError ByteString)
decryptRSA econtent = do
ver <- stVersion <$> get
rsapriv <- fromJust "rsa private key" . hstRSAPrivateKey . fromJust "handshake" . stHandshake <$> get
return $ kxDecrypt rsapriv (if ver < TLS10 then econtent else B.drop 2 econtent)
-- process the client key exchange message. the protocol expects the initial
-- client version received in ClientHello, not the negociated version.
-- in case the version mismatch, generate a random master secret