summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--OpenPGP.hs44
-rw-r--r--kiki.hs5
2 files changed, 2 insertions, 47 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)
diff --git a/kiki.hs b/kiki.hs
index 8e49086..ace9077 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -23,8 +23,7 @@ import Control.Monad
23import qualified Text.Show.Pretty as PP 23import qualified Text.Show.Pretty as PP
24import Text.PrettyPrint as PP hiding ((<>)) 24import Text.PrettyPrint as PP hiding ((<>))
25import Data.List 25import Data.List
26-- import Data.OpenPGP.CryptoAPI (verify,fingerprint,sign,decryptSecretKey) 26import Data.OpenPGP.Util (verify,fingerprint,decryptSecretKey,pgpSign)
27import OpenPGP
28import Data.Ord 27import Data.Ord
29import Data.Maybe 28import Data.Maybe
30import Data.Bits 29import Data.Bits
@@ -714,7 +713,7 @@ expandPath path [] = []
714 713
715readPacketsFromFile :: FilePath -> IO Message 714readPacketsFromFile :: FilePath -> IO Message
716readPacketsFromFile fname = do 715readPacketsFromFile fname = do
717 warn $ fname ++ ": reading..." 716 -- warn $ fname ++ ": reading..."
718 input <- L.readFile fname 717 input <- L.readFile fname
719 return $ 718 return $
720 case decodeOrFail input of 719 case decodeOrFail input of