diff options
Diffstat (limited to 'src/Crypto/Tox.hs')
-rw-r--r-- | src/Crypto/Tox.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs index 8bb822d8..9b7e82c0 100644 --- a/src/Crypto/Tox.hs +++ b/src/Crypto/Tox.hs | |||
@@ -594,12 +594,13 @@ decodeSecret k64 = do | |||
594 | CryptoPassed x -> Just x | 594 | CryptoPassed x -> Just x |
595 | _ -> Nothing | 595 | _ -> Nothing |
596 | 596 | ||
597 | -- Treats byte pairs as big-endian. | ||
597 | xorsum :: ByteArrayAccess ba => ba -> Word16 | 598 | xorsum :: ByteArrayAccess ba => ba -> Word16 |
598 | xorsum bs = unsafeDupablePerformIO $ BA.withByteArray bs $ \ptr16 -> do | 599 | xorsum bs = unsafeDupablePerformIO $ BA.withByteArray bs $ \ptr16 -> do |
599 | let (wcnt,r) = BA.length bs `divMod` 2 | 600 | let (wcnt,r) = BA.length bs `divMod` 2 |
600 | loop cnt !ac = do | 601 | loop cnt !ac = do |
601 | ac' <- xor ac <$> peekElemOff ptr16 cnt | 602 | ac' <- xor ac <$> peekElemOff ptr16 cnt |
602 | case cnt of 0 -> return ac' | 603 | case cnt of 0 -> return $ fromBE16 ac' |
603 | _ -> loop (cnt - 1) ac' | 604 | _ -> loop (cnt - 1) ac' |
604 | loop (wcnt - 1) $ case r of | 605 | loop (wcnt - 1) $ case r of |
605 | 0 -> 0 | 606 | 0 -> 0 |