diff options
author | Neal H. Walfield <neal@pep.foundation> | 2018-12-17 22:24:09 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2018-12-17 22:24:09 +0100 |
commit | c3ea88b3d4f1a3708248fcbdd879fafe060679d3 (patch) | |
tree | 63ade2d81053161ba2e188a161156c78d4c3f915 /openpgp | |
parent | 61980c77f2f34f6cbc829d25928e807c6bd1b6b9 (diff) |
openpgp: Improve error message.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/tpk/mod.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/openpgp/src/tpk/mod.rs b/openpgp/src/tpk/mod.rs index e20c6a46..96fb9c07 100644 --- a/openpgp/src/tpk/mod.rs +++ b/openpgp/src/tpk/mod.rs @@ -1394,14 +1394,17 @@ impl TPK { assert_eq!(sig.sigtype(), SignatureType::DirectKey); } - if let Some(SecretKey::Unencrypted{ mpis: ref sec }) - = pair.secret() - { - // Generate the signature. - sig.sign_hash(&pair, sec, hash_algo, hash)? - } else { - return Err(Error::InvalidOperation( - "Secret key is encrypted".into()).into()); + match pair.secret() { + Some(SecretKey::Unencrypted{ mpis: ref sec }) => { + // Generate the signature. + sig.sign_hash(&pair, sec, hash_algo, hash)? + } + Some(_) => + return Err(Error::InvalidOperation( + "Secret key is encrypted".into()) .into()), + None => + return Err(Error::InvalidOperation( + "No secret key".into()).into()), } }; |