aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/pbes2
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-09-06 15:02:52 -0400
committerJack Lloyd <[email protected]>2018-09-10 13:27:45 -0400
commit9e88329b1d5c64e399c1677ccc6c158e45f19511 (patch)
treee69afd7882e49959ac8059695c09d54c5a965232 /src/lib/pubkey/pbes2
parent7a5ef7c8277ef5d85e3f99b7165e42108c179c24 (diff)
Add from_iterations
Diffstat (limited to 'src/lib/pubkey/pbes2')
-rw-r--r--src/lib/pubkey/pbes2/pbes2.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/pubkey/pbes2/pbes2.cpp b/src/lib/pubkey/pbes2/pbes2.cpp
index e9c2a9df1..995f93c47 100644
--- a/src/lib/pubkey/pbes2/pbes2.cpp
+++ b/src/lib/pubkey/pbes2/pbes2.cpp
@@ -99,9 +99,6 @@ secure_vector<uint8_t> derive_key(const std::string& passphrase,
size_t key_length,
AlgorithmIdentifier& kdf_algo)
{
- // TODO should be configurable
- const size_t MAX_PBKDF_MEMORY = 32;
-
const secure_vector<uint8_t> salt = rng.random_vec(12);
if(digest == "Scrypt")
@@ -115,7 +112,7 @@ secure_vector<uint8_t> derive_key(const std::string& passphrase,
if(msec_in_iterations_out)
{
const std::chrono::milliseconds msec(*msec_in_iterations_out);
- pwhash = pwhash_fam->tune(key_length, msec, MAX_PBKDF_MEMORY);
+ pwhash = pwhash_fam->tune(key_length, msec);
}
else if(iterations_if_msec_null <= 100000)
{
@@ -123,9 +120,7 @@ secure_vector<uint8_t> derive_key(const std::string& passphrase,
}
else
{
- //const std::chrono::milliseconds msec(iterations_if_msec_null / 100000);
- //pwhash = pwhash_fam->tune(key_length, msec, MAX_PBKDF_MEMORY);
- pwhash = pwhash_fam->default_params();
+ pwhash = pwhash_fam->from_iterations(iterations_if_msec_null);
}
secure_vector<uint8_t> key(key_length);
@@ -170,11 +165,11 @@ secure_vector<uint8_t> derive_key(const std::string& passphrase,
if(msec_in_iterations_out)
{
const std::chrono::milliseconds msec(*msec_in_iterations_out);
- pwhash = pwhash_fam->tune(key_length, msec, MAX_PBKDF_MEMORY);
+ pwhash = pwhash_fam->tune(key_length, msec);
}
else
{
- pwhash = pwhash_fam->from_params(iterations_if_msec_null);
+ pwhash = pwhash_fam->from_iterations(iterations_if_msec_null);
}
secure_vector<uint8_t> key(key_length);