diff options
author | Jack Lloyd <[email protected]> | 2018-05-15 22:24:59 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-05-16 10:33:52 -0400 |
commit | 556aac9cd7362d959ada085222f1e0e940f94cdd (patch) | |
tree | 17bd7fef0100fab77195d9e3423dc3f5400a2d2c /src/cli | |
parent | 1edd844d4b59867e2dbbf135bc754dc220f375e3 (diff) |
Add Scrypt key dervation function
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/speed.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
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 <botan/newhope.h> #endif +#if defined(BOTAN_HAS_SCRYPT) + #include <botan/scrypt.h> +#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<Timer> 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*/, |