diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-05-07 16:30:17 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-05-07 17:00:52 +0200 |
commit | cf565c026d3a563053f28078eb6c88d4c58e0ba0 (patch) | |
tree | 1af6653ab8a3965199496f7eb5de95e171004dff /tool/src | |
parent | 3eb554d0980ae788df2a07df609b77e01b7e57ce (diff) |
openpgp: Configure mapping in the builder, remove from Helper trait.
- See #498.
Diffstat (limited to 'tool/src')
-rw-r--r-- | tool/src/commands/decrypt.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/tool/src/commands/decrypt.rs b/tool/src/commands/decrypt.rs index 1b228a7f..9e951af4 100644 --- a/tool/src/commands/decrypt.rs +++ b/tool/src/commands/decrypt.rs @@ -33,14 +33,13 @@ struct Helper<'a> { key_hints: HashMap<KeyID, String>, dump_session_key: bool, dumper: Option<PacketDumper>, - hex: bool, } impl<'a> Helper<'a> { fn new(ctx: &'a Context, policy: &'a dyn Policy, mapping: &'a mut store::Mapping, signatures: usize, certs: Vec<Cert>, secrets: Vec<Cert>, - dump_session_key: bool, dump: bool, hex: bool) + dump_session_key: bool, dump: bool) -> Self { let mut keys = HashMap::new(); @@ -74,14 +73,13 @@ impl<'a> Helper<'a> { key_identities: identities, key_hints: hints, dump_session_key: dump_session_key, - dumper: if dump || hex { + dumper: if dump { let width = terminal::size().ok().map(|(cols, _)| cols as usize) .unwrap_or(80); Some(PacketDumper::new(width, false)) } else { None }, - hex: hex, } } @@ -116,10 +114,6 @@ impl<'a> Helper<'a> { } impl<'a> VerificationHelper for Helper<'a> { - fn mapping(&self) -> bool { - self.hex - } - fn inspect(&mut self, pp: &PacketParser) -> Result<()> { if let Some(dumper) = self.dumper.as_mut() { dumper.packet(&mut io::stderr(), @@ -287,8 +281,9 @@ pub fn decrypt(ctx: &Context, policy: &dyn Policy, mapping: &mut store::Mapping, dump: bool, hex: bool) -> Result<()> { let helper = Helper::new(ctx, policy, mapping, signatures, certs, secrets, - dump_session_key, dump, hex); + dump_session_key, dump || hex); let mut decryptor = DecryptorBuilder::from_reader(input)? + .mapping(hex) .with_policy(policy, None, helper) .context("Decryption failed")?; @@ -309,7 +304,7 @@ pub fn decrypt_unwrap(ctx: &Context, policy: &dyn Policy, -> Result<()> { let mut helper = Helper::new(ctx, policy, mapping, 0, Vec::new(), secrets, - dump_session_key, false, false); + dump_session_key, false); let mut ppr = PacketParser::from_reader(input)?; |