diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-24 17:51:02 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-24 17:51:02 -0500 |
commit | ecc7c859118e022b1f3d8fff5b74702d4c0bab71 (patch) | |
tree | 29b2d117da8c39adbd52b8f86a09da0dad09c2ac /Data | |
parent | 4df371631b16d753dd262171ec82c3ebaea42a10 (diff) |
Some fixes for signature verification
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP/Crypto.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Data/OpenPGP/Crypto.hs b/Data/OpenPGP/Crypto.hs index c213651..f9d1074 100644 --- a/Data/OpenPGP/Crypto.hs +++ b/Data/OpenPGP/Crypto.hs | |||
@@ -40,13 +40,16 @@ find_key (OpenPGP.Message (x@(OpenPGP.PublicKeyPacket {}):xs)) keyid = | |||
40 | find_key_ x xs keyid | 40 | find_key_ x xs keyid |
41 | find_key (OpenPGP.Message (x@(OpenPGP.SecretKeyPacket {}):xs)) keyid = | 41 | find_key (OpenPGP.Message (x@(OpenPGP.SecretKeyPacket {}):xs)) keyid = |
42 | find_key_ x xs keyid | 42 | find_key_ x xs keyid |
43 | find_key (OpenPGP.Message (_:xs)) keyid = | ||
44 | find_key (OpenPGP.Message xs) keyid | ||
43 | find_key _ _ = Nothing | 45 | find_key _ _ = Nothing |
44 | 46 | ||
45 | find_key_ :: OpenPGP.Packet -> [OpenPGP.Packet] -> String -> Maybe OpenPGP.Packet | 47 | find_key_ :: OpenPGP.Packet -> [OpenPGP.Packet] -> String -> Maybe OpenPGP.Packet |
46 | find_key_ x xs keyid = | 48 | find_key_ x xs keyid |
47 | if thisid == keyid then Just x else find_key (OpenPGP.Message xs) keyid | 49 | | thisid == keyid = Just x |
48 | where thisid = reverse $ | 50 | | otherwise = find_key (OpenPGP.Message xs) keyid |
49 | take (length keyid) (reverse (fingerprint x)) | 51 | where |
52 | thisid = reverse $ take (length keyid) (reverse (fingerprint x)) | ||
50 | 53 | ||
51 | keyfield_as_octets :: OpenPGP.Packet -> Char -> [Word8] | 54 | keyfield_as_octets :: OpenPGP.Packet -> Char -> [Word8] |
52 | keyfield_as_octets k f = | 55 | keyfield_as_octets k f = |
@@ -65,7 +68,7 @@ emsa_pkcs1_v1_5_hash_padding _ = | |||
65 | 68 | ||
66 | hash :: OpenPGP.HashAlgorithm -> [Word8] -> [Word8] | 69 | hash :: OpenPGP.HashAlgorithm -> [Word8] -> [Word8] |
67 | hash OpenPGP.MD5 = MD5.hash | 70 | hash OpenPGP.MD5 = MD5.hash |
68 | hash OpenPGP.SHA1 = reverse . drop 2 . LZ.unpack . encode . OpenPGP.MPI . SHA1.toInteger . SHA1.hash | 71 | hash OpenPGP.SHA1 = drop 2 . LZ.unpack . encode . OpenPGP.MPI . SHA1.toInteger . SHA1.hash |
69 | hash OpenPGP.SHA256 = SHA256.hash | 72 | hash OpenPGP.SHA256 = SHA256.hash |
70 | hash OpenPGP.SHA384 = SHA384.hash | 73 | hash OpenPGP.SHA384 = SHA384.hash |
71 | hash OpenPGP.SHA512 = SHA512.hash | 74 | hash OpenPGP.SHA512 = SHA512.hash |