diff options
author | Joe Crayne <joe@jerkface.net> | 2020-05-06 06:37:26 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-05-06 09:33:33 -0400 |
commit | 99ee915c0fdbf5bc718dbd59e9f5bbe9f5f7690c (patch) | |
tree | d376f6405deeb640aed44ef5995b08fc9a3099a4 /Data/OpenPGP/Util/Fingerprint.hs | |
parent | 02680b1ed3b37c0cc16e04e51e613d53ff9dbab8 (diff) |
Implemented v5 fingerprints (draft-ietf-openpgp-rfc4880bis-09).
Diffstat (limited to 'Data/OpenPGP/Util/Fingerprint.hs')
-rw-r--r-- | Data/OpenPGP/Util/Fingerprint.hs | 3 |
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> |
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 |