diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-05-31 12:48:17 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-05-31 12:48:17 +0200 |
commit | fd7d02ca8d49573940475625bf22e5ea63858ac6 (patch) | |
tree | cd8d6f12e60218963a9ed6297d09ec401427a962 /tool | |
parent | 88bd7656707d19d732ca388960fe100201646829 (diff) |
tool: Improve decryption command.
- When hex-dumping, add a newline before the hex dump.
- Process PKESK and SKESK packets after the call to 'recurse()'
avoiding the clone.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/src/commands.rs | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/tool/src/commands.rs b/tool/src/commands.rs index 1dcbd877..f7a42318 100644 --- a/tool/src/commands.rs +++ b/tool/src/commands.rs @@ -30,6 +30,7 @@ pub fn decrypt(input: &mut io::Read, output: &mut io::Write, } if let Some(ref map) = pp.map { + eprintln!(); let mut hd = HexDumper::new(); for (field, bytes) in map.iter() { hd.print(bytes, field); @@ -41,20 +42,6 @@ pub fn decrypt(input: &mut io::Read, output: &mut io::Write, // Look for an PKESK or SKESK packet. State::Start(pkesks, mut skesks) => match pp.packet { - Packet::Unknown(ref u) => { - match u.tag { - Tag::PKESK => - eprintln!("Decryption using PKESK not yet \ - supported."), - _ => (), - } - State::Start(pkesks, skesks) - }, - Packet::SKESK(ref skesk) => { - // xxx do after recurse and avoid clone - skesks.push(skesk.clone()); - State::Start(pkesks, skesks) - }, Packet::SEIP(_) => { let mut state = None; for _pkesk in pkesks.iter() { @@ -95,8 +82,32 @@ pub fn decrypt(input: &mut io::Read, output: &mut io::Write, State::Done => State::Done, }; - let (_, _, ppo_tmp, _) = pp.recurse()?; + let (packet, _, ppo_tmp, _) = pp.recurse()?; ppo = ppo_tmp; + + state = match state { + // Look for an PKESK or SKESK packet. + State::Start(pkesks, mut skesks) => + match packet { + Packet::Unknown(u) => { + match u.tag { + Tag::PKESK => + eprintln!("Decryption using PKESK not yet \ + supported."), + _ => (), + } + State::Start(pkesks, skesks) + }, + Packet::SKESK(skesk) => { + skesks.push(skesk); + State::Start(pkesks, skesks) + }, + _ => State::Start(pkesks, skesks), + }, + + // Do nothing in all other states. + s => s, + }; } if state != State::Done { |