diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2013-08-10 13:34:54 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2013-08-10 13:35:06 -0500 |
commit | 66e02f12198b4c9497d6193920ff80bc13551821 (patch) | |
tree | ce52cea3f5643b9a2a2c0089f1865150da66f3d7 | |
parent | bdc1636bf130c46bbc5ce550d737e6dabe80a059 (diff) |
Fix bug in parsing signature subpacket lengths.
-rw-r--r-- | Data/OpenPGP.hs | 4 | ||||
-rw-r--r-- | tests/data/3F5BBA0B0694BEB6000005-002.sig | bin | 0 -> 1089 bytes | |||
-rw-r--r-- | tests/data/3F5BBA0B0694BEB6000017-002.sig | bin | 0 -> 1089 bytes | |||
-rw-r--r-- | tests/suite.hs | 2 |
4 files changed, 4 insertions, 2 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index 3008fc2..7995d89 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs | |||
@@ -1051,9 +1051,9 @@ instance BINARY_CLASS SignatureSubpacket where | |||
1051 | get = do | 1051 | get = do |
1052 | len <- fmap fromIntegral (get :: Get Word8) | 1052 | len <- fmap fromIntegral (get :: Get Word8) |
1053 | len <- case len of | 1053 | len <- case len of |
1054 | _ | len > 190 && len < 255 -> do -- Two octet length | 1054 | _ | len >= 192 && len < 255 -> do -- Two octet length |
1055 | second <- fmap fromIntegral (get :: Get Word8) | 1055 | second <- fmap fromIntegral (get :: Get Word8) |
1056 | return $ ((len - 192) `shiftR` 8) + second + 192 | 1056 | return $ ((len - 192) `shiftL` 8) + second + 192 |
1057 | 255 -> -- Five octet length | 1057 | 255 -> -- Five octet length |
1058 | fmap fromIntegral (get :: Get Word32) | 1058 | fmap fromIntegral (get :: Get Word32) |
1059 | _ -> -- One octet length, no furthur processing | 1059 | _ -> -- One octet length, no furthur processing |
diff --git a/tests/data/3F5BBA0B0694BEB6000005-002.sig b/tests/data/3F5BBA0B0694BEB6000005-002.sig new file mode 100644 index 0000000..94055af --- /dev/null +++ b/tests/data/3F5BBA0B0694BEB6000005-002.sig | |||
Binary files differ | |||
diff --git a/tests/data/3F5BBA0B0694BEB6000017-002.sig b/tests/data/3F5BBA0B0694BEB6000017-002.sig new file mode 100644 index 0000000..b22f23b --- /dev/null +++ b/tests/data/3F5BBA0B0694BEB6000017-002.sig | |||
Binary files differ | |||
diff --git a/tests/suite.hs b/tests/suite.hs index 4bee6d6..cb4f4aa 100644 --- a/tests/suite.hs +++ b/tests/suite.hs | |||
@@ -145,6 +145,8 @@ tests = | |||
145 | testCase "uncompressed-ops-dsa.gpg" (testSerialization "uncompressed-ops-dsa.gpg"), | 145 | testCase "uncompressed-ops-dsa.gpg" (testSerialization "uncompressed-ops-dsa.gpg"), |
146 | testCase "uncompressed-ops-dsa-sha384.txt.gpg" (testSerialization "uncompressed-ops-dsa-sha384.txt.gpg"), | 146 | testCase "uncompressed-ops-dsa-sha384.txt.gpg" (testSerialization "uncompressed-ops-dsa-sha384.txt.gpg"), |
147 | testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg"), | 147 | testCase "uncompressed-ops-rsa.gpg" (testSerialization "uncompressed-ops-rsa.gpg"), |
148 | testCase "3F5BBA0B0694BEB6000005-002.sig" (testSerialization "3F5BBA0B0694BEB6000005-002.sig"), | ||
149 | testCase "3F5BBA0B0694BEB6000017-002.sig" (testSerialization "3F5BBA0B0694BEB6000017-002.sig"), | ||
148 | testProperty "MPI encode/decode" prop_MPI_serialization_loop, | 150 | testProperty "MPI encode/decode" prop_MPI_serialization_loop, |
149 | testProperty "S2K encode/decode" prop_S2K_serialization_loop, | 151 | testProperty "S2K encode/decode" prop_S2K_serialization_loop, |
150 | testProperty "SignatureSubpacket encode/decode" prop_SignatureSubpacket_serialization_loop | 152 | testProperty "SignatureSubpacket encode/decode" prop_SignatureSubpacket_serialization_loop |