Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions Data/OpenPGP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,14 @@ parse_packet 5 = do
-- PublicKeyPacket, http://tools.ietf.org/html/rfc4880#section-5.5.2
parse_packet 6 = do
version <- get :: Get Word8
case version of
3 -> do
let getVersionPacket version
| version `elem` [2, 3, 4] = do
timestamp <- get
days <- get
days <-
if version == 4 then
return Nothing
else
fmap Just get
algorithm <- get
key <- mapM (\f -> fmap ((,)f) get) (public_key_fields algorithm)
return PublicKeyPacket {
Expand All @@ -639,21 +643,11 @@ parse_packet 6 = do
key_algorithm = algorithm,
key = key,
is_subkey = False,
v3_days_of_validity = Just days
}
4 -> do
timestamp <- get
algorithm <- get
key <- mapM (\f -> fmap ((,)f) get) (public_key_fields algorithm)
return PublicKeyPacket {
version = 4,
timestamp = timestamp,
key_algorithm = algorithm,
key = key,
is_subkey = False,
v3_days_of_validity = Nothing
v3_days_of_validity = days
}
x -> fail $ "Unsupported PublicKeyPacket version " ++ show x ++ "."
| otherwise =
fail $ "Unsupported PublicKeyPacket version " ++ show version ++ "."
getVersionPacket version
-- Secret-SubKey Packet, http://tools.ietf.org/html/rfc4880#section-5.5.1.4
parse_packet 7 = do
p <- parse_packet 5
Expand Down