- Private key is stored in a secure place. Offline for all i care; printed on a piece of paper; memorized and swallowed.
- When user creates the account - password is padded with salt, then a public key is used to encrypt it. The resulting encrypted form is stored, along with the salt.
- When user attempts to authenticate - the password that is provided is padded with the stored salt, encrypted with the public key and compared to the stored password.
Private key is never used when comparing passwords. Never available to the system doing authentication, etc.
The only purpose of using a reversible encryption - is to be able to switch to a different authentication provider completely transparently to the user.
I've implemented this functionality considering that we may need to switch over to active directory (or some other directory) in place of storing passwords in the database - but never used it, fearful that i would be committing some cardinal crime against proper security practices
Thoughts?