diff options
author | Andrew Cady <d@jerkface.net> | 2019-07-13 15:22:45 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2019-07-13 15:41:12 -0400 |
commit | 006d1f0b7f36c25a91006fce24cbe76416fcee86 (patch) | |
tree | bf3e95582edf806677c6aaf56c825ba33c2c2974 /lib/SSHKey.hs | |
parent | 495d9fbac3d633b768d910fced5cf00d00118fa0 (diff) |
no cpp needed, since my love is unconditional
Diffstat (limited to 'lib/SSHKey.hs')
-rw-r--r-- | lib/SSHKey.hs | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/lib/SSHKey.hs b/lib/SSHKey.hs index 0ded986..81df18c 100644 --- a/lib/SSHKey.hs +++ b/lib/SSHKey.hs | |||
@@ -1,16 +1,11 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | 1 | {-# LANGUAGE OverloadedStrings #-} |
2 | {-# LANGUAGE CPP #-} | ||
3 | module SSHKey where | 2 | module SSHKey where |
4 | 3 | ||
5 | import qualified Data.ByteString.Lazy.Char8 as L8 | 4 | import qualified Data.ByteString.Lazy.Char8 as L8 |
6 | import qualified Data.ByteString.Lazy as L | 5 | import qualified Data.ByteString.Lazy as L |
7 | #if defined(VERSION_memory) | ||
8 | import qualified Data.ByteString.Char8 as S8 | 6 | import qualified Data.ByteString.Char8 as S8 |
9 | import Data.ByteArray.Encoding | 7 | import Data.ByteArray.Encoding |
10 | import FunctorToMaybe | 8 | import FunctorToMaybe |
11 | #elif defined(VERSION_dataenc) | ||
12 | import qualified Codec.Binary.Base64 as Base64 | ||
13 | #endif | ||
14 | import Data.Binary.Get ( runGet ) | 9 | import Data.Binary.Get ( runGet ) |
15 | import Data.Binary.Put ( putWord32be, runPut, putByteString ) | 10 | import Data.Binary.Put ( putWord32be, runPut, putByteString ) |
16 | import Data.Binary ( get, put ) | 11 | import Data.Binary ( get, put ) |
@@ -34,11 +29,7 @@ keyblob :: Key -> L.ByteString | |||
34 | keyblob (n,e) = "ssh-rsa " <> blob | 29 | keyblob (n,e) = "ssh-rsa " <> blob |
35 | where | 30 | where |
36 | bs = sshrsa e n | 31 | bs = sshrsa e n |
37 | #if defined(VERSION_memory) | ||
38 | blob = L.fromStrict $ convertToBase Base64 (L.toStrict bs) | 32 | blob = L.fromStrict $ convertToBase Base64 (L.toStrict bs) |
39 | #elif defined(VERSION_dataenc) | ||
40 | blob = L8.pack $ Base64.encode (L.unpack bs) | ||
41 | #endif | ||
42 | 33 | ||
43 | blobkey :: L8.ByteString -> Maybe Key | 34 | blobkey :: L8.ByteString -> Maybe Key |
44 | blobkey bs = do | 35 | blobkey bs = do |
@@ -47,11 +38,7 @@ blobkey bs = do | |||
47 | let (sp,bs2) = L8.span isSpace bs1 | 38 | let (sp,bs2) = L8.span isSpace bs1 |
48 | guard $ not (L8.null sp) | 39 | guard $ not (L8.null sp) |
49 | bs3 <- listToMaybe $ L8.words bs2 | 40 | bs3 <- listToMaybe $ L8.words bs2 |
50 | #if defined(VERSION_memory) | ||
51 | qq <- fmap L.fromStrict $ functorToMaybe $ convertFromBase Base64 $ L.toStrict bs3 | 41 | qq <- fmap L.fromStrict $ functorToMaybe $ convertFromBase Base64 $ L.toStrict bs3 |
52 | #elif defined(VERSION_dataenc) | ||
53 | qq <- L.pack `fmap` Base64.decode (L8.unpack bs3) | ||
54 | #endif | ||
55 | decode_sshrsa qq | 42 | decode_sshrsa qq |
56 | where | 43 | where |
57 | decode_sshrsa :: L8.ByteString -> Maybe Key | 44 | decode_sshrsa :: L8.ByteString -> Maybe Key |