summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/s2k.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-18 17:29:58 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-19 10:32:18 +0100
commit8799d48c5525ebe564070c4c3cd19df1b866e5ca (patch)
tree7c025dafa04f3140294e38127d531575cc12d554 /openpgp/src/crypto/s2k.rs
parent48cc5f28b158f853c1755ccadb958ce20d8a9007 (diff)
openpgp: Prepare to encrypt passwords.
- Remove direct access, provide Password::map instead.
Diffstat (limited to 'openpgp/src/crypto/s2k.rs')
-rw-r--r--openpgp/src/crypto/s2k.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index f0614ab0..fc29a7e1 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -75,11 +75,11 @@ impl Default for S2K {
impl S2K {
/// Convert the string to a key using the S2K's parameters.
- pub fn derive_key(&self, string: &Password, key_size: usize)
+ pub fn derive_key(&self, password: &Password, key_size: usize)
-> Result<SessionKey> {
match self {
&S2K::Simple { hash } | &S2K::Salted { hash, .. }
- | &S2K::Iterated { hash, .. } => {
+ | &S2K::Iterated { hash, .. } => password.map(|string| {
let mut hash = hash.context()?;
// If the digest length is shorter than the key length,
@@ -143,7 +143,7 @@ impl S2K {
}
Ok(ret.into())
- }
+ }),
&S2K::Unknown(u) | &S2K::Private(u) =>
Err(Error::MalformedPacket(
format!("Unknown S2K type {:#x}", u)).into()),