Closed Fonta1n3 closed 4 years ago
Encoding the data to base64 string then base32 seems to have fixed this:
import CryptoKit
import Foundation
class KeyGen {
var privKey = ""
var pubKey = ""
func generate() {
if #available(iOS 13.0, *) {
let privKeyRaw = Curve25519.Signing.PrivateKey.init()
let pubKeyRaw = privKeyRaw.publicKey
let privKeyData = privKeyRaw.rawRepresentation
let pubkeyData = pubKeyRaw.rawRepresentation
let privkeyBase64 = privKeyData.base64EncodedString()
let pubkeyBase64 = pubkeyData.base64EncodedString()
let privkeyBase32 = privkeyBase64.base32EncodedString
let pubkeyBase32 = pubkeyBase64.base32EncodedString
privKey = privkeyBase32.replacingOccurrences(of: "=", with: "")
pubKey = pubkeyBase32.replacingOccurrences(of: "=", with: "")
}
}
}
In KeyGen.swift I am attempting to make use of the iOS13 module
CryptoKit
. I am trying to mirror the functionality of this python script to generate x25519 keypair, trim the trailing====
and base32 encode it.Everytime I try and use the keypair to authenticate my tor v3 HS it fails. I think I am going wrong in the base32 encoding, do not have the time to focus on this. If anyone can help it would be much appreciated.