News for hackers. Stuff that matters.
Re:The scrypt parameters by user5994461 on Thursday December 28, 2017 @11:29AM (#16022998)
To illustrate the level of idiocy we reached with slow hash functions. The official NIST recommendation #800-132 is to use 10k iterations for PBKDF2, or 10M iterations for important keys.

10k iterations was half a second when we tried it on our server.

10M iterations took 8 minutes for a single hash.

Re:The scrypt parameters by chowells on Thursday December 28, 2017 @12:04PM (#16023238)
Were you using it to hash data for integrity? Or even worse, were you abusing it as a MAC [1]? That's the only way I can see it being so slow.

PBKDF2 is a password-based key derivation function (it says so, right in the name), not a data integrity verification function. You should only ever be feeding a password and high-entropy salt into it.

It's something of a disservice to call all these things "hash functions". It makes people think they're interchangeable, but that's very far from true.

[1] The reason I say using it as a MAC is even worse than using it for data integrity is that was never intended to work as a MAC. A KDF doesn't care (in theory) if the salt input can be derived by looking at its output. For the intended use case of a KDF, the salt is stored with the output anyway. So a cryptanalysis of a KDF wouldn't see the revelation of information about the key by the output as a theoretical flaw. But that would be a huge flaw in a MAC, where the output is often conveyed by an untrusted party between two parties who keep the key secret. From a practical standpoint, a KDF that did leak details of its key in its output is inefficient (redundant use of storage space), but it isn't sufficient by itself to break the security properties.

Re:The scrypt parameters by user5994461 on Thursday December 28, 2017 @12:44PM (#16023498)
It's hashing a password. It's used exactly the way it's supposed to be.
Re:The scrypt parameters by minitech on Thursday December 28, 2017 @01:16PM (#16023722)
> 10M iterations took 8 minutes for a single hash.

  ~: time node -p 'crypto.pbkdf2Sync("password", "salt", 10e6, 32, "sha256").toString("hex")'
  3c0873fa17659d22450cfcc4a7dd8e51e66db276a0d594cc729baba5af5cedd8
  node -p   6.55s user 0.02s system 99% cpu 6.576 total
10 million iterations in 6.5 seconds on a cheap laptop. Not sure what caused your numbers, but spending a few seconds on a password hash is not “idiocy”.
Re:The scrypt parameters by rocqua on Thursday December 28, 2017 @03:00PM (#16024464)
Maybe it was a javascript implementation?
Re:The scrypt parameters by user5994461 on Thursday December 28, 2017 @07:37PM (#16026468)
It was a java library, not sure if the implementation was in C.
Re:The scrypt parameters by timv on Thursday December 28, 2017 @08:54PM (#16026910)
Either the library you were using was terrible, your servers were powered by hamsters, or you were feeding the wrong parameters into the algorithm.

The code below takes ~15 seconds on 1 year old MacBook running Java 1.8.0_111-b14 and uses no 3rd party libraries:

        PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 10_000_000, 256);
        SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");     
        byte[] hash = skf.generateSecret(spec).getEncoded();
Re:The scrypt parameters by user5994461 on Saturday December 30, 2017 @04:25PM (#16037698)
It was some years ago on first or second gen Xeon. Wouldn't be surprised if your new CPU is twice as fast.

There is a vulnerability in PBKDF2 that halved the amount of operations. New libraries make use of it but it wasn't known at the time.

That 15+ seconds would be 1+ minute back then. Assume the first implementations were poorly optimized and that's multiple minutes.