summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2020-05-19 11:57:13 -0400
committerJoe Crayne <joe@jerkface.net>2020-05-19 11:59:23 -0400
commit924ce0d71c3588e8c020a28ced9e5a0923a8da98 (patch)
tree06384e360943bc930e21bc6dff1ed8cd86b4003d
parentb5453e2f99a4b4f15bff45a19688e7006a3b9d20 (diff)
TODO: Comments (we aren't setting hash_head correctly).
-rw-r--r--Data/OpenPGP/Util/Sign.hs4
-rw-r--r--Data/OpenPGP/Util/Verify.hs1
2 files changed, 4 insertions, 1 deletions
diff --git a/Data/OpenPGP/Util/Sign.hs b/Data/OpenPGP/Util/Sign.hs
index a074dcb..1af6053 100644
--- a/Data/OpenPGP/Util/Sign.hs
+++ b/Data/OpenPGP/Util/Sign.hs
@@ -76,6 +76,8 @@ xed25519Sign cv25519key hsh dta = do
76-- In order to set more options on a signature, pass in a signature packet. 76-- In order to set more options on a signature, pass in a signature packet.
77-- Operation is unsafe in that it silently re-uses "random" bytes when 77-- Operation is unsafe in that it silently re-uses "random" bytes when
78-- entropy runs out. Use pgpSign for a safer interface. 78-- entropy runs out. Use pgpSign for a safer interface.
79--
80-- TODO: Produce hash_head field.
79unsafeSign :: (RG g) => -- CryptoRandomGen g) => 81unsafeSign :: (RG g) => -- CryptoRandomGen g) =>
80 OpenPGP.Message -- ^ SecretKeys, one of which will be used 82 OpenPGP.Message -- ^ SecretKeys, one of which will be used
81 -> OpenPGP.SignatureOver -- ^ Data to sign, and optional signature packet 83 -> OpenPGP.SignatureOver -- ^ Data to sign, and optional signature packet
@@ -129,7 +131,7 @@ unsafeSign keys over hsh keyid timestamp g = (over {OpenPGP.signatures_over = [s
129 hsh -- force hash algorithm 131 hsh -- force hash algorithm
130 (OpenPGP.hashed_subpackets s) 132 (OpenPGP.hashed_subpackets s)
131 (OpenPGP.unhashed_subpackets s) 133 (OpenPGP.unhashed_subpackets s)
132 (OpenPGP.hash_head s) 134 (OpenPGP.hash_head s) -- FIXME: This is not right.
133 (map OpenPGP.MPI final) 135 (map OpenPGP.MPI final)
134 findSigOrDefault Nothing = OpenPGP.signaturePacket 136 findSigOrDefault Nothing = OpenPGP.signaturePacket
135 4 137 4
diff --git a/Data/OpenPGP/Util/Verify.hs b/Data/OpenPGP/Util/Verify.hs
index 52e9005..359e116 100644
--- a/Data/OpenPGP/Util/Verify.hs
+++ b/Data/OpenPGP/Util/Verify.hs
@@ -49,6 +49,7 @@ verify keys over =
49 sigs = map (\s -> (s, LZ.toStrict $ encode over `LZ.append` OpenPGP.trailer s)) 49 sigs = map (\s -> (s, LZ.toStrict $ encode over `LZ.append` OpenPGP.trailer s))
50 (OpenPGP.signatures_over over) 50 (OpenPGP.signatures_over over)
51 51
52-- TODO: Check hash_head field?
52verifyOne :: OpenPGP.Message -> OpenPGP.Packet -> BS.ByteString -> Maybe OpenPGP.Packet 53verifyOne :: OpenPGP.Message -> OpenPGP.Packet -> BS.ByteString -> Maybe OpenPGP.Packet
53verifyOne keys sig over = fmap (const sig) $ maybeKey >>= verification >>= guard 54verifyOne keys sig over = fmap (const sig) $ maybeKey >>= verification >>= guard
54 where 55 where