diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-11-19 15:50:23 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-11-19 15:50:23 +0100 |
commit | 1ddc1dd61b45b41801c1d1c364cd6789314cb8f3 (patch) | |
tree | b34baf591fce5f778cd2f132ead705d39abbff47 /openpgp/src/crypto/asymmetric.rs | |
parent | cf9b92f5f9238b8322d09833b92c886dda219924 (diff) |
openpgp: Use the builder pattern for stream::Signer.
- See #375.
Diffstat (limited to 'openpgp/src/crypto/asymmetric.rs')
-rw-r--r-- | openpgp/src/crypto/asymmetric.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs index 9232bd14..144bcc4c 100644 --- a/openpgp/src/crypto/asymmetric.rs +++ b/openpgp/src/crypto/asymmetric.rs @@ -27,6 +27,17 @@ pub trait Signer<R> -> Result<mpis::Signature>; } +impl<R: key::KeyRole> Signer<R> for Box<dyn Signer<R>> { + fn public(&self) -> &Key<key::PublicParts, R> { + self.as_ref().public() + } + + fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) + -> Result<mpis::Signature> { + self.as_mut().sign(hash_algo, digest) + } +} + /// Decrypts a message. /// /// This is a low-level mechanism to decrypt an arbitrary OpenPGP |