Skip to content

Commit

Permalink
Make use of rand_core patch: TryCoreRng::unwrap_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Feb 16, 2025
1 parent 147808f commit 6402dde
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 54 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ serde_test = "1.0.89"
rand_xorshift = "0.4"
rand_chacha = "0.9"
rand = "0.9"
rand_core = { version = "0.9.0", default-features = false }
rand_core = { version = "0.9.1", default-features = false }
sha1 = { version = "=0.11.0-pre.4", default-features = false, features = ["oid"] }
sha2 = { version = "=0.11.0-pre.4", default-features = false, features = ["oid"] }
sha3 = { version = "=0.11.0-pre.4", default-features = false, features = ["oid"] }
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ pub mod traits;
mod dummy_rng;
mod encoding;
mod key;
mod unwrap_rng;

pub use pkcs1;
pub use pkcs8;
Expand Down
6 changes: 3 additions & 3 deletions src/pkcs1v15/signing_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{oid, pkcs1v15_generate_prefix, sign, Signature, VerifyingKey};
use crate::{dummy_rng::DummyRng, unwrap_rng::UnwrapRng, Result, RsaPrivateKey};
use crate::{dummy_rng::DummyRng, Result, RsaPrivateKey};
use alloc::vec::Vec;
use core::marker::PhantomData;
use digest::Digest;
Expand Down Expand Up @@ -133,7 +133,7 @@ where
digest: D,
) -> signature::Result<Signature> {
sign(
Some(&mut UnwrapRng(rng)),
Some(&mut rng.unwrap_mut()),
&self.inner,
&self.prefix,
&digest.finalize(),
Expand All @@ -153,7 +153,7 @@ where
msg: &[u8],
) -> signature::Result<Signature> {
sign(
Some(&mut UnwrapRng(rng)),
Some(&mut rng.unwrap_mut()),
&self.inner,
&self.prefix,
&D::digest(msg),
Expand Down
8 changes: 4 additions & 4 deletions src/pss/blinded_signing_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{get_pss_signature_algo_id, sign_digest, Signature, VerifyingKey};
use crate::{unwrap_rng::UnwrapRng, Result, RsaPrivateKey};
use crate::{Result, RsaPrivateKey};
use const_oid::AssociatedOid;
use core::marker::PhantomData;
use digest::{Digest, FixedOutputReset};
Expand Down Expand Up @@ -94,7 +94,7 @@ where
msg: &[u8],
) -> signature::Result<Signature> {
sign_digest::<_, D>(
&mut UnwrapRng(rng),
&mut rng.unwrap_mut(),
true,
&self.inner,
&D::digest(msg),
Expand All @@ -115,7 +115,7 @@ where
digest: D,
) -> signature::Result<Signature> {
sign_digest::<_, D>(
&mut UnwrapRng(rng),
&mut rng.unwrap_mut(),
true,
&self.inner,
&digest.finalize(),
Expand All @@ -136,7 +136,7 @@ where
prehash: &[u8],
) -> signature::Result<Signature> {
sign_digest::<_, D>(
&mut UnwrapRng(rng),
&mut rng.unwrap_mut(),
true,
&self.inner,
prehash,
Expand Down
12 changes: 6 additions & 6 deletions src/pss/signing_key.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{get_pss_signature_algo_id, sign_digest, Signature, VerifyingKey};
use crate::encoding::verify_algorithm_id;
use crate::{unwrap_rng::UnwrapRng, Result, RsaPrivateKey};
use crate::{Result, RsaPrivateKey};
use const_oid::AssociatedOid;
use core::marker::PhantomData;
use digest::{Digest, FixedOutputReset};
Expand All @@ -24,7 +24,7 @@ use {

#[cfg(feature = "getrandom")]
use {
rand_core::{OsRng, UnwrapErr},
rand_core::{OsRng, TryRngCore},
signature::{hazmat::PrehashSigner, Signer},
};

Expand Down Expand Up @@ -100,7 +100,7 @@ where
digest: D,
) -> signature::Result<Signature> {
sign_digest::<_, D>(
&mut UnwrapRng(rng),
&mut rng.unwrap_mut(),
false,
&self.inner,
&digest.finalize(),
Expand Down Expand Up @@ -134,7 +134,7 @@ where
prehash: &[u8],
) -> signature::Result<Signature> {
sign_digest::<_, D>(
&mut UnwrapRng(rng),
&mut rng.unwrap_mut(),
false,
&self.inner,
prehash,
Expand All @@ -151,7 +151,7 @@ where
D: Digest + FixedOutputReset,
{
fn sign_prehash(&self, prehash: &[u8]) -> signature::Result<Signature> {
self.sign_prehash_with_rng(&mut UnwrapErr(OsRng), prehash)
self.sign_prehash_with_rng(&mut OsRng.unwrap_err(), prehash)
}
}

Expand All @@ -161,7 +161,7 @@ where
D: Digest + FixedOutputReset,
{
fn try_sign(&self, msg: &[u8]) -> signature::Result<Signature> {
self.try_sign_with_rng(&mut UnwrapErr(OsRng), msg)
self.try_sign_with_rng(&mut OsRng.unwrap_err(), msg)
}
}

Expand Down
28 changes: 0 additions & 28 deletions src/unwrap_rng.rs

This file was deleted.

0 comments on commit 6402dde

Please sign in to comment.