diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2022-04-28 12:57:54 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2022-04-28 13:22:47 +0200 |
commit | 583f781a0fb66b503c492540510eb747c6f47247 (patch) | |
tree | 88a7b8d3267bb4dd6d623fbbd516ce3951e89c0e /openpgp/src/serialize.rs | |
parent | 31a9ae094eeb41e720119f92a8afeb1a6123a01e (diff) |
openpgp: Rework handing of unknown compression algorithms.
- Currently, if we don't understand a compression algorithm, parsing
a compressed data packet fails and it is turned into an Unknown
packet. This is rather unfortunate, and deviates from what we do
for the encryption containers.
- Encryption containers are either not decrypted, in which case they
have a Body::Unprocessed, decrypted with Body::Processed, or
decrypted and parsed Body::Structured.
- Likewise, if we don't understand a compression algorithm, we
should simply return a compressed data packet with an unprocessed
body. This change does exactly that.
- Fixes #830.
Diffstat (limited to 'openpgp/src/serialize.rs')
-rw-r--r-- | openpgp/src/serialize.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs index afbf1646..7588fb4b 100644 --- a/openpgp/src/serialize.rs +++ b/openpgp/src/serialize.rs @@ -3130,6 +3130,12 @@ mod test { // 3. Get the first packet. let po = pile.descendants().next(); if let Some(&Packet::CompressedData(ref cd)) = po { + if ! cd.algo().is_supported() { + eprintln!("Skipping {} because {} is not supported.", + filename, cd.algo()); + continue; + } + // 4. Serialize the container. let buffer = (&Packet::CompressedData(cd.clone()) as &dyn MarshalInto) @@ -3162,21 +3168,6 @@ mod test { assert_eq!(pile, pile2); } } else { - // XXX: We should always parse the packet into a - // compressed data packet, even if we don't understand - // the algorithm. See - // https://gitlab.com/sequoia-pgp/sequoia/-/issues/830. - // In the mean time, as a workaround, we check whether - // we support the algorithm. Drop this once #830 is - // addressed. - if let Some(Packet::Unknown(u)) = po { - // The first octet is the compression algorithm. - let algo: CompressionAlgorithm = u.body()[0].into(); - if ! algo.is_supported() { - continue; - } - } - panic!("Expected a compressed data data packet."); } } |