From 2d9b4aaa8bc80dd2bbefabebd52826caac532f82 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sat, 29 Dec 2018 09:17:48 -0500 Subject: Improve PBKDF self-tuning Make the tune interval a build-time configurable instead of hardcoding it in each source file. Also use binary search in RFC4880_encode_count instead of linear search. Fix a bug in Timer --- src/lib/pbkdf/scrypt/scrypt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/pbkdf/scrypt') diff --git a/src/lib/pbkdf/scrypt/scrypt.cpp b/src/lib/pbkdf/scrypt/scrypt.cpp index c20225734..e50073669 100644 --- a/src/lib/pbkdf/scrypt/scrypt.cpp +++ b/src/lib/pbkdf/scrypt/scrypt.cpp @@ -50,10 +50,10 @@ std::unique_ptr Scrypt_Family::tune(size_t output_length, size_t r = 1; size_t p = 1; - Timer timer("Scrypt", 0); - const std::chrono::milliseconds tune_msec(30); + Timer timer("Scrypt"); + const auto tune_time = BOTAN_PBKDF_TUNING_TIME; - timer.run_until_elapsed(tune_msec, [&]() { + timer.run_until_elapsed(tune_time, [&]() { uint8_t output[32] = { 0 }; scrypt(output, sizeof(output), "test", 4, nullptr, 0, N, r, p); }); -- cgit v1.2.3