summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-07-01 23:16:32 -0400
committerJoe Crayne <joe@jerkface.net>2019-07-01 23:16:32 -0400
commit5d5ce0e97107619b8e33c76585d7629f106ad3c8 (patch)
tree3492c9de1a740154654a6ba1cced90e879f47219 /lib
parentae8792ee7c51da15e52f30475c17ce589f940509 (diff)
New debugging option: --trace-verify
Diffstat (limited to 'lib')
-rw-r--r--lib/Data/OpenPGP/Util.hs37
-rw-r--r--lib/Kiki.hs5
2 files changed, 41 insertions, 1 deletions
diff --git a/lib/Data/OpenPGP/Util.hs b/lib/Data/OpenPGP/Util.hs
new file mode 100644
index 0000000..a51ce64
--- /dev/null
+++ b/lib/Data/OpenPGP/Util.hs
@@ -0,0 +1,37 @@
1{-# OPTIONS_GHC -Wno-duplicate-exports #-}
2{-# LANGUAGE PackageImports #-}
3module Data.OpenPGP.Util
4 ( module P
5 , verify
6 , setVerifyFlag
7 ) where
8
9import Data.Bool
10import Data.IORef
11import Debug.Trace
12import GHC.Stack
13import System.IO.Unsafe
14
15import qualified "openpgp-util" Data.OpenPGP.Util as P
16import "openpgp-util" Data.OpenPGP.Util hiding (verify)
17import Data.OpenPGP
18
19traceVerifyFlag :: IORef Bool
20traceVerifyFlag = unsafePerformIO $ newIORef False
21{-# NOINLINE traceVerifyFlag #-}
22
23getVerifyFlag :: Bool
24getVerifyFlag = unsafePerformIO $ readIORef traceVerifyFlag
25{-# NOINLINE getVerifyFlag #-}
26
27setVerifyFlag :: Bool -> IO ()
28setVerifyFlag x = writeIORef traceVerifyFlag x
29
30shortCallStack :: [([Char], SrcLoc)] -> String
31shortCallStack [] = ""
32shortCallStack ((_,loc):_) = (srcLocFile loc) ++ ":" ++ show (srcLocStartLine loc)
33
34verify :: HasCallStack => Message -> SignatureOver -> SignatureOver
35verify msg sig =
36 bool id (trace $ "verify " ++ shortCallStack (getCallStack callStack)) getVerifyFlag
37 $ P.verify msg sig
diff --git a/lib/Kiki.hs b/lib/Kiki.hs
index 64e2d7d..6481b58 100644
--- a/lib/Kiki.hs
+++ b/lib/Kiki.hs
@@ -1,6 +1,9 @@
1{-# LANGUAGE CPP #-} 1{-# LANGUAGE CPP #-}
2{-# LANGUAGE OverloadedStrings #-} 2{-# LANGUAGE OverloadedStrings #-}
3module Kiki where 3module Kiki
4 ( module Kiki
5 , setVerifyFlag
6 ) where
4 7
5import Control.Applicative 8import Control.Applicative
6import Control.Arrow 9import Control.Arrow