diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-30 04:12:30 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-30 04:12:30 +0000 |
commit | 0ffb1d36efb141e1701469af8896e9022323d744 (patch) | |
tree | 726923e841dab12bb96b553b021e7b523ebb7529 /src | |
parent | f9cacd68d01a060e4cef252f8930bee959ba68da (diff) |
decryption bug, try byteswap on last2Bytes
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 16 |
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 | ||