summaryrefslogtreecommitdiff
path: root/lib/SSHKey.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-07-13 06:19:11 -0400
committerJoe Crayne <joe@jerkface.net>2019-07-13 06:19:11 -0400
commit142352043699520d3cc3f1c6f1ff4fba585014a8 (patch)
treefd413440226e5e9749df050237d16242cb020102 /lib/SSHKey.hs
parent6d421d484821c2e92430c2702949dd2e9f5ae8a4 (diff)
Avoid external call to ssh-keygen.
Diffstat (limited to 'lib/SSHKey.hs')
-rw-r--r--lib/SSHKey.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/SSHKey.hs b/lib/SSHKey.hs
index bd47169..0ded986 100644
--- a/lib/SSHKey.hs
+++ b/lib/SSHKey.hs
@@ -22,6 +22,14 @@ import LengthPrefixedBE
22 22
23type Key = (Integer,Integer) 23type Key = (Integer,Integer)
24 24
25
26sshrsa :: Integer -> Integer -> L.ByteString
27sshrsa e n = runPut $ do
28 putWord32be 7
29 putByteString "ssh-rsa"
30 put (LengthPrefixedBE e)
31 put (LengthPrefixedBE n)
32
25keyblob :: Key -> L.ByteString 33keyblob :: Key -> L.ByteString
26keyblob (n,e) = "ssh-rsa " <> blob 34keyblob (n,e) = "ssh-rsa " <> blob
27 where 35 where
@@ -32,13 +40,6 @@ keyblob (n,e) = "ssh-rsa " <> blob
32 blob = L8.pack $ Base64.encode (L.unpack bs) 40 blob = L8.pack $ Base64.encode (L.unpack bs)
33#endif 41#endif
34 42
35 sshrsa :: Integer -> Integer -> L.ByteString
36 sshrsa e n = runPut $ do
37 putWord32be 7
38 putByteString "ssh-rsa"
39 put (LengthPrefixedBE e)
40 put (LengthPrefixedBE n)
41
42blobkey :: L8.ByteString -> Maybe Key 43blobkey :: L8.ByteString -> Maybe Key
43blobkey bs = do 44blobkey bs = do
44 let (pre,bs1) = L8.splitAt 7 bs 45 let (pre,bs1) = L8.splitAt 7 bs