Skip to content

Commit 684e9bc

Browse files
authored
signature: Prehash should accept a TryCryptoRng (#1752)
This is so that a `RandomizedDigestSigner` can call into `hazmat::RandomizedPrehashSigner` directly with the provided rng. Example use: RustCrypto/signatures#901
1 parent 0c41df9 commit 684e9bc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

signature/src/hazmat.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use crate::Error;
1010

1111
#[cfg(feature = "rand_core")]
12-
use crate::rand_core::CryptoRng;
12+
use crate::rand_core::TryCryptoRng;
1313

1414
/// Sign the provided message prehash, returning a digital signature.
1515
pub trait PrehashSigner<S> {
@@ -43,7 +43,11 @@ pub trait RandomizedPrehashSigner<S> {
4343
///
4444
/// Allowed lengths are algorithm-dependent and up to a particular
4545
/// implementation to decide.
46-
fn sign_prehash_with_rng<R: CryptoRng>(&self, rng: &mut R, prehash: &[u8]) -> Result<S, Error>;
46+
fn sign_prehash_with_rng<R: TryCryptoRng>(
47+
&self,
48+
rng: &mut R,
49+
prehash: &[u8],
50+
) -> Result<S, Error>;
4751
}
4852

4953
/// Verify the provided message prehash using `Self` (e.g. a public key)
@@ -99,7 +103,7 @@ pub trait AsyncRandomizedPrehashSigner<S> {
99103
///
100104
/// Allowed lengths are algorithm-dependent and up to a particular
101105
/// implementation to decide.
102-
async fn sign_prehash_with_rng_async<R: CryptoRng>(
106+
async fn sign_prehash_with_rng_async<R: TryCryptoRng>(
103107
&self,
104108
rng: &mut R,
105109
prehash: &[u8],

0 commit comments

Comments
 (0)