10

What is the usage of the kSecAttrIsPermanent attribute when using Apples libcommonCrypto.dylib on iOS?

Apples documentation says:

The corresponding value is of type CFBooleanRef and indicates whether this cryptographic key is to be stored permanently.


What is the reason not to store something permanently in the keychain and how long will it be stored then? (until reboot? until app is closed? until app is uninstalled?)

4

1 回答 1

10

它是SecKeyGeneratePair生成密钥时使用的参数。

来自证书、密钥和信任服务参考

kSecAttrIsPermanent— 如果此密钥存在且布尔值为 true,则将密钥或密钥对添加到默认钥匙串中。

在这种情况下,如果您提供此参数并且它为 false,那么您将在内存中收到密钥,但它不会被持久化到钥匙串(在磁盘上)。无论您在应用程序仍在运行时持有它多长时间,它都会持续多久,除非您事后自己坚持下去。

于 2014-02-06T13:55:37.580 回答