From 90c7e249c6667e48db42b3d6014176a2bfb82153 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 20 May 2019 13:55:12 +0200 Subject: openpgp: Fix special case. --- openpgp/src/crypto/s2k.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'openpgp/src/crypto/s2k.rs') diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs index 1b962bd9..527b2a50 100644 --- a/openpgp/src/crypto/s2k.rs +++ b/openpgp/src/crypto/s2k.rs @@ -100,9 +100,15 @@ impl S2K { hash.update(salt); hash.update(string); } - &S2K::Iterated { ref salt, hash_bytes, .. } => { + &S2K::Iterated { ref salt, hash_bytes, .. } + if (hash_bytes as usize) < salt.len() + string.len() => + { // Independent of what the hash count is, we // always hash the whole salt and password once. + hash.update(&salt[..]); + hash.update(&string); + }, + &S2K::Iterated { ref salt, hash_bytes, .. } => { let octs_per_iter = salt.len() + string.len(); let mut data = vec![0u8; octs_per_iter]; let full = hash_bytes as usize / octs_per_iter; -- cgit v1.2.3