summaryrefslogtreecommitdiff
path: root/Data
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-04-24 16:03:02 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-04-24 16:03:02 -0500
commit31e12ded73e1bf58ab565e99ab32884cde8e2c8e (patch)
treeafad71817fafc3b37b9cbbaf3e5131766fc8234d /Data
parent7d75d59b4c089f0a9ef2a3cccd099b3a3a847a7e (diff)
private_hash may be inside the encrypted blob
Diffstat (limited to 'Data')
-rw-r--r--Data/OpenPGP.hs21
1 files changed, 11 insertions, 10 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index e0361a7..233ff68 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -60,7 +60,7 @@ data Packet =
60 s2k_salt::Word64, 60 s2k_salt::Word64,
61 s2k_count::Word8, 61 s2k_count::Word8,
62 encrypted_data::LZ.ByteString, 62 encrypted_data::LZ.ByteString,
63 private_hash::LZ.ByteString 63 private_hash::Maybe LZ.ByteString -- the hash may be in the encrypted data
64 } | 64 } |
65 CompressedDataPacket { 65 CompressedDataPacket {
66 compression_algorithm::CompressionAlgorithm, 66 compression_algorithm::CompressionAlgorithm,
@@ -223,13 +223,14 @@ put_packet (SecretKeyPacket { version = version, timestamp = timestamp,
223 else []) ++ 223 else []) ++
224 (if s2k_useage > 0 then 224 (if s2k_useage > 0 then
225 [encrypted_data] 225 [encrypted_data]
226 else s) ++ 226 else s ++
227 (if s2k_useage == 254 then 227 -- XXX: Checksum is part of encrypted_data for V4 ONLY
228 [LZ.replicate 20 0] -- TODO SHA1 Checksum 228 if s2k_useage == 254 then
229 else 229 [LZ.replicate 20 0] -- TODO SHA1 Checksum
230 [encode (fromIntegral $ 230 else
231 LZ.foldl (\c i -> (c + fromIntegral i) `mod` 65536) 231 [encode (fromIntegral $
232 (0::Integer) (LZ.concat s) :: Word16)]), 5) 232 LZ.foldl (\c i -> (c + fromIntegral i) `mod` 65536)
233 (0::Integer) (LZ.concat s) :: Word16)]), 5)
233 where 234 where
234 p = fst (put_packet $ PublicKeyPacket version timestamp algorithm key 235 p = fst (put_packet $ PublicKeyPacket version timestamp algorithm key
235 :: (LZ.ByteString, Integer)) -- Supress warning 236 :: (LZ.ByteString, Integer)) -- Supress warning
@@ -337,13 +338,13 @@ parse_packet 5 = do
337 return (k undefined undefined undefined undefined undefined) 338 return (k undefined undefined undefined undefined undefined)
338 if s2k_useage > 0 then do { 339 if s2k_useage > 0 then do {
339 encrypted <- getRemainingLazyByteString; 340 encrypted <- getRemainingLazyByteString;
340 return (k' encrypted undefined) 341 return (k' encrypted Nothing)
341 } else do 342 } else do
342 key <- foldM (\m f -> do 343 key <- foldM (\m f -> do
343 mpi <- get :: Get MPI 344 mpi <- get :: Get MPI
344 return $ Map.insert f mpi m) key (secret_key_fields algorithm) 345 return $ Map.insert f mpi m) key (secret_key_fields algorithm)
345 private_hash <- getRemainingLazyByteString 346 private_hash <- getRemainingLazyByteString
346 return ((k' undefined private_hash) {key = key}) 347 return ((k' undefined (Just private_hash)) {key = key})
347-- PublicKeyPacket, http://tools.ietf.org/html/rfc4880#section-5.5.2 348-- PublicKeyPacket, http://tools.ietf.org/html/rfc4880#section-5.5.2
348parse_packet 6 = do 349parse_packet 6 = do
349 version <- get :: Get Word8 350 version <- get :: Get Word8