From fa888a60114c60f2babc311f15aff8e14f196025 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 20 Aug 2020 18:08:10 +0200 Subject: openpgp: Add optional parameters to unknown S2K variants. - This mirrors how we handle other unknown variants. However, since we do not know the length of the parameters for unknown S2K variants, we cannot parse them back. To work around that, the parameter field is optional, and will be `None` when an unknown S2K is parsed. The data is not lost, but stored in the packet containing the S2K object, so that we can serialize it again. - Carefully preserve the invariant that we can parse any packet we can serialize by comparing the serialized form of the packet fragments containing the S2K and any fields the parameters of unknown variants bleed into on parsing. - Unfortunately, this means that S2K on its own no longer roundtrips. Remove that test accordingly. --- tool/src/commands/dump.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'tool/src') diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs index 12752a44..3ecd864f 100644 --- a/tool/src/commands/dump.rs +++ b/tool/src/commands/dump.rs @@ -886,10 +886,20 @@ impl PacketDumper { writeln!(output, "{} Salt: {}", i, hex::encode(salt))?; writeln!(output, "{} Hash bytes: {}", i, hash_bytes)?; }, - Private(n) => - writeln!(output, "Private({})", n)?, - Unknown(n) => - writeln!(output, "Unknown({})", n)?, + Private { tag, parameters } => { + writeln!(output, "Private")?; + writeln!(output, "{} Tag: {}", i, tag)?; + if let Some(p) = parameters.as_ref() { + writeln!(output, "{} Parameters: {:?}", i, p)?; + } + }, + Unknown { tag, parameters } => { + writeln!(output, "Unknown")?; + writeln!(output, "{} Tag: {}", i, tag)?; + if let Some(p) = parameters.as_ref() { + writeln!(output, "{} Parameters: {:?}", i, p)?; + } + }, __Nonexhaustive => unreachable!(), } Ok(()) -- cgit v1.2.3