@@ -86,7 +86,7 @@ pub trait DigestSigner<D: Digest, S> {
86
86
#[ cfg( feature = "rand_core" ) ]
87
87
pub trait RandomizedSigner < S > {
88
88
/// Sign the given message and return a digital signature
89
- fn sign_with_rng < R : CryptoRng > ( & self , rng : & mut R , msg : & [ u8 ] ) -> S {
89
+ fn sign_with_rng < R : CryptoRng + ? Sized > ( & self , rng : & mut R , msg : & [ u8 ] ) -> S {
90
90
self . try_sign_with_rng ( rng, msg)
91
91
. expect ( "signature operation failed" )
92
92
}
@@ -96,7 +96,11 @@ pub trait RandomizedSigner<S> {
96
96
///
97
97
/// The main intended use case for signing errors is when communicating
98
98
/// with external signers, e.g. cloud KMS, HSMs, or other hardware tokens.
99
- fn try_sign_with_rng < R : TryCryptoRng > ( & self , rng : & mut R , msg : & [ u8 ] ) -> Result < S , Error > ;
99
+ fn try_sign_with_rng < R : TryCryptoRng + ?Sized > (
100
+ & self ,
101
+ rng : & mut R ,
102
+ msg : & [ u8 ] ,
103
+ ) -> Result < S , Error > ;
100
104
}
101
105
102
106
/// Combination of [`DigestSigner`] and [`RandomizedSigner`] with support for
@@ -106,15 +110,18 @@ pub trait RandomizedDigestSigner<D: Digest, S> {
106
110
/// Sign the given prehashed message `Digest`, returning a signature.
107
111
///
108
112
/// Panics in the event of a signing error.
109
- fn sign_digest_with_rng < R : CryptoRng > ( & self , rng : & mut R , digest : D ) -> S {
113
+ fn sign_digest_with_rng < R : CryptoRng + ? Sized > ( & self , rng : & mut R , digest : D ) -> S {
110
114
self . try_sign_digest_with_rng ( rng, digest)
111
115
. expect ( "signature operation failed" )
112
116
}
113
117
114
118
/// Attempt to sign the given prehashed message `Digest`, returning a
115
119
/// digital signature on success, or an error if something went wrong.
116
- fn try_sign_digest_with_rng < R : TryCryptoRng > ( & self , rng : & mut R , digest : D )
117
- -> Result < S , Error > ;
120
+ fn try_sign_digest_with_rng < R : TryCryptoRng + ?Sized > (
121
+ & self ,
122
+ rng : & mut R ,
123
+ digest : D ,
124
+ ) -> Result < S , Error > ;
118
125
}
119
126
120
127
/// Sign the provided message bytestring using `&mut Self` (e.g. an evolving
@@ -123,7 +130,7 @@ pub trait RandomizedDigestSigner<D: Digest, S> {
123
130
#[ cfg( feature = "rand_core" ) ]
124
131
pub trait RandomizedSignerMut < S > {
125
132
/// Sign the given message, update the state, and return a digital signature.
126
- fn sign_with_rng < R : CryptoRng > ( & mut self , rng : & mut R , msg : & [ u8 ] ) -> S {
133
+ fn sign_with_rng < R : CryptoRng + ? Sized > ( & mut self , rng : & mut R , msg : & [ u8 ] ) -> S {
127
134
self . try_sign_with_rng ( rng, msg)
128
135
. expect ( "signature operation failed" )
129
136
}
@@ -133,13 +140,21 @@ pub trait RandomizedSignerMut<S> {
133
140
///
134
141
/// Signing can fail, e.g., if the number of time periods allowed by the
135
142
/// current key is exceeded.
136
- fn try_sign_with_rng < R : TryCryptoRng > ( & mut self , rng : & mut R , msg : & [ u8 ] ) -> Result < S , Error > ;
143
+ fn try_sign_with_rng < R : TryCryptoRng + ?Sized > (
144
+ & mut self ,
145
+ rng : & mut R ,
146
+ msg : & [ u8 ] ,
147
+ ) -> Result < S , Error > ;
137
148
}
138
149
139
150
/// Blanket impl of [`RandomizedSignerMut`] for all [`RandomizedSigner`] types.
140
151
#[ cfg( feature = "rand_core" ) ]
141
152
impl < S , T : RandomizedSigner < S > > RandomizedSignerMut < S > for T {
142
- fn try_sign_with_rng < R : TryCryptoRng > ( & mut self , rng : & mut R , msg : & [ u8 ] ) -> Result < S , Error > {
153
+ fn try_sign_with_rng < R : TryCryptoRng + ?Sized > (
154
+ & mut self ,
155
+ rng : & mut R ,
156
+ msg : & [ u8 ] ,
157
+ ) -> Result < S , Error > {
143
158
T :: try_sign_with_rng ( self , rng, msg)
144
159
}
145
160
}
0 commit comments