summaryrefslogtreecommitdiff
path: root/KeyRing.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-28 16:43:30 -0400
committerjoe <joe@jerkface.net>2014-04-28 16:43:30 -0400
commit794661caa80061d8d20988497867d36c46397f96 (patch)
tree8e36a307354b513092e3341a2da3929d7ce968e5 /KeyRing.hs
parent5600972da9e24436985f520fadc4f74bf6fe60b5 (diff)
StreamInfo type, wip
Diffstat (limited to 'KeyRing.hs')
-rw-r--r--KeyRing.hs32
1 files changed, 26 insertions, 6 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index ecb6021..ac92b14 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -148,6 +148,7 @@ home = HomeDir
148 , optfile_alts = ["keys.conf","gpg.conf-2","gpg.conf"] 148 , optfile_alts = ["keys.conf","gpg.conf-2","gpg.conf"]
149 } 149 }
150 150
151-- TODO: Pipe Fd Fd
151data InputFile = HomeSec 152data InputFile = HomeSec
152 | HomePub 153 | HomePub
153 | ArgFile FilePath 154 | ArgFile FilePath
@@ -158,11 +159,30 @@ type UsageTag = String
158type Initializer = String 159type Initializer = String
159type PassWordFile = InputFile 160type PassWordFile = InputFile
160 161
162-- TODO: This should become a simple enum.
163-- The parameter to PEMFile will be subsumed by
164-- the KF_Match fill/spill KeyFilter styles. The parameter
165-- to KeyRingFile will be subsumbed by kPassphrases
161data FileType = KeyRingFile (Maybe PassWordFile) 166data FileType = KeyRingFile (Maybe PassWordFile)
162 | PEMFile UsageTag 167 | PEMFile UsageTag
163 | WalletFile -- (Maybe UsageTag) 168 | WalletFile -- (Maybe UsageTag)
164 | Hosts 169 | Hosts
165 170
171data Access = AutoAccess -- ^ secret or public as appropriate based on existing content
172 | Sec -- ^ secret information
173 | Pub -- ^ public information
174
175data KeyFilter = KF_None | KF_Match String | KF_Subkeys | KF_Authentic | KF_All
176
177-- | TODO: This should replace the element type of kFiles
178-- and kImports will be obsolete.
179data StreamInfo = StreamInfo
180 { access :: Access
181 , typ :: FileType
182 , fill :: KeyFilter
183 , spill :: KeyFilter
184 , initializer :: Maybe String }
185
166-- | RefType is perhaps not a good name for this... 186-- | RefType is perhaps not a good name for this...
167-- It is sort of like a read/write flag, although 187-- It is sort of like a read/write flag, although
168-- semantically, it is indicating the intention of 188-- semantically, it is indicating the intention of
@@ -192,9 +212,9 @@ iswallet :: FileType -> Bool
192iswallet (WalletFile {}) = True 212iswallet (WalletFile {}) = True
193iswallet _ = False 213iswallet _ = False
194 214
195initializer :: RefType -> Maybe Initializer 215rtyp_initializer :: RefType -> Maybe Initializer
196initializer (MutableRef x) = x 216rtyp_initializer (MutableRef x) = x
197initializer _ = Nothing 217rtyp_initializer _ = Nothing
198 218
199getUsage :: 219getUsage ::
200 MonadPlus m => FileType -> m UsageTag 220 MonadPlus m => FileType -> m UsageTag
@@ -210,7 +230,7 @@ data KeyRingRuntime = KeyRingRuntime
210 , rtKeyDB :: KeyDB 230 , rtKeyDB :: KeyDB
211 } 231 }
212 232
213-- | TODO: Packet Update should have deletiong action 233-- | TODO: Packet Update should have deletion action
214-- and any other kind of roster-entry level 234-- and any other kind of roster-entry level
215-- action. 235-- action.
216data PacketUpdate = InducerSignature String [SignatureSubpacket] 236data PacketUpdate = InducerSignature String [SignatureSubpacket]
@@ -992,7 +1012,7 @@ buildKeyDB doDecrypt secring pubring grip0 keyring = do
992 (topspec,subspec) <- fmap (parseSpec grip) $ getUsage ftyp 1012 (topspec,subspec) <- fmap (parseSpec grip) $ getUsage ftyp
993 n <- resolveInputFile secring pubring n 1013 n <- resolveInputFile secring pubring n
994 let ms = map fst $ filterMatches topspec (Map.toList db) 1014 let ms = map fst $ filterMatches topspec (Map.toList db)
995 cmd = initializer rtyp 1015 cmd = rtyp_initializer rtyp
996 return (n,subspec,ms,cmd) 1016 return (n,subspec,ms,cmd)
997 imports <- filterM (\(n,_,_,_) -> doesFileExist n) pems 1017 imports <- filterM (\(n,_,_,_) -> doesFileExist n) pems
998 db <- foldM (importPEMKey doDecrypt) (KikiSuccess (db,[])) imports 1018 db <- foldM (importPEMKey doDecrypt) (KikiSuccess (db,[])) imports
@@ -1565,7 +1585,7 @@ initializeMissingPEMFiles operation secring pubring grip decrypt db = do
1565 ns = do 1585 ns = do
1566 (kk,kd) <- filterMatches topspec $ Map.toList db 1586 (kk,kd) <- filterMatches topspec $ Map.toList db
1567 return (kk , subkeysForExport subspec kd) 1587 return (kk , subkeysForExport subspec kd)
1568 return (fname,subspec,ns,initializer rtyp) 1588 return (fname,subspec,ns,rtyp_initializer rtyp)
1569 (exports0,ambiguous) = partition (\(_,_,ns,_)->null $ drop 1 $ (ns>>=snd)) 1589 (exports0,ambiguous) = partition (\(_,_,ns,_)->null $ drop 1 $ (ns>>=snd))
1570 notmissing 1590 notmissing
1571 exports = map (\(f,subspec,ns,cmd) -> (f,subspec,ns >>= snd,cmd)) exports0 1591 exports = map (\(f,subspec,ns,cmd) -> (f,subspec,ns >>= snd,cmd)) exports0