Fix PBKDF2 benchmark to not double iteration count for corner case.

If measurement function returns exactly 500 ms, the iteration
calculation loop doubles iteration count but instead of repeating
measurement it uses this value directly.

Thanks to Ondrej Mosnacek for bug report.
This commit is contained in:
Milan Broz
2016-06-23 09:47:22 +02:00
parent 4d3a501b83
commit 67d55d08f8

View File

@@ -71,7 +71,7 @@ int crypt_pbkdf_check(const char *kdf, const char *hash,
return -ENOMEM;
iterations = 1 << 15;
while (ms < 500) {
while (1) {
if (getrusage(RUSAGE_SELF, &rstart) < 0) {
r = -EINVAL;
goto out;