diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-08-20 18:08:10 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-08-20 18:08:10 +0200 |
commit | fa888a60114c60f2babc311f15aff8e14f196025 (patch) | |
tree | cf534d6639b8ccae6677829897c0a7ba5efdad6f /tool/src | |
parent | 96c3ebd47138ea4ee044fea9fc4dc967c76f263f (diff) |
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.
Diffstat (limited to 'tool/src')
-rw-r--r-- | tool/src/commands/dump.rs | 18 |
1 files changed, 14 insertions, 4 deletions
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(()) |