summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-02-24 18:15:14 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-02-24 18:48:15 +0100
commit1ed1ba13602470caf483385cdb62e92d92c86894 (patch)
treefcad328f242e67ac6052f9b5112ab581867bac12
parent2fa9369dff04de43989044a8afffeda30348bdf5 (diff)
openpgp: Return a more appropriate error.
-rw-r--r--openpgp/src/parse/stream.rs5
-rw-r--r--openpgp/src/policy.rs2
2 files changed, 3 insertions, 4 deletions
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index 4e8c652e..32f1c2ab 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -1319,10 +1319,9 @@ impl<'a, H: VerificationHelper + DecryptionHelper> Decryptor<'a, H> {
decryption_proxy)?;
}
if ! pp.decrypted() {
- // XXX: That is not quite the right error to return.
return Err(
- Error::InvalidSessionKey("No session key".into())
- .into());
+ Error::MissingSessionKey(
+ "No session key decrypted".into()).into());
}
let sym_algo =
diff --git a/openpgp/src/policy.rs b/openpgp/src/policy.rs
index e0cd0088..016b5aa2 100644
--- a/openpgp/src/policy.rs
+++ b/openpgp/src/policy.rs
@@ -1772,7 +1772,7 @@ mod test {
Helper {}, crate::frozen_time());
match r {
Ok(_) => panic!(),
- Err(e) => assert_match!(Error::InvalidSessionKey(_)
+ Err(e) => assert_match!(Error::MissingSessionKey(_)
= e.downcast().unwrap()),
}