summaryrefslogtreecommitdiff
path: root/Data
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-04-27 13:07:54 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-04-27 13:07:54 -0500
commit16f0cd61f101ad1de2da3b3445b7f31b124de317 (patch)
tree8a452edade6b91951bc8c189b185e57b7853beb9 /Data
parent2ed08625f7f56ab5c086498d47242299cff10e98 (diff)
MPI encode/decode QuickCheck
Diffstat (limited to 'Data')
-rw-r--r--Data/OpenPGP.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index bf7cdf5..63d4dc1 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -56,6 +56,7 @@ module Data.OpenPGP (
56 56
57import Numeric 57import Numeric
58import Control.Monad 58import Control.Monad
59import Control.Exception (assert)
59import Data.Bits 60import Data.Bits
60import Data.Word 61import Data.Word
61import Data.Char 62import Data.Char
@@ -632,10 +633,11 @@ instance BINARY_CLASS MPI where
632 + 1 :: Word16) 633 + 1 :: Word16)
633 putSomeByteString bytes 634 putSomeByteString bytes
634 where 635 where
635 bytes = B.reverse $ B.unfoldr (\x -> 636 bytes = if B.null bytes' then B.singleton 0 else bytes'
637 bytes' = B.reverse $ B.unfoldr (\x ->
636 if x == 0 then Nothing else 638 if x == 0 then Nothing else
637 Just (fromIntegral x, x `shiftR` 8) 639 Just (fromIntegral x, x `shiftR` 8)
638 ) i 640 ) (assert (i>=0) i)
639 get = do 641 get = do
640 length <- fmap fromIntegral (get :: Get Word16) 642 length <- fmap fromIntegral (get :: Get Word16)
641 bytes <- getSomeByteString ((length + 7) `div` 8) 643 bytes <- getSomeByteString ((length + 7) `div` 8)