diff options
Diffstat (limited to 'OpenPGP.hs')
-rw-r--r-- | OpenPGP.hs | 44 |
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 @@ | |||
1 | module OpenPGP | ||
2 | ( verify | ||
3 | , fingerprint | ||
4 | , pgpSign | ||
5 | , decryptSecretKey | ||
6 | ) where | ||
7 | |||
8 | import Data.OpenPGP as OpenPGP | ||
9 | import Data.OpenPGP.CryptoAPI (verify,fingerprint,sign,decryptSecretKey) | ||
10 | import Data.Time.Clock.POSIX | ||
11 | import Control.Applicative ( (<$>) ) | ||
12 | import Crypto.Random (newGenIO,SystemRandom) | ||
13 | import ControlMaybe | ||
14 | |||
15 | now = floor <$> Data.Time.Clock.POSIX.getPOSIXTime | ||
16 | |||
17 | stampit 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. | ||
31 | pgpSign :: | ||
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) | ||
37 | pgpSign 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) | ||