I currently store my users passwords as PBKDF2 hashes, for the authentication part of my web application.
Each user also has their own private key and public key (also stored in their user profile in the database). The private key is encrypted with their plain text password upon registration.
Now, I've come to the part where I need to retrieve the user's private key, to decrypt other data - so the issue is; what would be the best way to allow me to access the user's private key?
I have a couple of ideas in mind:
I could (upon login) decrypt the private key, then encrypt it with DPAPI and store it in persistent memory (server side).
I could encrypt the user's password with an OTP, and then store the encrypted password in a cookie (on each request I could generate a new OTP, re-encrypt the password, and put back in the cookie) The OTP would have to be stored in server-side persistent memory (probably encrypted with DPAPI).
I could store the store the OTP and the encrypted password in persistent memory (server side).
I could store half of the password (encrypted) in a cookie and half in persistent memory (server side).
Which one of these options would be the most secure? Is there another method that I haven't thought of?
I know rolling your own is a baaad thing, but this application doesn't need to be government level super secure, but I would like it to be as secure as I can possibly make it.