diff options
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()), } }; |