mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added importsshpubkey to get the raw key bytes from an openssh format pubkey ssh-ed25519 <b64 blob> <comment>
This commit is contained in:
@@ -26,12 +26,15 @@ class KeyManager: ObservableObject {
|
||||
let key = Curve25519.Signing.PrivateKey()
|
||||
let privatekeyData = key.rawRepresentation
|
||||
let publickeyData = key.publicKey.rawRepresentation
|
||||
print(publickeyData.base64EncodedString())
|
||||
let pubpem = makeSSHPubkey(pub: publickeyData, comment: "neon443@m")
|
||||
let privpem = makeSSHPrivkey(pub: publickeyData, priv: privatekeyData, comment: "neon443@m")
|
||||
print(String(data: pubpem, encoding: .utf8)!)
|
||||
print()
|
||||
print(String(data: privpem, encoding: .utf8)!)
|
||||
print()
|
||||
|
||||
print(importSSHPubkey(pub: String(data: pubpem, encoding: .utf8)!).base64EncodedString())
|
||||
}
|
||||
|
||||
func loadTags() {
|
||||
@@ -59,6 +62,19 @@ class KeyManager: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func importSSHPubkey(pub: String) -> Data {
|
||||
let split = pub.split(separator: " ")
|
||||
guard split.count == 3 else { return Data() }
|
||||
|
||||
var pubdata = Data(base64Encoded: String(split[1]))!
|
||||
while pubdata.count != 36 {
|
||||
let lengthOfField = Int(pubdata[3])
|
||||
pubdata.removeFirst(4 + lengthOfField)
|
||||
}
|
||||
pubdata.removeFirst(4)
|
||||
return pubdata
|
||||
}
|
||||
|
||||
func makeSSHPubkey(pub: Data, comment: String) -> Data {
|
||||
let header = "ssh-ed25519"
|
||||
var keyBlob: Data = Data()
|
||||
|
||||
Reference in New Issue
Block a user