diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-31 12:50:59 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-31 12:50:59 +0000 |
commit | 7008671663916828d89bfff5441803dea10f1e00 (patch) | |
tree | 5c666a5e782f33e657b156232a832eb512a92100 /src/Network/Tox/Crypto/Handlers.hs | |
parent | 1b78cae637fa28001214697ca042e907b9f5af4f (diff) |
debugging sessionPacketH
Diffstat (limited to 'src/Network/Tox/Crypto/Handlers.hs')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index 0dc7f08d..bc7d7af8 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -559,6 +559,7 @@ freshCryptoSession sessions | |||
559 | dropNum <- atomically $ newTVar 0 | 559 | dropNum <- atomically $ newTVar 0 |
560 | theirbasenonce <- atomically $ readTVar ncTheirBaseNonce0 | 560 | theirbasenonce <- atomically $ readTVar ncTheirBaseNonce0 |
561 | dput XNetCrypto $ "freshCryptoSession: Session ncTheirBaseNonce=" ++ show theirbasenonce | 561 | dput XNetCrypto $ "freshCryptoSession: Session ncTheirBaseNonce=" ++ show theirbasenonce |
562 | dput XNetCrypto $ "freshCryptoSession: My Session Public =" ++ show (key2id $ toPublic newsession) | ||
562 | ncTheirSessionPublic0 <- atomically $ newTVar (frmMaybe mbtheirSessionKey) | 563 | ncTheirSessionPublic0 <- atomically $ newTVar (frmMaybe mbtheirSessionKey) |
563 | let netCryptoSession0 = | 564 | let netCryptoSession0 = |
564 | NCrypto { ncState = ncState0 | 565 | NCrypto { ncState = ncState0 |
@@ -606,7 +607,10 @@ createNetCryptoOutQueue sessions newsession theirSessionKey pktq ncMyPacketNonce | |||
606 | atomically $ do | 607 | atomically $ do |
607 | n24 <- readTVar ncMyPacketNonce0 | 608 | n24 <- readTVar ncMyPacketNonce0 |
608 | let n24plus1 = incrementNonce24 n24 | 609 | let n24plus1 = incrementNonce24 n24 |
609 | trace ("ncMyPacketNonce+1=" ++ show n24plus1) $ writeTVar ncMyPacketNonce0 n24plus1 | 610 | trace ("ncMyPacketNonce+1=" ++ show n24plus1 |
611 | ++ "\n toWireIO: theirSessionKey = " ++ show (key2id theirSessionKey) | ||
612 | ++ "\n toWireIO: my public session key = " ++ show (key2id (toPublic newsession)) | ||
613 | ) $ writeTVar ncMyPacketNonce0 n24plus1 | ||
610 | return (return (f n24, n24, ncOutgoingIdMap0)) | 614 | return (return (f n24, n24, ncOutgoingIdMap0)) |
611 | pktoq <- atomically $ PQ.newOutGoing pktq ncToWire toWireIO 0 (outboundQueueCapacity sessions) 0 | 615 | pktoq <- atomically $ PQ.newOutGoing pktq ncToWire toWireIO 0 (outboundQueueCapacity sessions) 0 |
612 | return (HaveHandshake pktoq) | 616 | return (HaveHandshake pktoq) |
@@ -710,7 +714,9 @@ updateCryptoSession sessions addr hp session handshake = do | |||
710 | ++ bool "(/=)" "(==)" (toMaybe ncTheirBaseNonce0 == hpTheirBaseNonce hp) | 714 | ++ bool "(/=)" "(==)" (toMaybe ncTheirBaseNonce0 == hpTheirBaseNonce hp) |
711 | ++ "hpTheirBaseNonce=" ++ show (hpTheirBaseNonce hp)) | 715 | ++ "hpTheirBaseNonce=" ++ show (hpTheirBaseNonce hp)) |
712 | if ( ncTheirBaseNonce0 /= frmMaybe (hpTheirBaseNonce hp)) | 716 | if ( ncTheirBaseNonce0 /= frmMaybe (hpTheirBaseNonce hp)) |
713 | then freshCryptoSession sessions addr hp -- basenonce mismatch, trigger refresh | 717 | then do |
718 | dput XNetCrypto "basenonce mismatch, trigger refresh" | ||
719 | freshCryptoSession sessions addr hp -- basenonce mismatch, trigger refresh | ||
714 | else atomically $ writeTVar (ncState session) {-Accepted-}(InProgress AwaitingSessionPacket) | 720 | else atomically $ writeTVar (ncState session) {-Accepted-}(InProgress AwaitingSessionPacket) |
715 | 721 | ||
716 | anyRight :: Monad m => a -> [t] -> (t -> m (Either b b1)) -> m (Either a b1) | 722 | anyRight :: Monad m => a -> [t] -> (t -> m (Either b b1)) -> m (Either a b1) |
@@ -833,6 +839,8 @@ sessionPacketH sessions addr (CryptoPacket nonce16 encrypted) = do | |||
833 | dput XNetCrypto $ "(NetCrypto)sessionPacketH: theirBaseNonce = " ++ show theirBaseNonce | 839 | dput XNetCrypto $ "(NetCrypto)sessionPacketH: theirBaseNonce = " ++ show theirBaseNonce |
834 | dput XNetCrypto $ "(NetCrypto)sessionPacketH: tempNonce = " ++ show tempNonce | 840 | dput XNetCrypto $ "(NetCrypto)sessionPacketH: tempNonce = " ++ show tempNonce |
835 | ++ " nonce16=" ++ printf "0x%x" nonce16 ++ " last2bytes =" ++ printf "0x%x" (last2Bytes theirBaseNonce) | 841 | ++ " nonce16=" ++ printf "0x%x" nonce16 ++ " last2bytes =" ++ printf "0x%x" (last2Bytes theirBaseNonce) |
842 | dput XNetCrypto $ "(NetCrypto)sessionPacketH: mySession public=" ++ show (key2id $ toPublic ncSessionSecret) | ||
843 | dput XNetCrypto $ "(NetCrypto)sessionPacketH: theirSession public=" ++ show (key2id $ pubkey) | ||
836 | secret <- lookupSharedSecret crypto ncSessionSecret pubkey tempNonce | 844 | secret <- lookupSharedSecret crypto ncSessionSecret pubkey tempNonce |
837 | let step1 = decrypt secret encrypted | 845 | let step1 = decrypt secret encrypted |
838 | case step1 of | 846 | case step1 of |