I want to generate a key pair on an iPhone such that the private key can only ever be used to sign blocks of data on that particular iPhone.
The SecKeyGeneratePair
function looks promising. I can generate a key pair to the keychain (using kSecAttrIsPermanent
) and I can disable decryption, derivation and unwrapping with the private key (setting kSecAttrCanDecrypt
, kSecAttrCanDerive
and kSecAttrCanUnwrap
to false
).
Two things worry me about key pairs generated with SecKeyGeneratePair
:
Is it possible to export the private key outside of the keychain into application memory?
Is it possible to change a key property (e.g. set
kSecAttrCanDecrypt
totrue
) after a private key has been created?
kSecAttrTokenIDSecureEnclave
may not work with RSA key pairs. – Cytosine