diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-29 06:59:11 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-29 06:59:11 +0000 |
commit | 24fc5b3077dc8ea810a7b1d6c685a29c26562ad7 (patch) | |
tree | 9f884aa3ddf2898bcc75684cb620e30e62dd3844 /src/Network | |
parent | bef702cf30f1386a5ad11abaee6f37f6e496138f (diff) |
handshake nonce debug prints
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/Tox.hs | 2 | ||||
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index 69982c81..5ad9c041 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs | |||
@@ -112,6 +112,7 @@ import qualified Data.HashMap.Strict as HashMap | |||
112 | import Data.HashMap.Strict (HashMap) | 112 | import Data.HashMap.Strict (HashMap) |
113 | import qualified Data.Map.Strict as Map | 113 | import qualified Data.Map.Strict as Map |
114 | import Control.Concurrent (threadDelay) | 114 | import Control.Concurrent (threadDelay) |
115 | import DPut | ||
115 | 116 | ||
116 | 117 | ||
117 | newCrypto :: IO TransportCrypto | 118 | newCrypto :: IO TransportCrypto |
@@ -321,6 +322,7 @@ netCryptoWithBackoff millisecs tox myseckey theirpubkey = do | |||
321 | , hpTheirSessionKeyPublic = error "netCrypto: Unreachable! hpTheirSessionKeyPublic" | 322 | , hpTheirSessionKeyPublic = error "netCrypto: Unreachable! hpTheirSessionKeyPublic" |
322 | } | 323 | } |
323 | n24' <- atomically $ transportNewNonce crypto | 324 | n24' <- atomically $ transportNewNonce crypto |
325 | dput XNetCrypto ("Handshake Nonce24: " <> show n24') | ||
324 | state <- lookupSharedSecret crypto myseckey theirDhtKey n24' | 326 | state <- lookupSharedSecret crypto myseckey theirDhtKey n24' |
325 | newBaseNonce <- atomically $ transportNewNonce crypto | 327 | newBaseNonce <- atomically $ transportNewNonce crypto |
326 | mbMyhandshakeData <- newHandShakeData crypto newBaseNonce hp saddr | 328 | mbMyhandshakeData <- newHandShakeData crypto newBaseNonce hp saddr |
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index d192e42e..485c5219 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -553,8 +553,20 @@ cryptoNetHandler sessions addr (NetHandshake (Handshake (Cookie n24 ecookie) non | |||
553 | (CookieData cookieTime remotePubkey remoteDhtkey) <- (decodePlain =<< decryptSymmetric symkey n24 ecookie) | 553 | (CookieData cookieTime remotePubkey remoteDhtkey) <- (decodePlain =<< decryptSymmetric symkey n24 ecookie) |
554 | Right $ do -- IO Monad | 554 | Right $ do -- IO Monad |
555 | decrypted <- anyRight seckeys $ \key -> do | 555 | decrypted <- anyRight seckeys $ \key -> do |
556 | dput XNetCrypto $ "cryptoNetHandler: remotePubkey = " ++ show (key2id $ remotePubkey) | ||
557 | dput XNetCrypto $ "cryptoNetHandler: nonce24 = " ++ show nonce24 | ||
556 | secret <- lookupSharedSecret crypto key remotePubkey nonce24 | 558 | secret <- lookupSharedSecret crypto key remotePubkey nonce24 |
557 | return $ (key,) <$> (decodePlain =<< decrypt secret encrypted) | 559 | let step1 = decrypt secret encrypted |
560 | case step1 of | ||
561 | Left s -> do | ||
562 | dput XNetCrypto $ "cryptoNetHandler: (decrypt) " ++ s | ||
563 | return (Left s) | ||
564 | Right pln -> do | ||
565 | case decodePlain pln of | ||
566 | Left s -> do | ||
567 | dput XNetCrypto $ "cryptoNetHandler: (decodePlain) " ++ s | ||
568 | return (Left s) | ||
569 | Right x -> return (Right (key,x)) | ||
558 | return $ do -- Either Monad | 570 | return $ do -- Either Monad |
559 | (key,HandshakeData { baseNonce, sessionKey, cookieHash, otherCookie }) <- decrypted | 571 | (key,HandshakeData { baseNonce, sessionKey, cookieHash, otherCookie }) <- decrypted |
560 | -- check cookie time < 15 seconds ago | 572 | -- check cookie time < 15 seconds ago |