summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index dfe7da36..ac7379d4 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -666,8 +666,20 @@ cryptoNetHandler sessions addr (NetCrypto (CryptoPacket nonce16 encrypted)) = do
666 lr <- fmap join $ sequence $ do -- Either Monad -- 666 lr <- fmap join $ sequence $ do -- Either Monad --
667 pubkey <- maybeToEither ncTheirSessionPublic 667 pubkey <- maybeToEither ncTheirSessionPublic
668 Right $ do -- IO Monad 668 Right $ do -- IO Monad
669 dput XNetCrypto $ "cryptoNetHandler: pubkey = " ++ show (key2id $ pubkey)
670 dput XNetCrypto $ "cryptoNetHandler: tempNonce = " ++ show tempNonce
669 secret <- lookupSharedSecret crypto ncSessionSecret pubkey tempNonce 671 secret <- lookupSharedSecret crypto ncSessionSecret pubkey tempNonce
670 return $ decodePlain =<< decrypt secret encrypted 672 let step1 = decrypt secret encrypted
673 case step1 of
674 Left s -> do
675 dput XNetCrypto $ "cryptoNetHandler: (decrypt) " ++ s
676 return (Left s)
677 Right pln -> do
678 case decodePlain pln of
679 Left s -> do
680 dput XNetCrypto $ "cryptoNetHandler: (decodePlain) " ++ s
681 return (Left s)
682 Right x -> return (Right x)
671 case lr of 683 case lr of
672 Left s -> do 684 Left s -> do
673 dput XNetCrypto $ "cryptoNetHandler: " ++ s 685 dput XNetCrypto $ "cryptoNetHandler: " ++ s
@@ -709,7 +721,7 @@ cryptoNetHandler sessions addr (NetCrypto (CryptoPacket nonce16 encrypted)) = do
709 where 721 where
710 last2Bytes :: Nonce24 -> Word16 722 last2Bytes :: Nonce24 -> Word16
711 last2Bytes (Nonce24 bs) = case S.decode (B.drop 22 bs) of 723 last2Bytes (Nonce24 bs) = case S.decode (B.drop 22 bs) of
712 Right n -> n 724 Right n -> byteSwap16 n
713 _ -> error "unreachable-last2Bytes" 725 _ -> error "unreachable-last2Bytes"
714 dATA_NUM_THRESHOLD = 21845 -- = 65535 / 3 726 dATA_NUM_THRESHOLD = 21845 -- = 65535 / 3
715 727