4 ms·
This is a good post, but there's a little too much ritual in here about password-based KDFs for my taste. Put all the mainstream KDFs on a dartboard, yes includ
by tptacek 2y ago
This is a good post, but there's a little too much ritual in here about password-based KDFs for my taste. Put all the mainstream KDFs on a dartboard, yes including PBKDF2, and throw a dart. I think you'll be fine. Bcrypt, the most popular password hash, has held up surprisingly well, and scrypt might still be one of the best options.
- Vecr 2y agoThere's no point intentionally making your implementation weaker than it has to be.
- delusional 2y agoThe complement is also true. There's no point in making it stronger than it has to be. If I have this box that says Bcrypt, but scrypt might be better. I can either spend a bunch of time re-implementing scrypt, or I can shove Bcrypt into there and move on. If Bcrypt is sufficient, then I don't really care if scrypt would be "better"
- Vecr 2y agoI think tptacek is talking about a ground-up design, in that case I think you should use Argon2id. Using something weaker is not really needed, turn the parallelism down to 1 and then start reducing the rounds and memory until it works for your case.
- tptacek 2y agoI would probably still reach for scrypt.
- Aachen 2y agoThe LUKS2 source code mentions there is an attack on Argon2 which they prevent by setting rounds to 2 or 4 iirc. Not sure what that's about though, would need to look it up again but perhaps heed the recommended settings to avoid such pitfalls As for parallelism=1, why would you do that? My understanding is that you want it to a point where it'll saturate your memory bus because then you're getting the most out of your system -> making it the hardest for the attacker. (Pretty sure this takes more than one thread on a modern system because I've tested that argon2id with the same number of rounds and memory gets faster with more threads.) Beyond that, increasing memory usage is good because that dominates the die space of an ASIC which in turn dominates the cost, if I remember and understood the argon2 paper correctly. The repetitions value is the last thing to touch, namely when you've run out of threads and usable RAM (such as when it gets into DoS territory) (I focus on argon2 because that's what I've read up on. Scrypt is also a good option but I'm not sure the same advice applies because it has this TMTO attack. The underlying concepts will be the same of course, but tweaking one parameter before another may play into the attacker's hand.)
- Vecr 2y agoNo. The parallelism is an upper bound, higher reduces security. If you're running a server for multiple clients each client should only get one thread for argon2 anyway, more won't help your overall throughput.
- Aachen 2y agoI'm not understanding the why behind that claim
- Vecr 2y agoIt's been a while, I thought it was something to do with the blocks but it probably depends on what the exact state of the art is for cracking at this point. Don't put it any higher than 4, that's for sure. In theory a parallelism on 1 should make it so the information required to do the next step has to be computed linearly (think of the dependency graph, it should look like a line instead of diverging then converging) but it's possible that either never worked or got cracked.
- rstuart4133 2y agoPBKDF2 makes it harder by using more ALU related functions to calculate the key. The problem is ALU's are rather easy to add to a chip, which means it is relatively easy to increase parallelism. ALU parallelism is I'm guessing what you are thinking of. The others target other constraints, with varying degrees of success. Scrypt for example targets the connection between the CPU chip and DRAM. It doesn't use a lot of CPU time, but rather jumps in a very random way over a whole pile of memory. So adding ALU's doesn't help you crack scrypt. You have to increase memory bandwidth. How fast you can access memory is effectively limited by the numbers of pins you can put on a die, and the number of pins is far harder to increase that the number of ALU's. So the answer is yes parallelism always helps, but if you chose the things that constrains you to stuff that is hard to add (like pins) adding that parallelism is hard.
- vintermann 2y agoYes, it was conspicuous to me that for the two other examples, they mentioned "this has been used in a real attack!", but for key derivation functions, they didn't say that. Sure, you should still use Argon2.
- Aachen 2y agoStill a difference between "you'll be fine" and "if you're newly choosing, might as well not pick PBKDF2 where anyone with a regular GPU gets a 100x speedup compared to your server CPU". Bcrypt wasn't even designed for memory hardness but is so much more annoying to crack because it seems to stress (per my understanding) the GPU's memory bus just enough with the iirc 4k state table that's being randomly accessed
- layer8 2y agoIn the browser, PBKDF2 can still make sense, because all modern browsers support it via SubtleCrypto.deriveKey(), and you may want to avoid the overhead of a JS-implemented alternative. Just select the maximum iteration count that is still acceptable for your use case and targeted devices (mobile devices tend to be the slowest).
- Aachen 2y agoVery true. May make sense to check how WASM implementations stack up, though. Makes me realise I don't even know if WASM does multithreading; maybe via background workers?
- FreakLegion 2y agoI'd draw a line at the post's NIST-adjacent advice. With the caveat that I may be up to two years out of date here: Last I checked Balloon was a bad choice (only a research implementation) and Argon2 didn't meet the requirements (unapproved primitive in BLAKE2). With enough rigamarole can you get these into a government office? Probably. But scrypt and yescrypt (the default on most Linux systems) already fit the bill, so just use one of those.
- tptacek 2y agoI have a really hard time taking the attack research on password KDFs all that seriously. I don't think there are many common threat models where "weaknesses" in password hashes are more than marginal issues. Not using a real password KDF is a big issue. Using the wrong one, not so much.
- FreakLegion 2y agoI don't disagree at all. My comment is about paperwork and selling to the government ("operating in the FIPS world", as the post has it, where NIST enters the conversation). I'm sure you can get away with tacking PBKDF2 onto Argon2 here, but those are hoops you don't need to jump through.