aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2021-04-19 19:45:58 -0400
committerJack Lloyd <[email protected]>2021-04-19 20:05:15 -0400
commitd1db6c39559c51888a8e2553cea33015cb7f88be (patch)
tree6dfe71a47167fc7769068089fd8dfca2cb392f22 /src/cli
parent1c5043bdfaf94919626eb38019571bb6f26a91fd (diff)
Run scrypt and bcrypt-pbkdf through PasswordHash
The old top level fns like scrypt are now deprecated, and we can now mark the algorithm headers as future-internal.
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/pbkdf.cpp4
-rw-r--r--src/cli/speed.cpp22
2 files changed, 16 insertions, 10 deletions
diff --git a/src/cli/pbkdf.cpp b/src/cli/pbkdf.cpp
index d17c49220..079e121e7 100644
--- a/src/cli/pbkdf.cpp
+++ b/src/cli/pbkdf.cpp
@@ -6,14 +6,14 @@
#include "cli.h"
-#if defined(BOTAN_HAS_PBKDF)
+#if defined(BOTAN_HAS_PASSWORD_HASHING)
#include <botan/pwdhash.h>
#include <botan/internal/os_utils.h>
#endif
namespace Botan_CLI {
-#if defined(BOTAN_HAS_PBKDF)
+#if defined(BOTAN_HAS_PASSWORD_HASHING)
class PBKDF_Tune final : public Command
{
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 500c5aea5..cc9cfb09a 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -119,10 +119,6 @@
#include <botan/newhope.h>
#endif
-#if defined(BOTAN_HAS_SCRYPT)
- #include <botan/scrypt.h>
-#endif
-
#if defined(BOTAN_HAS_BCRYPT)
#include <botan/bcrypt.h>
#endif
@@ -131,6 +127,10 @@
#include <botan/passhash9.h>
#endif
+#if defined(BOTAN_HAS_PASSWORD_HASHING)
+ #include <botan/pwdhash.h>
+#endif
+
namespace Botan_CLI {
using Botan::Timer;
@@ -2213,17 +2213,20 @@ class Speed final : public Command
void bench_scrypt(const std::string& /*provider*/,
std::chrono::milliseconds msec)
{
+ auto pwdhash_fam = Botan::PasswordHashFamily::create_or_throw("Scrypt");
for(size_t N : { 8192, 16384, 32768, 65536 })
{
for(size_t r : { 1, 8, 16 })
{
- for(size_t p : { 1, 4 })
+ for(size_t p : { 1 })
{
+ auto pwdhash = pwdhash_fam->from_params(N, r, p);
+
auto scrypt_timer = make_timer(
"scrypt-" + std::to_string(N) + "-" +
std::to_string(r) + "-" + std::to_string(p) +
- " (" + std::to_string(Botan::scrypt_memory_usage(N, r, p) / (1024*1024)) + " MiB)");
+ " (" + std::to_string(pwdhash->total_memory_usage() / (1024*1024)) + " MiB)");
uint8_t out[64];
uint8_t salt[8];
@@ -2232,8 +2235,11 @@ class Speed final : public Command
while(scrypt_timer->under(msec))
{
scrypt_timer->run([&] {
- Botan::scrypt(out, sizeof(out), "password",
- salt, sizeof(salt), N, r, p);
+ pwdhash->derive_key(out, sizeof(out),
+ "password", 8,
+ salt, sizeof(salt));
+
+ Botan::copy_mem(salt, out, 8);
});
}