summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-19 21:27:22 -0400
committerjoe <joe@jerkface.net>2014-04-19 21:27:22 -0400
commit9e8f7b0293dbc14e1aa9760420ec9c58f3243b7a (patch)
tree07adb2d2474ab98835afb7db301608bd4c80a12d
parente5a61ddac138be9b3a9cd56a7b23811935bc738e (diff)
added kManip
-rw-r--r--KeyRing.hs38
-rw-r--r--kiki.hs1
2 files changed, 39 insertions, 0 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index 4033c3b..b6f16ca 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -127,6 +127,21 @@ data KeyRingRuntime = KeyRingRuntime
127 127
128data KeyRingAction a = KeyRingAction a | RunTimeAction (KeyRingRuntime -> a) 128data KeyRingAction a = KeyRingAction a | RunTimeAction (KeyRingRuntime -> a)
129 129
130data SubKeyKey = SubKeyKey KeyKey | UIDKey String
131 deriving (Eq,Ord)
132
133data PacketUpdate = InducerSignature [SignatureSubpacket]
134
135data KeyRingAddress a = KeyRingAddress
136 { topkeyAddress :: KeyKey
137 , subkeyAddress :: SubKeyKey
138 , keyringAddressed :: a
139 }
140 deriving Functor
141
142noManip :: KeyRingRuntime -> [KeyRingAddress PacketUpdate]
143noManip = const []
144
130data KeyRingData = KeyRingData 145data 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
311usage _ = Nothing 327usage _ = Nothing
312 328
329torSigOver
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
314torSigOver topk wkun uid extras 333torSigOver 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
1203interpretManip :: KeyData -> KeyRingAddress PacketUpdate -> IO KeyData
1204interpretManip kd (KeyRingAddress kk sk (InducerSignature ps)) = error "todo"
1205interpretManip kd manip = return kd
1184 1206
1185runKeyRing :: KeyRingData -> IO (KikiResult KeyRingRuntime) 1207runKeyRing :: KeyRingData -> IO (KikiResult KeyRingRuntime)
1186runKeyRing keyring = do 1208runKeyRing 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
diff --git a/kiki.hs b/kiki.hs
index 7c89882..2968067 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -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