diff options
Diffstat (limited to 'SSHKey.hs')
-rw-r--r-- | SSHKey.hs | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -8,7 +8,7 @@ import Data.Binary.Get ( runGet ) | |||
8 | import Data.Binary.Put ( putWord32be, runPut, putByteString ) | 8 | import Data.Binary.Put ( putWord32be, runPut, putByteString ) |
9 | import Data.Binary ( get, put ) | 9 | import Data.Binary ( get, put ) |
10 | import Data.Monoid ( (<>) ) | 10 | import Data.Monoid ( (<>) ) |
11 | import Data.Maybe ( fromMaybe, listToMaybe ) | 11 | import Data.Maybe ( listToMaybe ) |
12 | import Data.Char ( isSpace ) | 12 | import Data.Char ( isSpace ) |
13 | import Control.Monad ( guard ) | 13 | import Control.Monad ( guard ) |
14 | import LengthPrefixedBE | 14 | import 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 | ||
31 | blobkey :: L8.ByteString -> Key | 31 | blobkey :: L8.ByteString -> Maybe Key |
32 | blobkey bs = fromMaybe er $ do | 32 | blobkey 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 |