Background: I have little knowledge of hashing and encryption, so please bear with me. I have posted a related question here: http://programmers.stackexchange.com/questions/232261/options-for-client-side-encryption-of-local-web-databases for the programming perspective, which may give some background. That question was about the general feasibility of the overall product. In a sense, this question is a follow-up, about the actual implementation, but as it is more technical on the security side I felt it would be better posted here. Feel free to post on either question/both questions as appropriate.
I have been tasked in securing local data for a web application that can be used offline, so interaction with the server for authentication and encryption is not an option. This would be optional, for users who would like an extra layer of protection on top of the hardware encryption.
The application will be for a single user per device. The goal is to try and reduce the risk of unauthorised access to sensitive data if a device is lost or stolen.
My initial ideas of how I could do this are:
- Require the user to enter a password every time the application starts.
- Hash the password using PBKDF2, storing the hash and the salt locally, e.g. in WebSQL.
- User would then enter their password, it could be re-hashed using the loaded salt and compared against the stored hash.
- Use this as a key for encrypting and decrypting (using AES) data in the database.
Q: How could this approach be improved? Would hashing the password in two different ways, one for storage, and one for encryption/decryption, be sufficient? Is there anything more that I could be doing, bearing in mind the limitations of working with web storage and without a server/external hardware to assist?
Also - although the user will be working offline with the application, so the data needs to be local and encrypted, there will be an initial connection to the server to actually download the application. So if there is anything I can do based on that initial connection that might help then let me know.