Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
109 lines (100 sloc) 4.93 KB
--- Data/OpenPGP/Arbitrary.hs 2012-04-27 12:38:11.492411339 -0500
+++ arb.s 2012-04-27 12:37:57.176469214 -0500
@@ -1 +1,2 @@
+{-# OPTIONS_GHC -fno-warn-orphans -fno-warn-unused-imports #-}
module Data.OpenPGP.Arbitrary where
@@ -14,13 +14,18 @@
1 -> do x1 <- arbitrary
x2 <- arbitrary
x3 <- arbitrary
- x4 <- arbitrary
- x5 <- arbitrary
+ x4 <- resize 10 (listOf arbitrary)
+ x5 <- resize 10 (listOf arbitrary)
x6 <- arbitrary
x7 <- arbitrary
- x8 <- arbitrary
- x9 <- arbitrary
- return (SignaturePacket x1 x2 x3 x4 x5 x6 x7 x8 x9)
+ version <- choose (2 :: Word8, 4)
+ case version of
+ 4 ->
+ return (signaturePacket 4 x1 x2 x3 x4 x5 x6 x7)
+ _ -> do
+ creation_time <- arbitrary
+ keyid <- vectorOf 16 (elements (['0'..'9'] ++ ['A'..'F']))
+ return (signaturePacket version x1 x2 x3 [] [SignatureCreationTimePacket creation_time, IssuerPacket keyid] x6 x7)
2 -> do x1 <- arbitrary
x2 <- arbitrary
x3 <- arbitrary
@@ -88,5 +93,5 @@
x2 <- arbitrary
- x3 <- arbitrary
+ x3 <- fmap decode_s2k_count arbitrary
return (IteratedSaltedS2K x1 x2 x3)
- 3 -> do x1 <- arbitrary
+ 3 -> do x1 <- suchThat arbitrary (`notElem` [0,1,3])
x2 <- arbitrary
@@ -73,7 +72,7 @@
4 -> return SHA384
5 -> return SHA512
6 -> return SHA224
- 7 -> do x1 <- arbitrary
+ 7 -> do x1 <- suchThat arbitrary (`notElem` [01,02,03,08,09,10,11])
return (HashAlgorithm x1)
_ -> error "FATAL ERROR: Arbitrary instance, logic bug"
@@ -90,7 +89,7 @@
5 -> return ECC
6 -> return ECDSA
7 -> return DH
- 8 -> do x1 <- arbitrary
+ 8 -> do x1 <- suchThat arbitrary (`notElem` [01,02,03,16,17,18,19,21])
return (KeyAlgorithm x1)
_ -> error "FATAL ERROR: Arbitrary instance, logic bug"
@@ -108,7 +107,7 @@
6 -> return AES192
7 -> return AES256
8 -> return Twofish
- 9 -> do x1 <- arbitrary
+ 9 -> do x1 <- suchThat arbitrary (`notElem` [00,01,02,03,04,07,08,09,10])
return (SymmetricAlgorithm x1)
_ -> error "FATAL ERROR: Arbitrary instance, logic bug"
@@ -121,7 +120,7 @@
1 -> return ZIP
2 -> return ZLIB
3 -> return BZip2
- 4 -> do x1 <- arbitrary
+ 4 -> do x1 <- suchThat arbitrary (`notElem` [0,1,2,3])
return (CompressionAlgorithm x1)
_ -> error "FATAL ERROR: Arbitrary instance, logic bug"
@@ -135,7 +134,7 @@
2 -> return KeyCompromised
3 -> return KeyRetired
4 -> return UserIDInvalid
- 5 -> do x1 <- arbitrary
+ 5 -> do x1 <- suchThat arbitrary (`notElem` [00,01,02,03,32])
return (RevocationCode x1)
_ -> error "FATAL ERROR: Arbitrary instance, logic bug"
@@ -134,7 +133,7 @@
instance Arbitrary MPI where
arbitrary
- = do x1 <- arbitrary
+ = do x1 <- suchThat arbitrary (>=0)
return (MPI x1)
@@ -160,5 +160,5 @@
return (PreferredSymmetricAlgorithmsPacket x1)
8 -> do x1 <- arbitrary
x2 <- arbitrary
- x3 <- arbitrary
+ x3 <- vectorOf 40 (elements (['0'..'9'] ++ ['A'..'F']))
return (RevocationKeyPacket x1 x2 x3)
@@ -166 +165 @@
- 9 -> do x1 <- arbitrary
+ 9 -> do x1 <- vectorOf 16 (elements (['0'..'9'] ++ ['A'..'F']))
@@ -217 +216 @@
- 22 -> do x1 <- arbitrary
+ 22 -> do x1 <- suchThat arbitrary isSignaturePacket
@@ -169,2 +168 @@
- x2 <- arbitrary
- return (UnsupportedSignatureSubpacket x1 x2)
+ return (UnsupportedSignatureSubpacket 105 x1)