diff options
-rw-r--r-- | openpgp/src/crypto/asymmetric.rs | 17 | ||||
-rw-r--r-- | openpgp/src/crypto/mod.rs | 3 | ||||
-rw-r--r-- | openpgp/src/packet/signature/mod.rs | 15 |
3 files changed, 24 insertions, 11 deletions
diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs new file mode 100644 index 00000000..9a497f9a --- /dev/null +++ b/openpgp/src/crypto/asymmetric.rs @@ -0,0 +1,17 @@ +//! Asymmetric crypto operations. + +use packet::Key; +use crypto::mpis; +use constants::HashAlgorithm; + +use Result; + +/// Creates a signature. +pub trait Signer { + /// Returns a reference to the public key. + fn public(&self) -> &Key; + + /// Creates a signature over the `digest` produced by `hash_algo`. + fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) + -> Result<mpis::Signature>; +} diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index d3deb2e1..300a5aeb 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -13,12 +13,15 @@ use constants::HashAlgorithm; use Result; pub(crate) mod aead; +mod asymmetric; pub(crate) mod ecdh; mod hash; pub mod mpis; pub mod s2k; pub(crate) mod symmetric; +pub use self::asymmetric::Signer; + /// Holds a session key. /// /// The session key is cleared when dropped. diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index 02d3d441..22240259 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -6,7 +6,10 @@ use std::ops::Deref; use constants::Curve; use Error; use Result; -use crypto::mpis::{self, MPI}; +use crypto::{ + mpis::{self, MPI}, + Signer, +}; use HashAlgorithm; use PublicKeyAlgorithm; use SignatureType; @@ -211,16 +214,6 @@ impl Builder { } } -/// Creates a signature. -pub trait Signer { - /// Returns a reference to the public key. - fn public(&self) -> &Key; - - /// Creates a signature over the `digest` produced by `hash_algo`. - fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) - -> Result<mpis::Signature>; -} - /// A cryptographic key pair. pub struct KeyPair { public: Key, |