summaryrefslogtreecommitdiff
path: root/SSHKey.hs
diff options
context:
space:
mode:
Diffstat (limited to 'SSHKey.hs')
-rw-r--r--SSHKey.hs8
1 files changed, 3 insertions, 5 deletions
diff --git a/SSHKey.hs b/SSHKey.hs
index 6e92e43..488f55f 100644
--- a/SSHKey.hs
+++ b/SSHKey.hs
@@ -8,7 +8,7 @@ import Data.Binary.Get ( runGet )
8import Data.Binary.Put ( putWord32be, runPut, putByteString ) 8import Data.Binary.Put ( putWord32be, runPut, putByteString )
9import Data.Binary ( get, put ) 9import Data.Binary ( get, put )
10import Data.Monoid ( (<>) ) 10import Data.Monoid ( (<>) )
11import Data.Maybe ( fromMaybe, listToMaybe ) 11import Data.Maybe ( listToMaybe )
12import Data.Char ( isSpace ) 12import Data.Char ( isSpace )
13import Control.Monad ( guard ) 13import Control.Monad ( guard )
14import LengthPrefixedBE 14import LengthPrefixedBE
@@ -28,8 +28,8 @@ keyblob (n,e) = "ssh-rsa " <> blob
28 put (LengthPrefixedBE e) 28 put (LengthPrefixedBE e)
29 put (LengthPrefixedBE n) 29 put (LengthPrefixedBE n)
30 30
31blobkey :: L8.ByteString -> Key 31blobkey :: L8.ByteString -> Maybe Key
32blobkey bs = fromMaybe er $ do 32blobkey bs = do
33 let (pre,bs1) = L8.splitAt 7 bs 33 let (pre,bs1) = L8.splitAt 7 bs
34 guard $ pre == "ssh-rsa" 34 guard $ pre == "ssh-rsa"
35 let (sp,bs2) = L8.span isSpace bs1 35 let (sp,bs2) = L8.span isSpace bs1
@@ -38,8 +38,6 @@ blobkey bs = fromMaybe er $ do
38 qq <- L.pack `fmap` Base64.decode (L8.unpack bs3) 38 qq <- L.pack `fmap` Base64.decode (L8.unpack bs3)
39 decode_sshrsa qq 39 decode_sshrsa qq
40 where 40 where
41 er = error "Unsupported key format"
42
43 decode_sshrsa :: L8.ByteString -> Maybe Key 41 decode_sshrsa :: L8.ByteString -> Maybe Key
44 decode_sshrsa bs = do 42 decode_sshrsa bs = do
45 let (pre,bs1) = L8.splitAt 11 bs 43 let (pre,bs1) = L8.splitAt 11 bs