aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-05-30 08:07:47 -0400
committerJack Lloyd <[email protected]>2019-05-30 08:07:47 -0400
commit6e3abeb22abed9f220dac97868a02840c60e52c4 (patch)
treee5db817492425cba00900d678778ba3e7b80ec71 /src/cli
parent72655f4b237edebec557998669af676475fb721b (diff)
Argon2: minor optimizations, add tests of CLI, tweak tuning
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/pbkdf.cpp2
-rw-r--r--src/cli/speed.cpp46
2 files changed, 47 insertions, 1 deletions
diff --git a/src/cli/pbkdf.cpp b/src/cli/pbkdf.cpp
index c2e4112b6..d17c49220 100644
--- a/src/cli/pbkdf.cpp
+++ b/src/cli/pbkdf.cpp
@@ -18,7 +18,7 @@ namespace Botan_CLI {
class PBKDF_Tune final : public Command
{
public:
- PBKDF_Tune() : Command("pbkdf_tune --algo=Scrypt --max-mem=160 --output-len=32 --check *times") {}
+ PBKDF_Tune() : Command("pbkdf_tune --algo=Scrypt --max-mem=256 --output-len=32 --check *times") {}
std::string group() const override
{
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index c93f45ea6..9830c4f29 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -121,6 +121,10 @@
#include <botan/scrypt.h>
#endif
+#if defined(BOTAN_HAS_ARGON2)
+ #include <botan/argon2.h>
+#endif
+
#if defined(BOTAN_HAS_BCRYPT)
#include <botan/bcrypt.h>
#endif
@@ -646,6 +650,12 @@ class Speed final : public Command
bench_scrypt(provider, msec);
}
#endif
+#if defined(BOTAN_HAS_ARGON2)
+ else if(algo == "argon2")
+ {
+ bench_argon2(provider, msec);
+ }
+#endif
#if defined(BOTAN_HAS_BCRYPT)
else if(algo == "bcrypt")
{
@@ -2195,6 +2205,42 @@ class Speed final : public Command
#endif
+#if defined(BOTAN_HAS_ARGON2)
+
+ void bench_argon2(const std::string& /*provider*/,
+ std::chrono::milliseconds msec)
+ {
+ for(size_t M : { 8*1024, 64*1024, 256*1024 })
+ {
+ for(size_t t : { 1, 2, 4 })
+ {
+ for(size_t p : { 1 })
+ {
+ std::unique_ptr<Timer> timer = make_timer(
+ "Argon2id M=" + std::to_string(M) + " t=" + std::to_string(t) + " p=" + std::to_string(p));
+
+ const size_t mode = 2;
+ uint8_t out[64];
+ uint8_t salt[16];
+ rng().randomize(salt, sizeof(salt));
+
+ while(timer->under(msec))
+ {
+ timer->run([&] {
+ Botan::argon2(out, sizeof(out), "password", 8,
+ salt, sizeof(salt), nullptr, 0, nullptr, 0,
+ mode, p, M, t);
+ });
+ }
+
+ record_result(timer);
+ }
+ }
+ }
+ }
+
+#endif
+
#if defined(BOTAN_HAS_NEWHOPE) && defined(BOTAN_HAS_CHACHA_RNG)
void bench_newhope(const std::string& /*provider*/,
std::chrono::milliseconds msec)