2

So I was going about implementing AES encryption of data on an iPhone app, when I was puzzled by how to store the encryption key. I can easily enough encrypt data using a user-entered password, the encryption key. However, if I store the key unencrypted, the encryption is useless as anyone with access could easily enough decrypt the data with the readily-available encryption key. I could encrypt the key, but then there would be another unencrypted key floating around and someone could just follow the chain down to the data. It seemed clear that I could not store the key, so I thought that I could have the key be only in the user's mind. It would be very secure, but I would have no way to check if the decryption worked correctly and all data would be lost in the event that the user forgot their password, which is unacceptable.

Essentially, how can I securely store an encryption key for AES?

I'm sure this situation has been encountered before, as other questions have shown, but they seemed web-focused. I am interested in an iPhone-centric solution, potentially using CommonCrypto?

4

3 回答 3

1

如您所说,不要存储密码。您仍然可以单独存储密码的哈希值并对其进行测试以查看它是否是正确的密码。

于 2012-07-23T12:31:57.737 回答
1

也许您有兴趣将其作为通用服务保存在 Keychain 中?钥匙串服务有一个不错的 Objective-C 包装器,称为SSKeychain

于 2012-07-23T09:55:38.670 回答
0

我在我的项目中使用了一个很好的开源工具包,用于在钥匙链中存储安全数据。

PDKeychainBindingsController

于 2012-07-23T06:05:35.823 回答