diff options
author | joe <joe@jerkface.net> | 2014-04-19 21:27:22 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-19 21:27:22 -0400 |
commit | 9e8f7b0293dbc14e1aa9760420ec9c58f3243b7a (patch) | |
tree | 07adb2d2474ab98835afb7db301608bd4c80a12d | |
parent | e5a61ddac138be9b3a9cd56a7b23811935bc738e (diff) |
added kManip
-rw-r--r-- | KeyRing.hs | 38 | ||||
-rw-r--r-- | kiki.hs | 1 |
2 files changed, 39 insertions, 0 deletions
@@ -127,6 +127,21 @@ data KeyRingRuntime = KeyRingRuntime | |||
127 | 127 | ||
128 | data KeyRingAction a = KeyRingAction a | RunTimeAction (KeyRingRuntime -> a) | 128 | data KeyRingAction a = KeyRingAction a | RunTimeAction (KeyRingRuntime -> a) |
129 | 129 | ||
130 | data SubKeyKey = SubKeyKey KeyKey | UIDKey String | ||
131 | deriving (Eq,Ord) | ||
132 | |||
133 | data PacketUpdate = InducerSignature [SignatureSubpacket] | ||
134 | |||
135 | data KeyRingAddress a = KeyRingAddress | ||
136 | { topkeyAddress :: KeyKey | ||
137 | , subkeyAddress :: SubKeyKey | ||
138 | , keyringAddressed :: a | ||
139 | } | ||
140 | deriving Functor | ||
141 | |||
142 | noManip :: KeyRingRuntime -> [KeyRingAddress PacketUpdate] | ||
143 | noManip = const [] | ||
144 | |||
130 | data KeyRingData = KeyRingData | 145 | data KeyRingData = KeyRingData |
131 | { kFiles :: Map.Map InputFile (RefType,FileType) | 146 | { kFiles :: Map.Map InputFile (RefType,FileType) |
132 | , kImports :: Map.Map InputFile (KeyRingRuntime -> KeyData -> Maybe Bool) | 147 | , kImports :: Map.Map InputFile (KeyRingRuntime -> KeyData -> Maybe Bool) |
@@ -138,6 +153,7 @@ data KeyRingData = KeyRingData | |||
138 | -- Note that subkeys will always be imported if their owner key is | 153 | -- Note that subkeys will always be imported if their owner key is |
139 | -- already in the ring. | 154 | -- already in the ring. |
140 | -- TODO: Even if their signatures are bad? | 155 | -- TODO: Even if their signatures are bad? |
156 | , kManip :: KeyRingRuntime -> [KeyRingAddress PacketUpdate] | ||
141 | , homeSpec :: Maybe String | 157 | , homeSpec :: Maybe String |
142 | } | 158 | } |
143 | 159 | ||
@@ -310,6 +326,9 @@ usage (NotationDataPacket | |||
310 | }) = Just u | 326 | }) = Just u |
311 | usage _ = Nothing | 327 | usage _ = Nothing |
312 | 328 | ||
329 | torSigOver | ||
330 | :: Packet | ||
331 | -> Packet -> Packet -> [SignatureSubpacket] -> SignatureOver | ||
313 | -- torsig g topk wkun uid timestamp extras = todo | 332 | -- torsig g topk wkun uid timestamp extras = todo |
314 | torSigOver topk wkun uid extras | 333 | torSigOver topk wkun uid extras |
315 | = CertificationSignature (secretToPublic topk) | 334 | = CertificationSignature (secretToPublic topk) |
@@ -1181,6 +1200,9 @@ doDecrypt unkeysRef pws mp = do | |||
1181 | (return . KikiSuccess) | 1200 | (return . KikiSuccess) |
1182 | $ Map.lookup kk unkeys | 1201 | $ Map.lookup kk unkeys |
1183 | 1202 | ||
1203 | interpretManip :: KeyData -> KeyRingAddress PacketUpdate -> IO KeyData | ||
1204 | interpretManip kd (KeyRingAddress kk sk (InducerSignature ps)) = error "todo" | ||
1205 | interpretManip kd manip = return kd | ||
1184 | 1206 | ||
1185 | runKeyRing :: KeyRingData -> IO (KikiResult KeyRingRuntime) | 1207 | runKeyRing :: KeyRingData -> IO (KikiResult KeyRingRuntime) |
1186 | runKeyRing keyring = do | 1208 | runKeyRing keyring = do |
@@ -1292,6 +1314,22 @@ runKeyRing keyring = do | |||
1292 | 1314 | ||
1293 | try' externals_ret $ \(db,report_externals) -> do | 1315 | try' externals_ret $ \(db,report_externals) -> do |
1294 | 1316 | ||
1317 | let manips0 = kManip keyring rt | ||
1318 | manips :: Map.Map KeyKey [KeyRingAddress PacketUpdate] | ||
1319 | manips = Map.fromList $ do | ||
1320 | ms <- groupBy ((==EQ) .: comparing topkeyAddress) | ||
1321 | $ sortBy (comparing topkeyAddress) | ||
1322 | manips0 | ||
1323 | k <- fmap topkeyAddress $ take 1 ms | ||
1324 | return (k,ms) | ||
1325 | where (.:) = (.).(.) | ||
1326 | doManips kd = do | ||
1327 | let kk = keykey $ keyPacket kd | ||
1328 | ms = maybe [] id $ Map.lookup kk manips | ||
1329 | foldM interpretManip kd ms | ||
1330 | |||
1331 | db' <- Traversable.mapM doManips db | ||
1332 | |||
1295 | r <- writeWalletKeys keyring db wk | 1333 | r <- writeWalletKeys keyring db wk |
1296 | try' r $ \report_wallets -> do | 1334 | try' r $ \report_wallets -> do |
1297 | 1335 | ||
@@ -1352,6 +1352,7 @@ main = do | |||
1352 | ++ walts | 1352 | ++ walts |
1353 | , kImports = Map.fromList $ | 1353 | , kImports = Map.fromList $ |
1354 | [ ( HomePub, importStyle ) ] | 1354 | [ ( HomePub, importStyle ) ] |
1355 | , kManip = noManip | ||
1355 | , homeSpec = homespec | 1356 | , homeSpec = homespec |
1356 | } | 1357 | } |
1357 | 1358 | ||