A system I'm implementing requires a user to create a single user, with a single login password.
I want to have a single password for the system, and not require multiple different password entries in order to encrypt/decrypt files after login in (the main purpose of this system).
The way I've implemented this is: when the user first setups on the account password,
- the password is hashed (bcrypted) *
- a salt is generated *
- a crypto key is generated using PBKDF2 (based on the salt)
- 256 random bits are generated
- the 256 bits are encrypted with the key derived using PBKDF2 *
All of the above "*" information is stored in a database
The decrypted 256 bits are used for the actual file encryption/decryption.
The reason I'm doing it this way, is if the single user decides to change his password, the files will still be decryptable (i just have to re-encrypt the random 256 bits with the new password).
Is this a common and secure approach?