From 6805abd97738ada3577e23cbfbd5ff22d1d167b7 Mon Sep 17 00:00:00 2001 From: Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> Date: Fri, 4 Jun 2021 07:56:10 -0700 Subject: [PATCH] Fix Sodium::Password::Key::Create starting memlimit --- src/sodium/password/create_key.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sodium/password/create_key.cr b/src/sodium/password/create_key.cr index b25c832..e4b4a26 100644 --- a/src/sodium/password/create_key.cr +++ b/src/sodium/password/create_key.cr @@ -79,13 +79,13 @@ class Sodium::Password::Key::Create protected def create_key!(pw, pass : Bytes, key_size : Int32) : SecureBuffer pw.ops = OPSLIMIT_MIN - mem = MEMLIMIT_MIN + pw.mem = MEMLIMIT_MIN key = SecureBuffer.new key_size nsamples = 10 samples = nsamples.times.map do - ts = time_derive_key key, pw, pass + time_derive_key key, pw, pass end.to_a mean = samples.sum / nsamples return key.readonly if mean.to_f >= @tcost