summaryrefslogtreecommitdiff
path: root/Data/OpenPGP/Util/Fingerprint.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Data/OpenPGP/Util/Fingerprint.hs')
-rw-r--r--Data/OpenPGP/Util/Fingerprint.hs3
1 files changed, 3 insertions, 0 deletions
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>
42fingerprint :: OpenPGP.Packet -> Fingerprint 42fingerprint :: OpenPGP.Packet -> Fingerprint
43fingerprint p 43fingerprint 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