summaryrefslogtreecommitdiff
path: root/OpenPGP.hs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP.hs')
-rw-r--r--OpenPGP.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/OpenPGP.hs b/OpenPGP.hs
index 7fef0b5..75054b3 100644
--- a/OpenPGP.hs
+++ b/OpenPGP.hs
@@ -10,6 +10,7 @@ import Data.OpenPGP.CryptoAPI (verify,fingerprint,sign,decryptSecretKey)
10import Data.Time.Clock.POSIX 10import Data.Time.Clock.POSIX
11import Control.Applicative ( (<$>) ) 11import Control.Applicative ( (<$>) )
12import Crypto.Random (newGenIO,SystemRandom) 12import Crypto.Random (newGenIO,SystemRandom)
13import ControlMaybe
13 14
14now = floor <$> Data.Time.Clock.POSIX.getPOSIXTime 15now = floor <$> Data.Time.Clock.POSIX.getPOSIXTime
15 16
@@ -32,11 +33,12 @@ pgpSign ::
32 -> OpenPGP.SignatureOver -- ^ Data to sign, and optional signature packet 33 -> OpenPGP.SignatureOver -- ^ Data to sign, and optional signature packet
33 -> OpenPGP.HashAlgorithm -- ^ HashAlgorithm to use in signature 34 -> OpenPGP.HashAlgorithm -- ^ HashAlgorithm to use in signature
34 -> String -- ^ KeyID of key to choose 35 -> String -- ^ KeyID of key to choose
35 -> IO OpenPGP.SignatureOver 36 -> IO (Maybe OpenPGP.SignatureOver)
36pgpSign seckeys dta hash_algo keyid = do 37pgpSign seckeys dta hash_algo keyid =
38 handleIO_ (return Nothing) $ do
37 timestamp <- now 39 timestamp <- now
38 g <- newGenIO :: IO SystemRandom 40 g <- newGenIO :: IO SystemRandom
39 let sigs = map (stampit timestamp) $ signatures_over dta 41 let sigs = map (stampit timestamp) $ signatures_over dta
40 dta' = dta { signatures_over = sigs } 42 dta' = dta { signatures_over = sigs }
41 let (r,g') = sign seckeys dta' hash_algo keyid timestamp g 43 let (r,g') = sign seckeys dta' hash_algo keyid timestamp g
42 return r 44 return (Just r)