crypto-pouch icon indicating copy to clipboard operation
crypto-pouch copied to clipboard

enhancement: support changing password

Open arolson101 opened this issue 8 years ago • 5 comments

Currently you take the user password, pass it through pbkdf2, then use the result as the encryption key. If you were to instead use the result to encrypt/decrypt a buffer containing the key, then you could change the password trivially.

arolson101 avatar Dec 03 '16 16:12 arolson101

hm not a bad idea

On Sat, Dec 3, 2016 at 11:03 AM arolson101 [email protected] wrote:

Currently you take the user password, pass it through pbkdf2, then use the result as the encryption key. If you were to instead use the result to encrypt/decrypt a buffer containing the key, then you could change the password trivially.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/calvinmetcalf/crypto-pouch/issues/42, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4n-5WRl1uqQcWu3e7eW3h9z3SDuj2ks5rEZK3gaJpZM4LDVdO .

calvinmetcalf avatar Dec 04 '16 00:12 calvinmetcalf

you could also use this to easily validate whether the password is correct

arolson101 avatar Dec 04 '16 17:12 arolson101

you get an error about being unable to decrypt when that happens now, because you never actually know if it's because somebody modified the db or your password is wrong

calvinmetcalf avatar Dec 04 '16 21:12 calvinmetcalf

Hey, just checking in here. Changing passwords is an inevitable part of working with passwords, so I'm certainly interested in implementing this in crypto-pouch. Could y'all explain it to me again?

garbados avatar Aug 06 '21 23:08 garbados

Create a random db encryption key (dbkey). User provides key (ukey). Use ukey to encrypt dbkey (edbkey), store it separately from the db itself.

When opening db, get ukey from user, get edbkey from store, use ukey to decrypt edbkey to get dbkey and use it for db. If the decryption fails it’s because you have the wrong key- no cryptic message.

To rekey the db, just get a new ukey, re-encrypt dbkey with it and overwrite the stored edbkey.

arolson101 avatar Aug 07 '21 00:08 arolson101