summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/KeyRing.hs86
1 files changed, 23 insertions, 63 deletions
diff --git a/lib/KeyRing.hs b/lib/KeyRing.hs
index f8e2290..bd6de27 100644
--- a/lib/KeyRing.hs
+++ b/lib/KeyRing.hs
@@ -28,36 +28,24 @@ module KeyRing (module KeyRing.Types, module Transforms, module PacketTranscoder
28 28
29import System.Environment 29import System.Environment
30import Control.Monad 30import Control.Monad
31import Control.Exception ( catch )
32import System.IO.Error ( isDoesNotExistError )
33import Data.Bool 31import Data.Bool
34import Data.Maybe 32import Data.Maybe
35import Data.Either 33import Data.Either
36import Data.Char 34import Data.Char
37import Data.Ord
38import Data.List 35import Data.List
39import Data.OpenPGP 36import Data.OpenPGP
40import Data.Functor
41import Data.Monoid
42import Data.Tuple ( swap )
43import Data.Bits ( (.|.), (.&.) )
44import Control.Applicative ( Applicative, pure, liftA2, (<*>) )
45import System.Directory ( getHomeDirectory, doesFileExist, createDirectoryIfMissing ) 37import System.Directory ( getHomeDirectory, doesFileExist, createDirectoryIfMissing )
46import Control.Arrow ( first, second ) 38import Control.Arrow ( first, second )
47import Data.OpenPGP.Util 39import Data.OpenPGP.Util
48import Data.ByteString.Lazy ( ByteString ) 40import Data.ByteString.Lazy ( ByteString )
49import Text.Show.Pretty as PP ( ppShow )
50import Data.Binary {- decode, decodeOrFail -} 41import Data.Binary {- decode, decodeOrFail -}
51import ControlMaybe ( handleIO_ ) 42import ControlMaybe ( handleIO_ )
52import Data.ASN1.Types ( toASN1, ASN1Object, fromASN1 43import Data.ASN1.Types ( toASN1, ASN1Object, fromASN1
53 , ASN1(Start,End,IntVal,OID,BitString,Null), ASN1ConstructionType(Sequence) ) 44 , ASN1(Start,End,IntVal,OID,BitString,Null), ASN1ConstructionType(Sequence) )
54import Data.ASN1.BitArray ( BitArray(..), toBitArray ) 45import Data.ASN1.BitArray ( BitArray(..), toBitArray )
55import Data.ASN1.Encoding ( encodeASN1, encodeASN1', decodeASN1, decodeASN1' ) 46import Data.ASN1.Encoding (decodeASN1', encodeASN1, encodeASN1' )
56import Data.ASN1.BinaryEncoding ( DER(..) ) 47import Data.ASN1.BinaryEncoding ( DER(..) )
57import Data.Time.Clock.POSIX ( POSIXTime, utcTimeToPOSIXSeconds ) 48import Data.Bits ((.&.), shiftR )
58import Data.Time.Clock ( UTCTime )
59import Data.Bits ( Bits, shiftR )
60import Data.Text.Encoding ( encodeUtf8 )
61import qualified Data.Map as Map 49import qualified Data.Map as Map
62import qualified Data.ByteString.Lazy as L 50import qualified Data.ByteString.Lazy as L
63import qualified Data.ByteString as S 51import qualified Data.ByteString as S
@@ -72,25 +60,15 @@ import qualified Codec.Binary.Base64 as Base64
72import qualified Crypto.Hash.SHA1 as SHA1 60import qualified Crypto.Hash.SHA1 as SHA1
73import qualified Crypto.Types.PubKey.ECC as ECC 61import qualified Crypto.Types.PubKey.ECC as ECC
74#else 62#else
75import qualified Crypto.Hash as Vincent
76import Data.ByteArray (convert)
77import qualified Crypto.PubKey.ECC.Types as ECC
78#endif 63#endif
79import qualified Data.X509 as X509
80import qualified Crypto.PubKey.RSA as RSA
81import qualified Codec.Compression.GZip as GZip 64import qualified Codec.Compression.GZip as GZip
82import qualified Data.Text as T ( Text, unpack, pack,
83 strip, reverse, drop, break, dropAround, length )
84import qualified System.Posix.Types as Posix 65import qualified System.Posix.Types as Posix
85import System.Posix.Files ( modificationTime, getFileStatus, getFdStatus 66import System.Posix.Files (setFileCreationMask, setFileTimes )
86 , setFileCreationMask, setFileTimes ) 67
87#if MIN_VERSION_x509(1,5,0) 68#if MIN_VERSION_x509(1,5,0)
88import Data.Hourglass.Types
89import Data.Hourglass
90#endif 69#endif
91#if MIN_VERSION_unix(2,7,0) 70#if MIN_VERSION_unix(2,7,0)
92import System.Posix.Files ( setFdTimesHiRes ) 71import System.Posix.Files ( setFdTimesHiRes )
93import Foreign.C.Types ( CTime(..), CLong, CInt(..) )
94#else 72#else
95import Foreign.C.Types ( CTime(..), CLong, CInt(..) ) 73import Foreign.C.Types ( CTime(..), CLong, CInt(..) )
96import Foreign.Marshal.Array ( withArray ) 74import Foreign.Marshal.Array ( withArray )
@@ -100,59 +78,41 @@ import Foreign.Storable
100#endif 78#endif
101import System.FilePath ( takeDirectory ) 79import System.FilePath ( takeDirectory )
102import System.IO (hPutStrLn,withFile,IOMode(..), Handle, hPutStr, stderr, hClose) 80import System.IO (hPutStrLn,withFile,IOMode(..), Handle, hPutStr, stderr, hClose)
103import Data.IORef
104import System.Posix.IO ( fdToHandle ) 81import System.Posix.IO ( fdToHandle )
105import qualified Data.Traversable as Traversable
106import Data.Traversable ( sequenceA )
107#if ! MIN_VERSION_base(4,6,0) 82#if ! MIN_VERSION_base(4,6,0)
108import GHC.Exts ( Down(..) ) 83import GHC.Exts ( Down(..) )
109#endif 84#endif
110#if MIN_VERSION_binary(0,7,0) 85#if MIN_VERSION_binary(0,7,0)
111import Debug.Trace
112#endif 86#endif
113import Network.Socket -- (SockAddr)
114import qualified Data.ByteString.Lazy.Char8 as Char8 87import qualified Data.ByteString.Lazy.Char8 as Char8
115import qualified Codec.Encryption.OpenPGP.ASCIIArmor as ASCIIArmor 88import qualified Codec.Encryption.OpenPGP.ASCIIArmor as ASCIIArmor
116import Codec.Encryption.OpenPGP.ASCIIArmor.Types 89import Codec.Encryption.OpenPGP.ASCIIArmor.Types
117 90
118import Compat
119import TimeUtil
120import PEM
121import ScanningParser
122import qualified Hosts 91import qualified Hosts
123import qualified CryptoCoins 92import qualified CryptoCoins
124import Base58 93import Base58
125import FunctorToMaybe 94import FunctorToMaybe
126import DotLock 95import DotLock
127import ProcessUtils (systemEnv, ExitCode(ExitFailure, ExitSuccess) ) 96import ProcessUtils (systemEnv, ExitCode(ExitFailure, ExitSuccess) )
128import GnuPGAgent as Agent 97import KeyRing.BuildKeyDB (Hostnames(..),
129import KeyRing.BuildKeyDB {- (accBindings, backsig, buildKeyDB, 98 IPsToWriteToHostsFile(..),
130 combineTransforms, concatSort, 99 buildKeyDB,
131 derRSA, derToBase32, filterMatches, 100 combineTransforms,
132 findTag, fingerdress, 101 filterMatches,
133 flattenAllUids, flattenKeys, 102 fingerdress, flattenKeys,
134 flattenSub, flattenTop, 103 generateInternals,
135 generateInternals, getBindings, 104 getHostnames, getSubkeys,
136 getHostnames, getSubkeys, 105 importSecretKey,
137 importSecretKey, insertSubkey, 106 insertSubkey,
138 isKey, isSecretKey, 107 matchSpec, merge,
139 isSubkeySignature, isUserID, 108 packetFromPublicRSAKey,
140 keyFlags0, keyPacket, keyflags, 109 parseCertBlob,
141 keykey, mappedPacket, matchSpec, 110 parseSingleSpec,
142 matchpr, merge, mergeKeyPacket, 111 parseSpec, readInputFileL,
143 mkUsage, origin, 112 readSecretPEMFile,
144 packetFromPublicRSAKey, 113 secp256k1_id, seek_key,
145 parseCertBlob, parseSingleSpec, 114 selectKey0, selectPublicKey,
146 parseSpec, parseUID, 115 usageFromFilter)
147 performManipulations,
148 readInputFileL, readSecretPEMFile,
149 resolveForReport, resolveInputFile,
150 rsaKeyFromPacket, secp256k1_id,
151 secretToPublic, seek_key,
152 selectKey0, selectPublicKey,
153 showPacket, sortByHint,
154 subkeyMappedPacket, torhash,
155 usageFromFilter) -}
156 116
157import KeyRing.Types 117import KeyRing.Types
158import PacketTranscoder 118import PacketTranscoder