作者:Kanxsg | 来源:互联网 | 2023-08-16 14:47
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.
我想在iPhone上生成密钥对,这样私钥就只能用于在特定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
).
SecKeyGeneratePair函数看起来很有前途。我可以为钥匙串生成密钥对(使用kSecAttrIsPermanent),我可以使用私钥禁用解密,派生和解包(将kSecAttrCanDecrypt,kSecAttrCanDerive和kSecAttrCanUnwrap设置为false)。
Two things worry me about key pairs generated with SecKeyGeneratePair
:
有两件事让我担心使用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
to true
) after a private key has been created?
是否可以在创建私钥后更改密钥属性(例如,将kSecAttrCanDecrypt设置为true)?
2 个解决方案