diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-16 17:45:27 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-16 18:01:45 +0100 |
commit | 67e79fe28c6827c2bfb68d75d331b9fd3a574843 (patch) | |
tree | 1e97aff169b182870fdaaa71cdbe42dfb9beffc0 /openpgp/src/crypto/asymmetric.rs | |
parent | 9a30451890b61aa8121fde7570a7e1d1ebaa3778 (diff) |
openpgp: Return Result<()> from Signature::verify*.
Diffstat (limited to 'openpgp/src/crypto/asymmetric.rs')
-rw-r--r-- | openpgp/src/crypto/asymmetric.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs index 76729ddb..32787db6 100644 --- a/openpgp/src/crypto/asymmetric.rs +++ b/openpgp/src/crypto/asymmetric.rs @@ -306,13 +306,13 @@ impl<P: key::KeyParts, R: key::KeyRole> Key<P, R> { } /// Verifies the given signature. - pub fn verify(&self, sig: &packet::Signature, digest: &[u8]) -> Result<bool> + pub fn verify(&self, sig: &packet::Signature, digest: &[u8]) -> Result<()> { use crate::PublicKeyAlgorithm::*; use crate::crypto::mpis::{PublicKey, Signature}; #[allow(deprecated)] - match (sig.pk_algo(), self.mpis(), sig.mpis()) { + let ok = match (sig.pk_algo(), self.mpis(), sig.mpis()) { (RSASign, PublicKey::RSA { e, n }, Signature::RSA { s }) | (RSAEncryptSign, PublicKey::RSA { e, n }, Signature::RSA { s }) => { let key = rsa::PublicKey::new(n.value(), e.value())?; @@ -394,6 +394,12 @@ impl<P: key::KeyParts, R: key::KeyRole> Key<P, R> { "unsupported combination of algorithm {}, key {} and \ signature {:?}.", sig.pk_algo(), self.pk_algo(), sig.mpis())).into()), + }?; + + if ok { + Ok(()) + } else { + Err(Error::ManipulatedMessage.into()) } } } |