summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Crypto
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-05-30 03:21:43 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-05-30 03:21:43 +0000
commit2f21694c9ef0e94bc3778029ca6fe85f416cc98a (patch)
tree92cbe73b41bf40b2de27ed82659f04a99dc59a5d /src/Network/Tox/Crypto
parente8bc15e80ce585dc5d6911d310c98ce02c16eef7 (diff)
last2Bytes should be Word16
Diffstat (limited to 'src/Network/Tox/Crypto')
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index 5946c530..cd227a4d 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -657,7 +657,7 @@ cryptoNetHandler sessions addr (NetCrypto (CryptoPacket nonce16 encrypted)) = do
657 theirBaseNonce <- atomically $ readTVar ncTheirBaseNonce 657 theirBaseNonce <- atomically $ readTVar ncTheirBaseNonce
658 -- Try to decrypt message 658 -- Try to decrypt message
659 let diff :: Word16 659 let diff :: Word16
660 diff = nonce16 - fromIntegral (last2Bytes theirBaseNonce) -- truncating to Word16 660 diff = nonce16 - (last2Bytes theirBaseNonce) -- truncating to Word16
661 tempNonce = addtoNonce24 theirBaseNonce (fromIntegral diff) -- expanding to Word 661 tempNonce = addtoNonce24 theirBaseNonce (fromIntegral diff) -- expanding to Word
662 lr <- fmap join $ sequence $ do -- Either Monad -- 662 lr <- fmap join $ sequence $ do -- Either Monad --
663 pubkey <- maybeToEither ncTheirSessionPublic 663 pubkey <- maybeToEither ncTheirSessionPublic
@@ -698,7 +698,7 @@ cryptoNetHandler sessions addr (NetCrypto (CryptoPacket nonce16 encrypted)) = do
698 else do atomically $ PQ.enqueue ncPacketQueue bufferEnd cd 698 else do atomically $ PQ.enqueue ncPacketQueue bufferEnd cd
699 return Nothing 699 return Nothing
700 where 700 where
701 last2Bytes :: Nonce24 -> Word 701 last2Bytes :: Nonce24 -> Word16
702 last2Bytes (Nonce24 bs) = case S.decode (B.drop 22 bs) of 702 last2Bytes (Nonce24 bs) = case S.decode (B.drop 22 bs) of
703 Right n -> n 703 Right n -> n
704 _ -> error "unreachable-last2Bytes" 704 _ -> error "unreachable-last2Bytes"