4 ms·
Bcrypt seems to have a big design oversight. Given a password stored with cost factor C1 that you would like to increase to cost factor C2, it seems to me that
by tzs 15y ago
Bcrypt seems to have a big design oversight. Given a password stored with cost factor C1 that you would like to increase to cost factor C2, it seems to me that you have to have the plaintext password to do this. Thus, you have to wait until that user next provides the password, verify it, and then re-store it with cost factor C2.
- deleted 15y ago[deleted]
- bradleyland 15y agoThat's no bug, its a feature! Seriously though, this is a design decision that cannot be easily solved with any non-reversible encryption. If you were able to increase the cost factor, the you'd open the algorithm to attacks that reverse that process.
- daeken 15y agoErr, no, that's actually not true. Take the case of PBKDF2 -- if you apply 1000 rounds of PBKDF2 to password X to get X' then apply 1000 rounds to PBKDF2 to password X' to get X'', applying 2000 rounds of PBKDF2 to password X == X''. You could increase the cost factor (number of rounds) every time the password is used, for instance.
- RyanMcGreal 15y agoUnless you run C2 on top of C1.
- tedunangst 15y agobcrypt doesn't work like that. The outline is: work * costfactor finish The finish step is irreversible, so you can't unwind it and add more work later. In practice though, even low cost factors for bcrypt are tons more work than MD5 or SHA. It's not a big deal.
- palish 15y agoHe didn't say "unwind it". He said "on top of it". bcrypt( bcrypt( "foo", c1 ), c2 )
- tzs 15y agoI think what he means by run C2 on top of C1 is something like this. Let b(k,w) mean bcrypt with work factor w on input k. So, initially, you are storing b(pass,C1). Running C2 on top of C1 would mean replacing that with b(b(pass,C1),C2). Later, when you want even more work, another layer could be added: b(b(b(pass,C1),C2),C3) and so on.
- tedunangst 15y agough, no thank you.
- tedunangst 15y agoDear down voters, parent is accurate (except possibly for saying "big").
- smanek 15y agoThat's just not true. To oversimplify a bit, let's say BCrypt is a function b(data, cost) that returns a hash. Right now, I have b(password, c1) = hash_a stored in my database. To increase the cost to c1+c2, I just replace that with b(hash_a, c2) = hash_b in my database. To verify a user's login, I just compute b(b(password, c1), c2) and compare it to the hash_b I have stored. Am I missing anything?
- tedunangst 15y agoYes. That's not how bcrypt really works.
- smanek 15y agoI've read the usenix paper, and I'm reasonably sure I'm right. Care to elaborate on what I'm mistaken about? I (and a few other people I've talked to about schemes isomorphic to this about) may learn something new :-D
- tedunangst 15y agoOK, so you can chain bcrypt in theory, but if you look at the API and how it stores rounds/salt, I don't think you'll enjoy implementing the code to do so. You can't just store hash_b, you'll need to store hash_a too. It's not worth it. Basically, the assumption that bcrypt is just a function that returns a hash oversimplifies the detail of how salt is stored in practice.
- tptacek 15y agoI wrote a comment to the effect of "you can just chain bcrypt" but deleted it because I didn't want to wade into exactly this tarpit. If a client asked me how to upgrade the cost of their password hashes, I'd probably tell them to validate incoming plaintext and then create a fresh hash. I agree: this is not a big deal in practice. bcrypt with a cost factor of 10 is so much slower than SHA1 that this is just not going to be an issue.
- 15y ago
- keeperofdakeys 15y agoI would say that, given how 'cheap', you could slowly increment the cost-factor over time. You could also ask a user to replace their password after a certain time period, or after the cost factor gets too 'low' - you can even allow the same password to be entered. Having a different cost-factor for every password is a bit of a logistical nightmare though. The fact is that any significantly high cost factor is much better than md5, sha1 or any other normal hashing function, and should prevent password cracking for 5-10 years. This is a reasonable period of time.