by adrian_b · 3y ago · 0 comments
PBKDF2 and similar key derivation algorithms are acceptable only when the key derivation must be run on some kind of microcontroller with limited resources, so the security requirements must be modest and it is understood that any really powerful adversary will be able to break the encryption, e.g. by using a large number of FPGAs or GPUs.
Otherwise, a modern key derivation algorithm should be used, for instance Argon2, which also needs a very large amount of memory, in order to prevent fast parallel implementations of the key derivation function.
(There is some "sweet spot" of hard-ish passwords of say 80 bits of entropy, where PBKDF2 or Argon2 would push it over into cryptographically-secure territory. But such a password is already extremely hard to remember, which means you are probably writing it down or storing it in a password manager already. So you may as well just make it longer).
> A lot of the discourse around password hashing gives the impression that there is some magic number you can pick that actually makes passwords safe to use for this kind of thing. There isn’t. They are not. Either your password has sufficient entropy to resist brute-forcing, in which case it is already probably a cryptographic key, or it doesn’t – in which case it will eventually be cracked no matter how many iterations you apply to it.
...but I'm not seeing anything to back that up. Using the article's own example of a 72-bit password entropy that would imply that an attacker is willing to spend up to 4722366482869645213696 times as much brute forcing the password as you are to unlock it normally.
That seems like a fairly remarkable claim to make with little to back it up.
For a sense of scale, even if you're password stretching to just 0.01s, that's 1,496,458,366,089.87 years. You can parallelize that, but let's say you used just 64MB in argon2, and memory costs just 1$/GB - if you're willing to spend 30 billion on ram and get energy and everything else for free, then you can reduce that time to just 50 years; a human working life. And of course, those settings are very light; a spending 10 times time+memory more would barely affect the user, yet cost the attacker 100 times more to hit that 50 year deadline.
Put another way, if the attacker spent the entire US annual GDP buying brute force crackers at 1GB/$ and then a year cracking, that could merely reliably brute-force a 1GB Argon2 stretched password up to 156ms.
I'm sure better hardware would help a bit here, and using PBKDF2 rather than Argon2 surely is weaker (I'd be curious how much, though) but this really isn't a a trivial problem, and the claim from the article looks at the very least unsupported.
The point of PBKDF2 and Argon2 is to add some extra protection for the relatively weak passwords that users typically pick, which are closer to 40 bits or less of entropy. For online authentication these KDFs are fine. But for long-term (decades) protection of encryption keys, it’s nowhere near enough.
Using your own example, a 40-bit password stretched to 0.01s would take about 348 years if purely sequential. But this is highly parallelisable, so crackable in less than a year in reality (much less on GPUs).
Now, maybe you are willing to bet that the costs of such an attack (memory and CPU/GPU time) will not change too much over your lifetime, and so are willing to accept this. But, as I say at the end of the article, this means you are adopting a non-standard model of security as far as cryptography is concerned and should be clear about that. (Cryptography defines security in terms of Turing machines with unlimited memory).
I tend to have a significantly easier time recalling a six-word passphrase than ten. So by your logic, key stretching makes sense in my case, am I following you correctly? Or is my math off?
(I quite enjoyed your article, thanks!)
Very good passwords (e.g. generated randomly by typical modern password managers) are unaffected, you can't guess or brute force them, so Argon2 isn't making a difference.
Very bad passwords (e.g. your username, 12345678, password) are also unaffected, despite Argon2 the bad guys can just guess the password.
What's really "obsolete" is the password itself. Memorable† Shared secret authentication has been a bad idea for decades. At the point where people were really excited about Rainbow tables because Microsoft are incompetent, we should have been gently insisting people stop using passwords, but we got sucked into telling them about better password hashing instead and now here I am talking about Argon2 again, not to a weird niche audience who genuinely have to use shared secrets, but to people who thought that looked simpler. Ugh.
† As originally posted I didn't write Memorable here. Shared secrets aren't great anyway, but there are a lot of practical applications if we don't need to memorise them. The faster re-connection to a modern web server when you visit HN again later today relies on a shared secret to make it work but it's not a memorable secret, it's just arbitrary data stored in a computer. Passwords are intended to be "memorable" so that a human can remember what they are.
The obvious problem is that we treat "something you have" items like Yubikeys, phones (webauthn), TOTP tokens, and fingers (biometrics) as second factors instead of as the primary factor.
We are deploying a lot of small VMs with container-like workloads. This enhances security for those workloads by using CPU virt capabilities to isolate them. (It's also required for Confidential Containers because of how the hardware works.) But at the same time because these are container-like, we only give them a few dozen or hundred MB of RAM. No one wants to be giving containers gigabytes of RAM each. This prevents accessing LUKSv2 filesystems using Argon2 from these containers.
So several useful security mitigations conflict in unfortunate ways.
bscrypt looks like a better alternative nowadays: https://github.com/Sc00bz/bscrypt