diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-06-28 15:56:23 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-07-16 12:19:46 +0200 |
commit | 7f65f84743a0c73bff69bbd5a87013bf4fb8f8b1 (patch) | |
tree | dd44206b698eb6b3c189e817503cbcb9d4468141 /tool | |
parent | 05415fde3811e78483a8ee41c9399ba78528b64b (diff) |
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.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/src/commands/dump.rs | 6 |
1 files changed, 4 insertions, 2 deletions
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)?; |