diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-06-08 19:50:13 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-06-08 19:52:00 +0200 |
commit | cdb25fd7dfb5957a103eadec3b26b4d98a98fa41 (patch) | |
tree | 29e46903c5414de1cd1c6c247b73c4e625bdec20 | |
parent | 1217f6c2ff9e6e911a404daf62ff02f4a243e840 (diff) |
openpgp: Turn key parse errors into soft errors.
- If an secret key is missing, or unexpected, turn the packet into
an unknown packet instead of failing hard. Also, improve error
messages.
-rw-r--r-- | openpgp/src/parse/parse.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs index d1348658..a14d6420 100644 --- a/openpgp/src/parse/parse.rs +++ b/openpgp/src/parse/parse.rs @@ -1385,17 +1385,17 @@ impl Key4 { }; let have_secret = secret.is_some(); - if have_secret && tag != Tag::Reserved { + if have_secret { if tag == Tag::PublicKey || tag == Tag::PublicSubkey { - return Err(Error::MalformedPacket( - format!("Expected a secret key for {:?} packet", tag)) - .into()); + return php.error(Error::MalformedPacket( + format!("Unexpected secret key found in {:?} packet", tag) + ).into()); } } else { if tag == Tag::SecretKey || tag == Tag::SecretSubkey { - return Err(Error::MalformedPacket( - format!("Expected no secret key for {:?} packet", tag)) - .into()); + return php.error(Error::MalformedPacket( + format!("Expected secret key in {:?} packet", tag) + ).into()); } } |