summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/parse.rs')
-rw-r--r--openpgp/src/parse.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index e3b4f32f..c208435b 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -2944,6 +2944,18 @@ impl AED1 {
}
}
+impl Padding {
+ /// Parses the body of a padding packet.
+ fn parse(mut php: PacketHeaderParser) -> Result<PacketParser> {
+ make_php_try!(php);
+ // XXX: I don't think we should capture the body.
+ let value = php_try!(php.parse_bytes_eof("value"));
+ php.ok(Packet::Padding(Padding::from(value)))
+ }
+}
+
+impl_parse_with_buffered_reader!(Padding);
+
impl MPI {
/// Parses an OpenPGP MPI.
///
@@ -4276,6 +4288,16 @@ impl <'a> PacketParser<'a> {
Err(Error::MalformedPacket("Looks like garbage".into()).into()),
Tag::Marker => Marker::plausible(bio, header),
+ Tag::Padding => {
+ // Even though a padding packet may occur here, it has
+ // so little structure, that we're likely better off
+ // trying to find the next packet.
+ //
+ // XXX: We could optimize that though, by using the
+ // potential padding packet's length to see if the
+ // next packet is plausible.
+ bad
+ },
Tag::Signature => Signature::plausible(bio, header),
Tag::SecretKey => Key::plausible(bio, header),
@@ -4536,6 +4558,7 @@ impl <'a> PacketParser<'a> {
Tag::MDC => MDC::parse(parser),
Tag::PKESK => PKESK::parse(parser),
Tag::AED => AED::parse(parser),
+ Tag::Padding => Padding::parse(parser),
_ => Unknown::parse(parser,
Error::UnsupportedPacketType(tag).into()),
}?;
@@ -4820,7 +4843,8 @@ impl <'a> PacketParser<'a> {
| Packet::UserID(_) | Packet::UserAttribute(_)
| Packet::Literal(_) | Packet::PKESK(_) | Packet::SKESK(_)
| Packet::SEIP(_) | Packet::MDC(_) | Packet::AED(_)
- | Packet::CompressedData(_) => {
+ | Packet::CompressedData(_)
+ | Packet::Padding(_) => {
// Drop through.
t!("A {:?} packet is not a container, not recursing.",
self.packet.tag());