summaryrefslogtreecommitdiff
path: root/lib/Kiki.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Kiki.hs')
-rw-r--r--lib/Kiki.hs20
1 files changed, 0 insertions, 20 deletions
diff --git a/lib/Kiki.hs b/lib/Kiki.hs
index 5481241..7cb373c 100644
--- a/lib/Kiki.hs
+++ b/lib/Kiki.hs
@@ -37,12 +37,8 @@ import System.Posix.Files
37import System.Posix.Types (FileMode) 37import System.Posix.Types (FileMode)
38import System.Posix.IO as Posix (createPipe) 38import System.Posix.IO as Posix (createPipe)
39import System.Posix.User 39import System.Posix.User
40#if defined(VERSION_memory)
41import Data.ByteArray.Encoding 40import Data.ByteArray.Encoding
42import qualified Data.ByteString.Char8 as S8 41import qualified Data.ByteString.Char8 as S8
43#elif defined(VERSION_dataenc)
44import qualified Codec.Binary.Base64 as Base64
45#endif
46import qualified Data.ByteString.Lazy as L 42import qualified Data.ByteString.Lazy as L
47import qualified Data.ByteString.Lazy.Char8 as Char8 43import qualified Data.ByteString.Lazy.Char8 as Char8
48import qualified Data.Map.Strict as Map 44import qualified Data.Map.Strict as Map
@@ -74,18 +70,12 @@ cipherFromString s =
74 _ -> error $ "known ciphers: "++unwords (map ciphername ciphers) 70 _ -> error $ "known ciphers: "++unwords (map ciphername ciphers)
75 {- 71 {-
76 where 72 where
77#if defined(VERSION_memory)
78 unhex hx = case convertFromBase Base16 (S8.pack hx) of 73 unhex hx = case convertFromBase Base16 (S8.pack hx) of
79 Left e -> do 74 Left e -> do
80 -- Useful for debugging but insecure generally ;) 75 -- Useful for debugging but insecure generally ;)
81 -- putStrLn $ "convertFromBase error for input "++show hx++": "++show e 76 -- putStrLn $ "convertFromBase error for input "++show hx++": "++show e
82 return Nothing 77 return Nothing
83 Right bs -> return $ Just $ S8.unpack bs 78 Right bs -> return $ Just $ S8.unpack bs
84#elif defined(VERSION_dataenc)
85 unhex hx = maybe (return () {- putStrLn $ "dataenc error for input "++show hx -})
86 return
87 $ fmap (map $ chr . fromIntegral) $ Base16.decode hx
88#endif
89-} 79-}
90 80
91 81
@@ -619,21 +609,11 @@ showA addr = if null bracket then pre else drop 1 pre
619 where (pre,bracket) = break (==']') (show addr) 609 where (pre,bracket) = break (==']') (show addr)
620 610
621 611
622#if !MIN_VERSION_base(4,8,0)
623sortOn :: Ord b => (a -> b) -> [a] -> [a]
624sortOn f =
625 map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x))
626#endif
627
628pemFromPacket :: Monad m => Packet -> m String 612pemFromPacket :: Monad m => Packet -> m String
629pemFromPacket k = do 613pemFromPacket k = do
630 let rsa = pkcs8 . fromJust $ rsaKeyFromPacket k 614 let rsa = pkcs8 . fromJust $ rsaKeyFromPacket k
631 der = encodeASN1 DER (toASN1 rsa []) 615 der = encodeASN1 DER (toASN1 rsa [])
632#if defined(VERSION_memory)
633 qq = S8.unpack $ convertToBase Base64 (L.toStrict der) 616 qq = S8.unpack $ convertToBase Base64 (L.toStrict der)
634#elif defined(VERSION_dataenc)
635 qq = Base64.encode (L.unpack der)
636#endif
637 return $ 617 return $
638 writePEM PemPublicKey qq -- ("TODO "++show keyspec) 618 writePEM PemPublicKey qq -- ("TODO "++show keyspec)
639 619