summaryrefslogtreecommitdiff
path: root/Data/OpenPGP.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Data/OpenPGP.hs')
-rw-r--r--Data/OpenPGP.hs20
1 files changed, 15 insertions, 5 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index 3064dc5..bee718a 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -59,6 +59,8 @@ module Data.OpenPGP (
59 MPI(..), 59 MPI(..),
60 find_key, 60 find_key,
61 fingerprint_material, 61 fingerprint_material,
62 auto_fp_version,
63 fingerprint_materialv,
62 SignatureOver(..), 64 SignatureOver(..),
63 signatures, 65 signatures,
64 signature_issuer, 66 signature_issuer,
@@ -843,9 +845,17 @@ parse_packet 19 =
843-- Represent unsupported packets as their tag and literal bytes 845-- Represent unsupported packets as their tag and literal bytes
844parse_packet tag = fmap (UnsupportedPacket tag) getRemainingByteString 846parse_packet tag = fmap (UnsupportedPacket tag) getRemainingByteString
845 847
848auto_fp_version :: Packet -> Word8
849auto_fp_version p | version p == 2 = 3
850 | otherwise = version p
851
852-- | Helper method for fingerprints and such
853fingerprint_material :: HasCallStack => Packet -> [B.ByteString]
854fingerprint_material p = fingerprint_materialv (auto_fp_version p) p
855
846-- | Helper method for fingerprints and such 856-- | Helper method for fingerprints and such
847fingerprint_material :: Packet -> [B.ByteString] 857fingerprint_materialv :: HasCallStack => Word8 -> Packet -> [B.ByteString]
848fingerprint_material p | version p == 5 = 858fingerprint_materialv 5 p =
849 [ 859 [
850 B.singleton 0x9A, 860 B.singleton 0x9A,
851 encode (10 + fromIntegral (B.length material) :: Word32), 861 encode (10 + fromIntegral (B.length material) :: Word32),
@@ -855,7 +865,7 @@ fingerprint_material p | version p == 5 =
855 ] 865 ]
856 where 866 where
857 material = B.concat $ encode_public_key_material p 867 material = B.concat $ encode_public_key_material p
858fingerprint_material p | version p == 4 = 868fingerprint_materialv 4 p =
859 [ 869 [
860 B.singleton 0x99, 870 B.singleton 0x99,
861 encode (6 + fromIntegral (B.length material) :: Word16), 871 encode (6 + fromIntegral (B.length material) :: Word16),
@@ -864,11 +874,11 @@ fingerprint_material p | version p == 4 =
864 ] 874 ]
865 where 875 where
866 material = B.concat $ encode_public_key_material p 876 material = B.concat $ encode_public_key_material p
867fingerprint_material p | version p `elem` [2, 3] = [n, e] 877fingerprint_materialv 3 p | key_algorithm p == RSA = [n, e]
868 where 878 where
869 n = B.drop 2 (encode (key p ! 'n')) 879 n = B.drop 2 (encode (key p ! 'n'))
870 e = B.drop 2 (encode (key p ! 'e')) 880 e = B.drop 2 (encode (key p ! 'e'))
871fingerprint_material _ = 881fingerprint_materialv _ _ =
872 error "Unsupported Packet version or type in fingerprint_material." 882 error "Unsupported Packet version or type in fingerprint_material."
873 883
874enum_to_word8 :: (Enum a) => a -> Word8 884enum_to_word8 :: (Enum a) => a -> Word8