This question already has an answer here:
In my application I would like to encrypt user data in such a way that I do not have access to it. To do this I will follow the following steps:
- Generate 256-bit key
- Encrypt data with key
- Derive second key from password (PBKDF2)
- Encrypt 1st key, destroy plain text key
- Store hashed+salted password and encrypted key
Now my issue is this: I still need to provide a way to reset the password when it is forgotten.
I realise that following this trust-no-one style scheme directly counters the ability to provide a password reset feature but I am hoping for a solution that can help maintain the spirit of the scheme through a healthy compromise, without requiring a second secret from the user like answers to security questions or a trusted third party.
- Storing a copy of the per-user encryption key with a key my application controls as a backup, ready to be re-encrypted with their new (reset) password for daily operations. To be clear, I am fine with having access to the data myself - instead I am aiming to limit the potential data a successful hacker could access.
- On signup, sending a password reset link to thier email that contains a key in the link used to encrypt a backup version of the encrypted key, ready for re-encryption using the new password.