summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/kiki.hs b/kiki.hs
index 03ea635..d4d4084 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -335,12 +335,15 @@ show_wip keyspec wkgrip db = do
335show_torhash :: FilePath -> p -> IO () 335show_torhash :: FilePath -> p -> IO ()
336show_torhash pubkey _ = do 336show_torhash pubkey _ = do
337 bs <- Char8.readFile pubkey 337 bs <- Char8.readFile pubkey
338 let parsekey f dta = do 338 let -- parsekey :: ((MPI -> MPI -> Packet) -> _ -> b) -> Char8.ByteString -> Maybe b
339 parsekey f dta = do
339 let mdta = fmap L.fromStrict $ functorToMaybe $ convertFromBase Base64 (Char8.toStrict dta) 340 let mdta = fmap L.fromStrict $ functorToMaybe $ convertFromBase Base64 (Char8.toStrict dta)
340 e <- decodeASN1 DER <$> mdta 341 e <- decodeASN1 DER <$> mdta
341 asn1 <- either (const Nothing) (Just) e 342 asn1 <- either (const Nothing) (Just) e
342 k <- either (const Nothing) (Just . fst) (fromASN1 asn1) 343 k <- either (const Nothing) (Just . fst) (fromASN1 asn1)
343 return $ f (packetFromPublicRSAKey undefined) k 344 return $ f (packetFromPublicRSAKey pgpver (error "torhash timestmap?")) k
345
346 pgpver = 4 :: Word8
344 347
345 addy :: String -> String 348 addy :: String -> String
346 addy hsh = take 16 hsh ++ ".onion " ++ hsh 349 addy hsh = take 16 hsh ++ ".onion " ++ hsh
@@ -348,7 +351,7 @@ show_torhash pubkey _ = do
348 $ pemParser (Just "RSA PUBLIC KEY") 351 $ pemParser (Just "RSA PUBLIC KEY")
349 pkcs8 = fmap ( parsekey (\f (RSAKey8 n e) -> f n e) . pemBlob ) 352 pkcs8 = fmap ( parsekey (\f (RSAKey8 n e) -> f n e) . pemBlob )
350 $ pemParser (Just "PUBLIC KEY") 353 $ pemParser (Just "PUBLIC KEY")
351 cert = fmap (fmap pcertKey . parseCertBlob False . pemBlob) 354 cert = fmap (fmap pcertKey . parseCertBlob pgpver False . pemBlob)
352 $ pemParser (Just "CERTIFICATE") 355 $ pemParser (Just "CERTIFICATE")
353 keys = catMaybes $ scanAndParse (pkcs1 <> pkcs8 <> cert) $ Char8.lines bs 356 keys = catMaybes $ scanAndParse (pkcs1 <> pkcs8 <> cert) $ Char8.lines bs
354 mapM_ (putStrLn . addy . torhash) keys 357 mapM_ (putStrLn . addy . torhash) keys