I have a question about encrypting master data. I store some sensitive user data in a SQL Server database. The critical values ββare all transformers, and I use AES256 to encrypt and decrypt them on the fly, including an individual IV for each value. The encryption key is the SHA512 hash of the password that the user selected. It works very well so far.
Now about the user password. When the user starts the application, they are asked for a password. The password is hashed with SHA512 and stored in the iOS keychain. For each write or read operation, NSValueTransformer will receive a password from the key fob. If the application closes, I delete the password hash from the key fob.
In my Core Data database, I have a special entity that has a random number! = 0, since this is only a value. To check if the user has entered the correct password, I retrieve this object and read the number. If it is =! 0, I know that the password was right, because when decryption fails, NSValueTransformer always returns 0.
Now my actual questions: do you think a good approach to encryption? How else could you verify the password you entered is correct?
I'm a little worried that keeping the password hash in the keychain while the application is running is getting slower because NSValueTransformer has to constantly access the keychain. Would it be safe enough to just store the password hash in memory, so will it be deleted when the application closes?
source share