diff options
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP.hs | 10 | ||||
-rw-r--r-- | Data/OpenPGP/Util/Fingerprint.hs | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index 17a6927..3064dc5 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs | |||
@@ -845,6 +845,16 @@ parse_packet tag = fmap (UnsupportedPacket tag) getRemainingByteString | |||
845 | 845 | ||
846 | -- | Helper method for fingerprints and such | 846 | -- | Helper method for fingerprints and such |
847 | fingerprint_material :: Packet -> [B.ByteString] | 847 | fingerprint_material :: Packet -> [B.ByteString] |
848 | fingerprint_material p | version p == 5 = | ||
849 | [ | ||
850 | B.singleton 0x9A, | ||
851 | encode (10 + fromIntegral (B.length material) :: Word32), | ||
852 | B.singleton 5, encode (timestamp p), encode (key_algorithm p), | ||
853 | encode (fromIntegral (B.length material) :: Word32), | ||
854 | material | ||
855 | ] | ||
856 | where | ||
857 | material = B.concat $ encode_public_key_material p | ||
848 | fingerprint_material p | version p == 4 = | 858 | fingerprint_material p | version p == 4 = |
849 | [ | 859 | [ |
850 | B.singleton 0x99, | 860 | B.singleton 0x99, |
diff --git a/Data/OpenPGP/Util/Fingerprint.hs b/Data/OpenPGP/Util/Fingerprint.hs index c1d8fef..d88661b 100644 --- a/Data/OpenPGP/Util/Fingerprint.hs +++ b/Data/OpenPGP/Util/Fingerprint.hs | |||
@@ -41,15 +41,18 @@ hex (Fingerprint bs) = hexify bs | |||
41 | -- <http://tools.ietf.org/html/rfc4880#section-12.2> | 41 | -- <http://tools.ietf.org/html/rfc4880#section-12.2> |
42 | fingerprint :: OpenPGP.Packet -> Fingerprint | 42 | fingerprint :: OpenPGP.Packet -> Fingerprint |
43 | fingerprint p | 43 | fingerprint p |
44 | | OpenPGP.version p == 5 = Fingerprint $ sha256 material | ||
44 | | OpenPGP.version p == 4 = Fingerprint $ sha1 material | 45 | | OpenPGP.version p == 4 = Fingerprint $ sha1 material |
45 | | OpenPGP.version p `elem` [2, 3] = Fingerprint $ md5 material | 46 | | OpenPGP.version p `elem` [2, 3] = Fingerprint $ md5 material |
46 | | otherwise = error "Unsupported Packet version or type in fingerprint" | 47 | | otherwise = error "Unsupported Packet version or type in fingerprint" |
47 | where | 48 | where |
48 | 49 | ||
49 | #if defined(VERSION_cryptonite) | 50 | #if defined(VERSION_cryptonite) |
51 | sha256 x = Bytes.convert (hashlazy x :: Digest SHA256) | ||
50 | sha1 x = Bytes.convert (hashlazy x :: Digest SHA1) | 52 | sha1 x = Bytes.convert (hashlazy x :: Digest SHA1) |
51 | md5 x = Bytes.convert (hashlazy x :: Digest MD5) | 53 | md5 x = Bytes.convert (hashlazy x :: Digest MD5) |
52 | #else | 54 | #else |
55 | -- TODO: SHA256 (or drop support for non-cryptonite) | ||
53 | sha1 = SHA1.hashlazy | 56 | sha1 = SHA1.hashlazy |
54 | md5 = MD5.hashlazy | 57 | md5 = MD5.hashlazy |
55 | #endif | 58 | #endif |