summaryrefslogtreecommitdiff
path: root/Data
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-04-24 17:51:02 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-04-24 17:51:02 -0500
commitecc7c859118e022b1f3d8fff5b74702d4c0bab71 (patch)
tree29b2d117da8c39adbd52b8f86a09da0dad09c2ac /Data
parent4df371631b16d753dd262171ec82c3ebaea42a10 (diff)
Some fixes for signature verification
Diffstat (limited to 'Data')
-rw-r--r--Data/OpenPGP/Crypto.hs13
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
41find_key (OpenPGP.Message (x@(OpenPGP.SecretKeyPacket {}):xs)) keyid = 41find_key (OpenPGP.Message (x@(OpenPGP.SecretKeyPacket {}):xs)) keyid =
42 find_key_ x xs keyid 42 find_key_ x xs keyid
43find_key (OpenPGP.Message (_:xs)) keyid =
44 find_key (OpenPGP.Message xs) keyid
43find_key _ _ = Nothing 45find_key _ _ = Nothing
44 46
45find_key_ :: OpenPGP.Packet -> [OpenPGP.Packet] -> String -> Maybe OpenPGP.Packet 47find_key_ :: OpenPGP.Packet -> [OpenPGP.Packet] -> String -> Maybe OpenPGP.Packet
46find_key_ x xs keyid = 48find_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
51keyfield_as_octets :: OpenPGP.Packet -> Char -> [Word8] 54keyfield_as_octets :: OpenPGP.Packet -> Char -> [Word8]
52keyfield_as_octets k f = 55keyfield_as_octets k f =
@@ -65,7 +68,7 @@ emsa_pkcs1_v1_5_hash_padding _ =
65 68
66hash :: OpenPGP.HashAlgorithm -> [Word8] -> [Word8] 69hash :: OpenPGP.HashAlgorithm -> [Word8] -> [Word8]
67hash OpenPGP.MD5 = MD5.hash 70hash OpenPGP.MD5 = MD5.hash
68hash OpenPGP.SHA1 = reverse . drop 2 . LZ.unpack . encode . OpenPGP.MPI . SHA1.toInteger . SHA1.hash 71hash OpenPGP.SHA1 = drop 2 . LZ.unpack . encode . OpenPGP.MPI . SHA1.toInteger . SHA1.hash
69hash OpenPGP.SHA256 = SHA256.hash 72hash OpenPGP.SHA256 = SHA256.hash
70hash OpenPGP.SHA384 = SHA384.hash 73hash OpenPGP.SHA384 = SHA384.hash
71hash OpenPGP.SHA512 = SHA512.hash 74hash OpenPGP.SHA512 = SHA512.hash