From 67d55d08f89c2745fe811fd2dce2296adc82def8 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 23 Jun 2016 09:47:22 +0200 Subject: [PATCH] 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. --- lib/crypto_backend/pbkdf_check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/crypto_backend/pbkdf_check.c b/lib/crypto_backend/pbkdf_check.c index f85bbfbe..823ef5fb 100644 --- a/lib/crypto_backend/pbkdf_check.c +++ b/lib/crypto_backend/pbkdf_check.c @@ -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;