From 7f65f84743a0c73bff69bbd5a87013bf4fb8f8b1 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 28 Jun 2019 15:56:23 +0200 Subject: openpgp: Rework unencrypted secret key handling. - Instead of giving out references to the stored secret, use a new function Unencrypted::map that maps a given function over the secret. This allows us to encrypt the secret, and decrypt it on demand. --- tool/src/commands/dump.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tool') diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs index 4af64e0b..3cdd7c0a 100644 --- a/tool/src/commands/dump.rs +++ b/tool/src/commands/dump.rs @@ -409,7 +409,9 @@ impl PacketDumper { let ii = format!("{} ", i); match secrets { - SecretKey::Unencrypted(ref u) => match u.mpis() + SecretKey::Unencrypted(ref u) => u.map( + |mpis| -> Result<()> { + match mpis { mpis::SecretKey::RSA { d, p, q, u } => self.dump_mpis(output, &ii, @@ -450,7 +452,7 @@ impl PacketDumper { self.dump_mpis(output, &ii, &[rest], &["rest"])?; }, - }, + } Ok(()) })?, SecretKey::Encrypted(ref e) => { writeln!(output, "{}", i)?; write!(output, "{} S2K: ", ii)?; -- cgit v1.2.3