我试图使用iOS上的KeyChain创建Curve25519密钥。我知道CryptoKit的存在,但不幸的是,它不适用于iOS 12。在没有CryptoKit的情况下,是否有一种方法可以创建Curve25519密钥,也许是在生成时缺少的参数?下面的代码仅生成P-256密钥。
let attributes: [String: Any] = [
String(kSecClass): kSecClassKey,
String(kSecAttrKeyType): kSecAttrKeyTypeECSECPrimeRandom,
String(kSecAttrKeySizeInBits): 256
]
var error: Unmanaged<CFError>?
let privateKey = SecKeyCreateRandomKey(attributes as CFDictionary, &error)
print(privateKey ?? error!.takeUnretainedValue())