Skip to content

Commit a7dfb09

Browse files
committed
Revert "signature: use R: CryptoRngCore + ?Sized (#1167)"
This reverts commit b12237e. As further discussed in #1148, passing a trait object to `&mut impl CryptoRngCore` is possible by mutably borrowing it, and upstream changes to `CryptoRng` should eliminate the requirement for the `?Sized` bound.
1 parent 4fca563 commit a7dfb09

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

signature/src/hazmat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ pub trait RandomizedPrehashSigner<S> {
4848
///
4949
/// Allowed lengths are algorithm-dependent and up to a particular
5050
/// implementation to decide.
51-
fn sign_prehash_with_rng<R: CryptoRngCore + ?Sized>(
51+
fn sign_prehash_with_rng(
5252
&self,
53-
rng: &mut R,
53+
rng: &mut impl CryptoRngCore,
5454
prehash: &[u8],
5555
) -> Result<S, Error>;
5656
}

signature/src/signer.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub trait DigestSigner<D: Digest, S> {
8787
#[cfg_attr(docsrs, doc(cfg(feature = "rand-preview")))]
8888
pub trait RandomizedSigner<S> {
8989
/// Sign the given message and return a digital signature
90-
fn sign_with_rng<R: CryptoRngCore + ?Sized>(&self, rng: &mut R, msg: &[u8]) -> S {
90+
fn sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> S {
9191
self.try_sign_with_rng(rng, msg)
9292
.expect("signature operation failed")
9393
}
@@ -97,11 +97,7 @@ pub trait RandomizedSigner<S> {
9797
///
9898
/// The main intended use case for signing errors is when communicating
9999
/// with external signers, e.g. cloud KMS, HSMs, or other hardware tokens.
100-
fn try_sign_with_rng<R: CryptoRngCore + ?Sized>(
101-
&self,
102-
rng: &mut R,
103-
msg: &[u8],
104-
) -> Result<S, Error>;
100+
fn try_sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> Result<S, Error>;
105101
}
106102

107103
/// Combination of [`DigestSigner`] and [`RandomizedSigner`] with support for
@@ -113,16 +109,13 @@ pub trait RandomizedDigestSigner<D: Digest, S> {
113109
/// Sign the given prehashed message `Digest`, returning a signature.
114110
///
115111
/// Panics in the event of a signing error.
116-
fn sign_digest_with_rng<R: CryptoRngCore + ?Sized>(&self, rng: &mut R, digest: D) -> S {
112+
fn sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) -> S {
117113
self.try_sign_digest_with_rng(rng, digest)
118114
.expect("signature operation failed")
119115
}
120116

121117
/// Attempt to sign the given prehashed message `Digest`, returning a
122118
/// digital signature on success, or an error if something went wrong.
123-
fn try_sign_digest_with_rng<R: CryptoRngCore + ?Sized>(
124-
&self,
125-
rng: &mut R,
126-
digest: D,
127-
) -> Result<S, Error>;
119+
fn try_sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D)
120+
-> Result<S, Error>;
128121
}

0 commit comments

Comments
 (0)