ateiob Every time you store the main password in the application, you really just complicate the access of unauthorized users to encrypted data a little.
Firstly, we can agree that data encryption using the "master key" built into the application and saving data on the phone is open in order to have a "master key" with reverse processing and data decryption.
Secondly, I think we can agree that encrypting data with a secret password and then deleting the secret password should be quite secure using strong encryption, 256-bit keys and strong passwords. Both methods apply to programming on mobile devices. In fact, iOS supports BOTH needs out of the box.
[keychainData setObject:@"password" forKey:(id)kSecValueData];
Perhaps a real example might help.
Let's say that if the temporary data field is to be stored and protected on low memory, it can be encrypted with the main password and cleared when the user clears the temporary data field. A temporary data field is never saved as plain text.
Thus, there are two passwords, a master password built into the application for temporary short-term encryption and a secret password, which should usually be entered by the user, for long-term stored encrypted data.
Finally, if you are encrypting files, consider adding a different level of indirection. So the current secret password is used to encrypt a random key, which is used to encrypt all user files. This allows the user to change the secret password without the need to decrypt, encrypt all encrypted files.
Jal
source share