summaryrefslogtreecommitdiff
path: root/OpenPGP.hs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP.hs')
-rw-r--r--OpenPGP.hs44
1 files changed, 0 insertions, 44 deletions
diff --git a/OpenPGP.hs b/OpenPGP.hs
deleted file mode 100644
index 75054b3..0000000
--- a/OpenPGP.hs
+++ /dev/null
@@ -1,44 +0,0 @@
1module OpenPGP
2 ( verify
3 , fingerprint
4 , pgpSign
5 , decryptSecretKey
6 ) where
7
8import Data.OpenPGP as OpenPGP
9import Data.OpenPGP.CryptoAPI (verify,fingerprint,sign,decryptSecretKey)
10import Data.Time.Clock.POSIX
11import Control.Applicative ( (<$>) )
12import Crypto.Random (newGenIO,SystemRandom)
13import ControlMaybe
14
15now = floor <$> Data.Time.Clock.POSIX.getPOSIXTime
16
17stampit timestamp sig = sig { hashed_subpackets = hashed' }
18 where
19 hashed_stamps = filter isStamp (hashed_subpackets sig)
20 unhashed_stamps = filter isStamp (unhashed_subpackets sig)
21 hashed' = case hashed_stamps ++ unhashed_stamps of
22 [] -> SignatureCreationTimePacket (fromIntegral timestamp)
23 : hashed_subpackets sig
24 _ -> hashed_subpackets sig
25 isStamp (SignatureCreationTimePacket {}) = True
26 isStamp _ = False
27
28-- | Make a signature
29--
30-- In order to set more options on a signature, pass in a signature packet.
31pgpSign ::
32 OpenPGP.Message -- ^ SecretKeys, one of which will be used
33 -> OpenPGP.SignatureOver -- ^ Data to sign, and optional signature packet
34 -> OpenPGP.HashAlgorithm -- ^ HashAlgorithm to use in signature
35 -> String -- ^ KeyID of key to choose
36 -> IO (Maybe OpenPGP.SignatureOver)
37pgpSign seckeys dta hash_algo keyid =
38 handleIO_ (return Nothing) $ do
39 timestamp <- now
40 g <- newGenIO :: IO SystemRandom
41 let sigs = map (stampit timestamp) $ signatures_over dta
42 dta' = dta { signatures_over = sigs }
43 let (r,g') = sign seckeys dta' hash_algo keyid timestamp g
44 return (Just r)