diff options
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/cert/parser/mod.rs | 22 | ||||
-rw-r--r-- | openpgp/src/packet/header/mod.rs | 20 |
2 files changed, 17 insertions, 25 deletions
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs index e7c0cdea..5538bbf1 100644 --- a/openpgp/src/cert/parser/mod.rs +++ b/openpgp/src/cert/parser/mod.rs @@ -143,22 +143,18 @@ impl KeyringValidator { return; } - match token { - Token::PublicKey(_) | Token::SecretKey(_) => { - self.tokens.clear(); - self.n_keys += 1; - }, - _ => (), + if let Token::PublicKey(_) | Token::SecretKey(_) = token { + self.tokens.clear(); + self.n_keys += 1; } self.n_packets += 1; - if matches!(&token, Token::Signature(None)) - && matches!(self.tokens.last(), Some(Token::Signature(None))) - { - // Compress multiple signatures in a row. This is - // essential for dealing with flooded keys. - } else { - self.tokens.push(token); + match (&token, self.tokens.last()) { + (Token::Signature(None), Some(Token::Signature(None))) => { + // Compress multiple signatures in a row. This is + // essential for dealing with flooded keys + }, + _ => self.tokens.push(token), } } diff --git a/openpgp/src/packet/header/mod.rs b/openpgp/src/packet/header/mod.rs index 43ca9232..95f2986b 100644 --- a/openpgp/src/packet/header/mod.rs +++ b/openpgp/src/packet/header/mod.rs @@ -78,18 +78,14 @@ impl Header { pub fn valid(&self, future_compatible: bool) -> Result<()> { let tag = self.ctb.tag(); - // Reserved packets are never valid. - if tag == Tag::Reserved { - return Err(Error::UnsupportedPacketType(tag).into()); - } - - // Unknown packets are not valid unless we want future - // compatibility. - if ! future_compatible - && (matches!(tag, Tag::Unknown(_)) - || matches!(tag, Tag::Private(_))) - { - return Err(Error::UnsupportedPacketType(tag).into()); + match tag { + // Reserved packets are never valid. + Tag::Reserved => + return Err(Error::UnsupportedPacketType(tag).into()), + // Unknown packets are not valid unless we want future compatibility. + Tag::Unknown(_) | Tag::Private(_) if !future_compatible => + return Err(Error::UnsupportedPacketType(tag).into()), + _ => (), } // An implementation MAY use Partial Body Lengths for data |