Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename to Signer/Verifier; add 'digest' module #11

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions signature-crate/src/digest/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//! Support for using hash functions that impl the `Digest` trait in order
//! to hash the input message in order to compute a signature.

mod signer;
mod verifier;

/// Re-export the `Digest` trait from the `digest` crate, as it's the main
/// trait this module depends on.
pub use ::digest::Digest;

pub use self::{signer::Signer, verifier::Verifier};
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
//! For use signature algorithms that support an Initialize-Update-Finalize
//! (IUF) API, such as ECDSA or Ed25519ph.

use crate::{error::Error, Signature};
use digest::Digest;
use crate::{digest::Digest, error::Error, Signature};

/// Sign the given prehashed message `Digest` using `Self`.
pub trait SignDigest<D, S>: Send + Sync
pub trait Signer<D, S>
where
D: Digest,
S: Signature,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
//! For use signature algorithms that support an Initialize-Update-Finalize
//! (IUF) API, such as ECDSA or Ed25519ph.

use crate::{error::Error, Signature};
use digest::Digest;
use crate::{digest::Digest, error::Error, Signature};

/// Verify the provided signature for the given prehashed message `Digest`
/// is authentic.
pub trait VerifyDigest<D, S>: Send + Sync
pub trait Verifier<D, S>
where
D: Digest,
S: Signature,
Expand Down
11 changes: 5 additions & 6 deletions signature-crate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
unused_qualifications
)]

#[cfg(feature = "digest")]
pub extern crate digest;

#[cfg(any(feature = "std", test))]
#[macro_use]
extern crate std;

#[cfg(feature = "digest")]
mod digest;
mod error;
mod prelude;
pub mod sign;
mod signature;
pub mod verify;
pub mod signer;
pub mod verifier;

pub use crate::{error::Error, sign::Sign, signature::Signature, verify::Verify};
pub use crate::{error::Error, signature::Signature, signer::Signer, verifier::Verifier};
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
//! Traits for generating digital signatures

#[cfg(feature = "digest")]
pub(crate) mod digest;

#[cfg(feature = "digest")]
pub use self::digest::SignDigest;
use crate::{error::Error, Signature};

/// Sign the provided message bytestring using `Self` (e.g. a cryptographic key
/// or connection to an HSM), returning a digital signature.
pub trait Sign<S: Signature>: Send + Sync {
pub trait Signer<S: Signature> {
/// Sign the given message and return a digital signature
fn sign(&self, msg: &[u8]) -> Result<S, Error>;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
//! Trait for verifying digital signatures

#[cfg(feature = "digest")]
pub(crate) mod digest;

#[cfg(feature = "digest")]
pub use self::digest::VerifyDigest;
use crate::{error::Error, Signature};

/// Verify the provided message bytestring using `Self` (e.g. a public key)
pub trait Verify<S: Signature>: Send + Sync {
pub trait Verifier<S: Signature> {
/// Use `Self` to verify that the provided signature for a given message
/// bytestring is authentic.
///
Expand Down