Skip to content

Commit e8d858e

Browse files
committed
Make use of rand_core patch: TryCoreRng::unwrap_mut
1 parent 147808f commit e8d858e

File tree

7 files changed

+17
-44
lines changed

7 files changed

+17
-44
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" }
7878

7979
# https://github.com/entropyxyz/crypto-primes/pull/74
8080
crypto-primes = { git = "https://github.com/baloo/crypto-primes.git", branch = "baloo/rand_core-0.9" }
81+
82+
# https://github.com/rust-random/rand/pull/1589
83+
rand_core = { git = "https://github.com/rust-random/rand.git" }

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ pub mod traits;
237237
mod dummy_rng;
238238
mod encoding;
239239
mod key;
240-
mod unwrap_rng;
241240

242241
pub use pkcs1;
243242
pub use pkcs8;

src/pkcs1v15/signing_key.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{oid, pkcs1v15_generate_prefix, sign, Signature, VerifyingKey};
2-
use crate::{dummy_rng::DummyRng, unwrap_rng::UnwrapRng, Result, RsaPrivateKey};
2+
use crate::{dummy_rng::DummyRng, Result, RsaPrivateKey};
33
use alloc::vec::Vec;
44
use core::marker::PhantomData;
55
use digest::Digest;
@@ -133,7 +133,7 @@ where
133133
digest: D,
134134
) -> signature::Result<Signature> {
135135
sign(
136-
Some(&mut UnwrapRng(rng)),
136+
Some(&mut rng.unwrap_mut()),
137137
&self.inner,
138138
&self.prefix,
139139
&digest.finalize(),
@@ -153,7 +153,7 @@ where
153153
msg: &[u8],
154154
) -> signature::Result<Signature> {
155155
sign(
156-
Some(&mut UnwrapRng(rng)),
156+
Some(&mut rng.unwrap_mut()),
157157
&self.inner,
158158
&self.prefix,
159159
&D::digest(msg),

src/pss/blinded_signing_key.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{get_pss_signature_algo_id, sign_digest, Signature, VerifyingKey};
2-
use crate::{unwrap_rng::UnwrapRng, Result, RsaPrivateKey};
2+
use crate::{Result, RsaPrivateKey};
33
use const_oid::AssociatedOid;
44
use core::marker::PhantomData;
55
use digest::{Digest, FixedOutputReset};
@@ -94,7 +94,7 @@ where
9494
msg: &[u8],
9595
) -> signature::Result<Signature> {
9696
sign_digest::<_, D>(
97-
&mut UnwrapRng(rng),
97+
&mut rng.unwrap_mut(),
9898
true,
9999
&self.inner,
100100
&D::digest(msg),
@@ -115,7 +115,7 @@ where
115115
digest: D,
116116
) -> signature::Result<Signature> {
117117
sign_digest::<_, D>(
118-
&mut UnwrapRng(rng),
118+
&mut rng.unwrap_mut(),
119119
true,
120120
&self.inner,
121121
&digest.finalize(),
@@ -136,7 +136,7 @@ where
136136
prehash: &[u8],
137137
) -> signature::Result<Signature> {
138138
sign_digest::<_, D>(
139-
&mut UnwrapRng(rng),
139+
&mut rng.unwrap_mut(),
140140
true,
141141
&self.inner,
142142
prehash,

src/pss/signing_key.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{get_pss_signature_algo_id, sign_digest, Signature, VerifyingKey};
22
use crate::encoding::verify_algorithm_id;
3-
use crate::{unwrap_rng::UnwrapRng, Result, RsaPrivateKey};
3+
use crate::{Result, RsaPrivateKey};
44
use const_oid::AssociatedOid;
55
use core::marker::PhantomData;
66
use digest::{Digest, FixedOutputReset};
@@ -24,7 +24,7 @@ use {
2424

2525
#[cfg(feature = "getrandom")]
2626
use {
27-
rand_core::{OsRng, UnwrapErr},
27+
rand_core::{OsRng, TryRngCore},
2828
signature::{hazmat::PrehashSigner, Signer},
2929
};
3030

@@ -100,7 +100,7 @@ where
100100
digest: D,
101101
) -> signature::Result<Signature> {
102102
sign_digest::<_, D>(
103-
&mut UnwrapRng(rng),
103+
&mut rng.unwrap_mut(),
104104
false,
105105
&self.inner,
106106
&digest.finalize(),
@@ -134,7 +134,7 @@ where
134134
prehash: &[u8],
135135
) -> signature::Result<Signature> {
136136
sign_digest::<_, D>(
137-
&mut UnwrapRng(rng),
137+
&mut rng.unwrap_mut(),
138138
false,
139139
&self.inner,
140140
prehash,
@@ -151,7 +151,7 @@ where
151151
D: Digest + FixedOutputReset,
152152
{
153153
fn sign_prehash(&self, prehash: &[u8]) -> signature::Result<Signature> {
154-
self.sign_prehash_with_rng(&mut UnwrapErr(OsRng), prehash)
154+
self.sign_prehash_with_rng(&mut OsRng.unwrap_err(), prehash)
155155
}
156156
}
157157

@@ -161,7 +161,7 @@ where
161161
D: Digest + FixedOutputReset,
162162
{
163163
fn try_sign(&self, msg: &[u8]) -> signature::Result<Signature> {
164-
self.try_sign_with_rng(&mut UnwrapErr(OsRng), msg)
164+
self.try_sign_with_rng(&mut OsRng.unwrap_err(), msg)
165165
}
166166
}
167167

src/unwrap_rng.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)