-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for signing and verifying prehashed message `Digest`s, for use with signature algorithms that support Initialize-Update-Finalize usage.
- Loading branch information
Showing
6 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//! Support for signing messages which have been prehashed messages using | ||
//! the `Digest` trait. | ||
//! | ||
//! 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; | ||
|
||
/// Sign the given prehashed message `Digest` using `Self`. | ||
pub trait SignDigest<D, S>: Send + Sync | ||
where | ||
D: Digest, | ||
S: Signature, | ||
{ | ||
/// Sign the given prehashed message `Digest`, returning a signature. | ||
fn sign(&self, digest: D) -> Result<S, Error>; | ||
} |
9 changes: 7 additions & 2 deletions
9
signature-crate/src/sign.rs → signature-crate/src/sign/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//! Support for verifying messages which have been prehashed messages using | ||
//! the `Digest` trait. | ||
//! | ||
//! 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; | ||
|
||
/// Verify the provided signature for the given prehashed message `Digest` | ||
/// is authentic. | ||
pub trait VerifyDigest<D, S>: Send + Sync | ||
where | ||
D: Digest, | ||
S: Signature, | ||
{ | ||
/// Verify the signature against the given `Digest` | ||
fn verify(&self, digest: D, signature: &S) -> Result<(), Error>; | ||
} |
7 changes: 6 additions & 1 deletion
7
signature-crate/src/verify.rs → signature-crate/src/verify/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters