summaryrefslogtreecommitdiff
path: root/Data
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-04-25 17:40:13 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-04-25 17:41:55 -0500
commit9cb589a33a09f42afa921ed6667f652b0c52a3f0 (patch)
treecd355d848bc269f424d584d50ceb8c37ed5acca5 /Data
parentf71c938026eeaff0ca110960fd78109cca3791ce (diff)
this list is always tiny, Data.Map is overkill
Diffstat (limited to 'Data')
-rw-r--r--Data/OpenPGP.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index 99f241b..8e1979b 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -60,8 +60,6 @@ import Data.Bits
60import Data.Word 60import Data.Word
61import Data.Char 61import Data.Char
62import Data.Maybe 62import Data.Maybe
63import Data.Map (Map, (!))
64import qualified Data.Map as Map
65import qualified Data.ByteString.Lazy as LZ 63import qualified Data.ByteString.Lazy as LZ
66import qualified Data.ByteString.Lazy.UTF8 as LZ (toString, fromString) 64import qualified Data.ByteString.Lazy.UTF8 as LZ (toString, fromString)
67 65
@@ -96,13 +94,13 @@ data Packet =
96 version::Word8, 94 version::Word8,
97 timestamp::Word32, 95 timestamp::Word32,
98 key_algorithm::KeyAlgorithm, 96 key_algorithm::KeyAlgorithm,
99 key::Map Char MPI 97 key::[(Char,MPI)]
100 } | 98 } |
101 SecretKeyPacket { 99 SecretKeyPacket {
102 version::Word8, 100 version::Word8,
103 timestamp::Word32, 101 timestamp::Word32,
104 key_algorithm::KeyAlgorithm, 102 key_algorithm::KeyAlgorithm,
105 key::Map Char MPI, 103 key::[(Char,MPI)],
106 s2k_useage::Word8, -- determines if the Maybes are Just or Nothing 104 s2k_useage::Word8, -- determines if the Maybes are Just or Nothing
107 symmetric_type::Maybe Word8, 105 symmetric_type::Maybe Word8,
108 s2k_type::Maybe Word8, 106 s2k_type::Maybe Word8,
@@ -197,6 +195,9 @@ secret_key_fields ELGAMAL = ['x']
197secret_key_fields DSA = ['x'] 195secret_key_fields DSA = ['x']
198secret_key_fields _ = undefined -- Nothing in the spec. Maybe empty 196secret_key_fields _ = undefined -- Nothing in the spec. Maybe empty
199 197
198(!) :: (Eq k) => [(k,v)] -> k -> v
199(!) xs = fromJust . (`lookup` xs)
200
200-- Need this seperate for trailer calculation 201-- Need this seperate for trailer calculation
201signature_packet_start :: Packet -> LZ.ByteString 202signature_packet_start :: Packet -> LZ.ByteString
202signature_packet_start (SignaturePacket { 203signature_packet_start (SignaturePacket {
@@ -389,7 +390,7 @@ parse_packet 5 = do
389 } else do 390 } else do
390 key <- foldM (\m f -> do 391 key <- foldM (\m f -> do
391 mpi <- get :: Get MPI 392 mpi <- get :: Get MPI
392 return $ Map.insert f mpi m) key (secret_key_fields algorithm) 393 return $ (f,mpi):m) key (secret_key_fields algorithm)
393 private_hash <- getRemainingLazyByteString 394 private_hash <- getRemainingLazyByteString
394 return ((k' LZ.empty (Just private_hash)) {key = key}) 395 return ((k' LZ.empty (Just private_hash)) {key = key})
395-- PublicKeyPacket, http://tools.ietf.org/html/rfc4880#section-5.5.2 396-- PublicKeyPacket, http://tools.ietf.org/html/rfc4880#section-5.5.2
@@ -406,7 +407,7 @@ parse_packet 6 = do
406 version = 4, 407 version = 4,
407 timestamp = timestamp, 408 timestamp = timestamp,
408 key_algorithm = algorithm, 409 key_algorithm = algorithm,
409 key = Map.fromList key 410 key = key
410 } 411 }
411 x -> fail $ "Unsupported PublicKeyPacket version " ++ show x ++ "." 412 x -> fail $ "Unsupported PublicKeyPacket version " ++ show x ++ "."
412-- CompressedDataPacket, http://tools.ietf.org/html/rfc4880#section-5.6 413-- CompressedDataPacket, http://tools.ietf.org/html/rfc4880#section-5.6