diff options
author | joe <joe@jerkface.net> | 2014-04-28 16:43:30 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-28 16:43:30 -0400 |
commit | 794661caa80061d8d20988497867d36c46397f96 (patch) | |
tree | 8e36a307354b513092e3341a2da3929d7ce968e5 /KeyRing.hs | |
parent | 5600972da9e24436985f520fadc4f74bf6fe60b5 (diff) |
StreamInfo type, wip
Diffstat (limited to 'KeyRing.hs')
-rw-r--r-- | KeyRing.hs | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -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 | ||
151 | data InputFile = HomeSec | 152 | data InputFile = HomeSec |
152 | | HomePub | 153 | | HomePub |
153 | | ArgFile FilePath | 154 | | ArgFile FilePath |
@@ -158,11 +159,30 @@ type UsageTag = String | |||
158 | type Initializer = String | 159 | type Initializer = String |
159 | type PassWordFile = InputFile | 160 | type 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 | ||
161 | data FileType = KeyRingFile (Maybe PassWordFile) | 166 | data FileType = KeyRingFile (Maybe PassWordFile) |
162 | | PEMFile UsageTag | 167 | | PEMFile UsageTag |
163 | | WalletFile -- (Maybe UsageTag) | 168 | | WalletFile -- (Maybe UsageTag) |
164 | | Hosts | 169 | | Hosts |
165 | 170 | ||
171 | data Access = AutoAccess -- ^ secret or public as appropriate based on existing content | ||
172 | | Sec -- ^ secret information | ||
173 | | Pub -- ^ public information | ||
174 | |||
175 | data 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. | ||
179 | data 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 | |||
192 | iswallet (WalletFile {}) = True | 212 | iswallet (WalletFile {}) = True |
193 | iswallet _ = False | 213 | iswallet _ = False |
194 | 214 | ||
195 | initializer :: RefType -> Maybe Initializer | 215 | rtyp_initializer :: RefType -> Maybe Initializer |
196 | initializer (MutableRef x) = x | 216 | rtyp_initializer (MutableRef x) = x |
197 | initializer _ = Nothing | 217 | rtyp_initializer _ = Nothing |
198 | 218 | ||
199 | getUsage :: | 219 | getUsage :: |
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. |
216 | data PacketUpdate = InducerSignature String [SignatureSubpacket] | 236 | data 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 |