Currently i am generating an Elliptic Curve KeyPair in my iOS App successfully:
let privateKeyParams: [String: Any] = [
kSecAttrIsPermanent as String: true,
kSecAttrApplicationTag as String: privateTag
]
let publicKeyParams: [String: Any] = [
kSecAttrIsPermanent as String: true,
kSecAttrApplicationTag as String: publicTag,
kSecAttrAccessible as String: kSecAttrAccessibleAlways
]
let query: [String: Any] = [
kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom,
kSecPrivateKeyAttrs as String: privateKeyParams,
kSecPublicKeyAttrs as String: publicKeyParams,
kSecAttrKeySizeInBits as String: 256 as AnyObject,
]
let status = SecKeyGeneratePair(query as CFDictionary, &self.publicKey, &self.privateKey)
guard status == errSecSuccess else {
print("Could not generate keypair")
return
}
guard let pubKey = self.publicKey, let privKey = self.privateKey else {
print("Keypair null")
return
}
This one works because when i check if my keys exist they do and i can also encrypt/decrypt and sign/verify.
Soo.. in the next step i need to generate a SecCertificate which will basically hold my public key... this is simply a requirement.
But there is literally no API/Documentation on how to do this..the only api i saw is on how to generate SecCertificate from existing der file etc..
So my question is:
How do i generate an SecCertificate object from my existing Elliptic Curve KeyPair (SecKey)?
Thanks and Greetings!