summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-11-15 14:46:58 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-11-15 14:57:54 +0100
commit00b731c0be993065491d23c956ae96e1a269f0fc (patch)
treea085108d0068ec2347b015f061763d11b646479c /openpgp
parent9ddabb9b4311a1dcee01df0aaf4b16387312f1e8 (diff)
openpgp: Ignore marker packets in TPKs.
- Fixes #372.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/tpk/parser/mod.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/openpgp/src/tpk/parser/mod.rs b/openpgp/src/tpk/parser/mod.rs
index b2804cb4..d3d6260c 100644
--- a/openpgp/src/tpk/parser/mod.rs
+++ b/openpgp/src/tpk/parser/mod.rs
@@ -557,6 +557,13 @@ impl<'a, I: Iterator<Item=Packet>> TPKParser<'a, I> {
// If we complete parsing a TPK, returns the TPK. Otherwise,
// returns None.
fn parse(&mut self, p: Packet) -> Result<Option<TPK>> {
+ if let Packet::Marker(_) = p {
+ // Ignore Marker Packet. RFC4880, section 5.8:
+ //
+ // Such a packet MUST be ignored when received.
+ return Ok(None);
+ }
+
if self.packets.len() > 0 {
match p.tag() {
Tag::PublicKey | Tag::SecretKey => {
@@ -909,4 +916,16 @@ mod test {
}
}
}
+
+ #[test]
+ fn marker_packet_ignored() {
+ use crate::serialize::Serialize;
+ let mut testy_with_marker = Vec::new();
+ Packet::Marker(Default::default())
+ .serialize(&mut testy_with_marker).unwrap();
+ testy_with_marker.extend_from_slice(crate::tests::key("testy.pgp"));
+ TPKParser::from_packet_parser(
+ PacketParser::from_bytes(&testy_with_marker).unwrap())
+ .nth(0).unwrap().unwrap();
+ }
}