diff options
Diffstat (limited to 'OpenPGP.hs')
-rw-r--r-- | OpenPGP.hs | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -10,6 +10,7 @@ import Data.OpenPGP.CryptoAPI (verify,fingerprint,sign,decryptSecretKey) | |||
10 | import Data.Time.Clock.POSIX | 10 | import Data.Time.Clock.POSIX |
11 | import Control.Applicative ( (<$>) ) | 11 | import Control.Applicative ( (<$>) ) |
12 | import Crypto.Random (newGenIO,SystemRandom) | 12 | import Crypto.Random (newGenIO,SystemRandom) |
13 | import ControlMaybe | ||
13 | 14 | ||
14 | now = floor <$> Data.Time.Clock.POSIX.getPOSIXTime | 15 | now = 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) |
36 | pgpSign seckeys dta hash_algo keyid = do | 37 | pgpSign 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) |