From 556aac9cd7362d959ada085222f1e0e940f94cdd Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Tue, 15 May 2018 22:24:59 -0400 Subject: Add Scrypt key dervation function --- src/cli/speed.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/cli') diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index ecd810ba2..80ac35272 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -110,6 +110,10 @@ #include #endif +#if defined(BOTAN_HAS_SCRYPT) + #include +#endif + namespace Botan_CLI { namespace { @@ -892,6 +896,12 @@ class Speed final : public Command bench_newhope(provider, msec); } #endif +#if defined(BOTAN_HAS_SCRYPT) + else if(algo == "scrypt") + { + bench_scrypt(provider, msec); + } +#endif #if defined(BOTAN_HAS_DL_GROUP) else if(algo == "modexp") @@ -2135,6 +2145,28 @@ class Speed final : public Command } #endif +#if defined(BOTAN_HAS_SCRYPT) + + void bench_scrypt(const std::string& /*provider*/, + std::chrono::milliseconds msec) + { + std::unique_ptr scrypt_timer = make_timer("scrypt"); + + uint8_t out[64]; + uint8_t salt[8] = { 0 }; + + while(scrypt_timer->under(msec)) + { + scrypt_timer->run([&] { + Botan::scrypt(out, sizeof(out), "password", + salt, sizeof(salt), 16384, 8, 1); + }); + } + + record_result(scrypt_timer); + } + +#endif #if defined(BOTAN_HAS_NEWHOPE) && defined(BOTAN_HAS_CHACHA_RNG) void bench_newhope(const std::string& /*provider*/, -- cgit v1.2.3