diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-25 16:00:34 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-25 16:00:34 -0500 |
commit | 7b3232778f284dd4dd3a6f3287bcbe1fbe10b010 (patch) | |
tree | aec1f8332f97734f2fbd38d0b3c8222edad95def /Data | |
parent | 9320bdfde1cceb3db19bb44ad2522e9f57d7b475 (diff) |
fix for MD5 without BaseConvert
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP/Crypto.hs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Data/OpenPGP/Crypto.hs b/Data/OpenPGP/Crypto.hs index 5049d00..54fb81e 100644 --- a/Data/OpenPGP/Crypto.hs +++ b/Data/OpenPGP/Crypto.hs | |||
@@ -28,13 +28,18 @@ import qualified Data.OpenPGP as OpenPGP | |||
28 | -- | Generate a key fingerprint from a PublicKeyPacket or SecretKeyPacket | 28 | -- | Generate a key fingerprint from a PublicKeyPacket or SecretKeyPacket |
29 | -- <http://tools.ietf.org/html/rfc4880#section-12.2> | 29 | -- <http://tools.ietf.org/html/rfc4880#section-12.2> |
30 | fingerprint :: OpenPGP.Packet -> String | 30 | fingerprint :: OpenPGP.Packet -> String |
31 | fingerprint p | OpenPGP.version p == 4 = | 31 | fingerprint p |
32 | map toUpper $ (`showHex` "") $ SHA1.toInteger $ SHA1.hash $ | 32 | | OpenPGP.version p == 4 = |
33 | LZ.unpack (LZ.concat (OpenPGP.fingerprint_material p)) | 33 | map toUpper $ (`showHex` "") $ SHA1.toInteger $ SHA1.hash $ |
34 | fingerprint p | OpenPGP.version p `elem` [2, 3] = | 34 | LZ.unpack (LZ.concat (OpenPGP.fingerprint_material p)) |
35 | map toUpper $ foldr showHex "" $ | 35 | | OpenPGP.version p `elem` [2, 3] = |
36 | MD5.hash $ LZ.unpack (LZ.concat (OpenPGP.fingerprint_material p)) | 36 | map toUpper $ foldr (pad `oo` showHex) "" $ |
37 | fingerprint _ = error "Unsupported Packet version or type in fingerprint." | 37 | MD5.hash $ LZ.unpack (LZ.concat (OpenPGP.fingerprint_material p)) |
38 | | otherwise = error "Unsupported Packet version or type in fingerprint" | ||
39 | where | ||
40 | oo = (.) . (.) | ||
41 | pad s | odd $ length s = '0':s | ||
42 | | otherwise = s | ||
38 | 43 | ||
39 | find_key :: OpenPGP.Message -> String -> Maybe OpenPGP.Packet | 44 | find_key :: OpenPGP.Message -> String -> Maybe OpenPGP.Packet |
40 | find_key (OpenPGP.Message (x@(OpenPGP.PublicKeyPacket {}):xs)) keyid = | 45 | find_key (OpenPGP.Message (x@(OpenPGP.PublicKeyPacket {}):xs)) keyid = |