Here's the Swift code, here's the doc https://developer.apple.com/documentation/security/1823694-seckeycreaterandomkey.
guard
let aclObject = SecAccessControlCreateWithFlags(
kCFAllocatorDefault,
kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly,
[.privateKeyUsage,.touchIDAny],
nil
) else {
print("could not create ACL error")
return""
}
// private key parameters
let privateKeyParams: [String: AnyObject] = [
kSecAttrAccessControl asString: aclObject asAnyObject, //protect with touch id
kSecAttrIsPermanent asString: trueas AnyObject,
]
// global parameters for our key generation
let parameters: [String: AnyObject] = [
kSecAttrTokenID asString: kSecAttrTokenIDSecureEnclave,
kSecAttrKeyType asString: kSecMessECCKeyType,
kSecAttrKeySizeInBits asString: kSecMessECCKeySize asAnyObject,
kSecAttrLabel asString: kSecMessECCSignLabel asAnyObject,
kSecPrivateKeyAttrs asString: privateKeyParams asAnyObject
]
guard
let eCCPrivKey = SecKeyCreateRandomKey(parameters asCFDictionary, nil) else {
print("ECC KeyGen Error!")
return""
}
guard
let eCCPubKey = SecKeyCopyPublicKey(eCCPrivKey) else {
print("ECC Pub KeyGen Error")
return""
}
We currently don't have a way to do that because we didn't open the keys (they are [Internal]).
Similar to https://github.com/xamarin/xamarin-macios/pull/3438 we should have a strong dictionary based on the Apple documentation linked above to set those keys (with strong types).
We can't set the keys.
As I have a stake in the matter I would like to do it.
Most helpful comment
As I have a stake in the matter I would like to do it.