Background:
I was working on an Android application that stores data in a local database as my favorite project. Recently, I decided that I want to password protect the application and encrypt the database. Now I know about the complexities of database encryption on the fly and (given the expected usage model of my application) decided to simply encrypt the entire database file, rather than trying to save the encrypted column value or the like. So far, I have implemented a system that will ask for a password every time the application starts or whenever the user switches from my activity (to take into account that the user presses the home key and the application does not kill in a timely manner).
I'm currently trying to decide how to hash the password and where to store it. Given that everything should be stored on the device, I mainly consider hashes of passwords and salts that have already been compromised, since anyone who has spent 10 minutes reading can connect this device and gain access to my database / preferences.
I have developed something that I think will still provide very strong security, given the above assumptions. I wanted to get feedback from the community to find out if my solution is viable or if there is a better way.
My idea is to generate 10 different values โโof random salts the first time I run the application. These values โโwill be saved with the actual final password hash in the application settings (and not in the database). Please note that there will be only one password, and it is used both for user authentication and for decrypting the database. Whenever a call is provided, the password will be hashed as follows:
- Password Cleartext hashed.
- The Hashed password is triggered through the same checksum algorithm that is used for standard UPC barcodes. This will result in a value between 0 and 9 (inclusive).
- This checksum digit will be used as an index for an array of salt values. This is the only salt value to be added to the current hash.
- A new hash value + salt will be added, and steps 2 through 3 will be repeated.
I believe that this process for 5 iterations would give 5 ^ 10 different salt combinations alone and should make any type of rainbow attack virtually impossible. After the final hash has been verified correctly, it can be used to decrypt the database.
Now I understand that this sounds like overkill for a simple mobile phone application. It. But, this is my favorite project, why not?
Question:
So, after this wall of text, is this approach reasonable or is there a better way? I think with this in place the weakest link would be an attack in memory, or am I mistaken? Any feedback is greatly appreciated.
Thanks in advance.
-cheers
source share