summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/s2k.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-05-20 18:16:49 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-05-20 18:22:43 +0200
commit8135721fab4564b7e2391ee898213cf5a91bf1fa (patch)
tree56c17d9b9cd10db2e8cae8796b7a8b1972f4f8b5 /openpgp/src/crypto/s2k.rs
parenta9b31b93ebcff0f40f7baea0aa3ab283f243b440 (diff)
openpgp: Calibrate S2K's hash bytes count.
- Fix the value to the largest one OpenPGP can represent. On moderate machines, like my Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz, it takes ~354ms to derive a key. - Fixes #192.
Diffstat (limited to 'openpgp/src/crypto/s2k.rs')
-rw-r--r--openpgp/src/crypto/s2k.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index 1e19d3a1..4fc87096 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -54,7 +54,6 @@ pub enum S2K {
Unknown(u8),
}
-// XXX: Check defaults.
impl Default for S2K {
fn default() -> Self {
let mut salt = [0u8; 8];
@@ -67,7 +66,10 @@ impl Default for S2K {
// for every cipher algorithm currently in use.
hash: HashAlgorithm::SHA256,
salt: salt,
- hash_bytes: 26214400, // XXX: Calibrate somehow.
+ // This is the largest count that OpenPGP can represent.
+ // On moderate machines, like my Intel(R) Core(TM) i5-2400
+ // CPU @ 3.10GHz, it takes ~354ms to derive a key.
+ hash_bytes: 65_011_712,
}
}
}