Skip to content

Commit 7c38a58

Browse files
committed
workspace: bump RustCrypto dependencies to pre-releases
1 parent 27ef8e3 commit 7c38a58

File tree

10 files changed

+46
-44
lines changed

10 files changed

+46
-44
lines changed

biscuit-auth/Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ uuid = ["dep:uuid"]
2626
pem = ["ed25519-dalek/pem", "ed25519-dalek/pkcs8"]
2727

2828
[dependencies]
29-
rand_core = "^0.6"
30-
sha2 = "^0.9"
29+
rand_core = "0.9"
30+
sha2 = "0.11.0-rc.2"
3131
prost = "0.10"
3232
prost-types = "0.10"
3333
regex = { version = "1.5", default-features = false, features = ["std"] }
3434
nom = { version = "7", default-features = false, features = ["std"] }
3535
hex = "0.4"
3636
zeroize = { version = "1.5", default-features = false }
3737
thiserror = "1"
38-
rand = { version = "0.8" }
38+
rand = { version = "0.9" }
3939
wasm-bindgen = { version = "0.2", optional = true }
4040
base64 = "0.13.0"
41-
ed25519-dalek = { version = "2.0.0", features = ["rand_core", "zeroize"] }
41+
ed25519-dalek = { version = "3.0.0-pre.1", features = ["rand_core", "zeroize"] }
4242
serde = { version = "1.0.132", optional = true, features = ["derive"] }
43-
getrandom = { version = "0.2.15" }
43+
getrandom = { version = "0.3" }
4444
time = { version = "0.3.7", features = ["formatting", "parsing"] }
4545
uuid = { version = "1", optional = true }
4646
biscuit-parser = { version = "0.2.0", path = "../biscuit-parser" }
@@ -49,14 +49,14 @@ chrono = { version = "0.4.26", optional = true, default-features = false, featur
4949
"serde",
5050
] }
5151
serde_json = "1.0.117"
52-
ecdsa = { version = "0.16.9", features = ["signing", "verifying", "pem", "alloc", "pkcs8", "serde"] }
53-
p256 = "0.13.2"
54-
pkcs8 = "0.9.0"
55-
elliptic-curve = { version = "0.13.8", features = ["pkcs8"] }
52+
ecdsa = { version = "0.17.0-rc.6", features = ["signing", "verifying", "pem", "alloc", "pkcs8", "serde"] }
53+
p256 = "0.14.0-pre.10"
54+
pkcs8 = "0.11.0-rc.6"
55+
elliptic-curve = { version = "0.14.0-rc.1", features = ["pkcs8"] }
5656

5757
[dev-dependencies]
5858
bencher = "0.1.5"
59-
rand = "0.8"
59+
rand = "0.9"
6060
chrono = { version = "0.4.26", features = ["serde", "clock"] }
6161
colored-diff = "0.2.3"
6262
prost-build = "0.10"

biscuit-auth/examples/testcases.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ fn random_block(target: &str, root: &KeyPair, test: bool) -> TestResult {
722722
} else {
723723
let serialized = biscuit2.container();
724724
let mut proto = serialized.to_proto();
725-
let arr: [u8; 32] = rng.gen();
725+
let arr: [u8; 32] = rng.random();
726726
proto.blocks[0].block = Vec::from(&arr[..]);
727727
let mut data = Vec::new();
728728
proto.encode(&mut data).unwrap();

biscuit-auth/src/crypto/ed25519.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ pub struct KeyPair {
3131

3232
impl KeyPair {
3333
pub fn new() -> Self {
34-
Self::new_with_rng(&mut rand::rngs::OsRng)
34+
Self::new_with_rng(&mut rand::rng())
3535
}
3636

37-
pub fn new_with_rng<T: RngCore + CryptoRng>(rng: &mut T) -> Self {
37+
pub fn new_with_rng<T: RngCore + CryptoRng + ?Sized>(rng: &mut T) -> Self {
3838
let kp = ed25519_dalek::SigningKey::generate(rng);
3939
KeyPair { kp }
4040
}

biscuit-auth/src/crypto/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ pub enum KeyPair {
3535
impl KeyPair {
3636
/// Create a new ed25519 keypair with the default OS RNG
3737
pub fn new() -> Self {
38-
Self::new_with_rng(Algorithm::Ed25519, &mut rand::rngs::OsRng)
38+
Self::new_with_rng(Algorithm::Ed25519, &mut rand::rng())
3939
}
4040

4141
/// Create a new keypair with a chosen algorithm and the default OS RNG
4242
pub fn new_with_algorithm(algorithm: Algorithm) -> Self {
43-
Self::new_with_rng(algorithm, &mut rand::rngs::OsRng)
43+
Self::new_with_rng(algorithm, &mut rand::rng())
4444
}
4545

46-
pub fn new_with_rng<T: RngCore + CryptoRng>(algorithm: Algorithm, rng: &mut T) -> Self {
46+
pub fn new_with_rng<T: RngCore + CryptoRng + ?Sized>(
47+
algorithm: Algorithm,
48+
rng: &mut T,
49+
) -> Self {
4750
match algorithm {
4851
Algorithm::Ed25519 => KeyPair::Ed25519(ed25519::KeyPair::new_with_rng(rng)),
4952
Algorithm::Secp256r1 => KeyPair::P256(p256::KeyPair::new_with_rng(rng)),

biscuit-auth/src/crypto/p256.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use super::error;
99
use super::Signature;
1010

1111
use p256::ecdsa::{signature::Signer, signature::Verifier, SigningKey, VerifyingKey};
12-
use p256::elliptic_curve::rand_core::{CryptoRng, OsRng, RngCore};
12+
use p256::elliptic_curve::rand_core::{CryptoRng, RngCore};
1313
use p256::NistP256;
14-
use std::hash::Hash;
14+
use std::{convert::TryInto, hash::Hash};
1515

1616
/// pair of cryptographic keys used to sign a token's block
1717
#[derive(Debug, PartialEq)]
@@ -21,10 +21,10 @@ pub struct KeyPair {
2121

2222
impl KeyPair {
2323
pub fn new() -> Self {
24-
Self::new_with_rng(&mut OsRng)
24+
Self::new_with_rng(&mut rand::rng())
2525
}
2626

27-
pub fn new_with_rng<T: RngCore + CryptoRng>(rng: &mut T) -> Self {
27+
pub fn new_with_rng<T: RngCore + CryptoRng + ?Sized>(rng: &mut T) -> Self {
2828
let kp = SigningKey::random(rng);
2929

3030
KeyPair { kp }
@@ -41,9 +41,13 @@ impl KeyPair {
4141
if bytes.len() != 32 {
4242
return Err(Format::InvalidKeySize(bytes.len()));
4343
}
44-
let kp = SigningKey::from_bytes(bytes.into())
45-
.map_err(|s| s.to_string())
46-
.map_err(Format::InvalidKey)?;
44+
let kp = SigningKey::from_bytes(
45+
bytes
46+
.try_into()
47+
.map_err(|_| Format::InvalidKeySize(bytes.len()))?,
48+
)
49+
.map_err(|s| s.to_string())
50+
.map_err(Format::InvalidKey)?;
4751

4852
Ok(KeyPair { kp })
4953
}
@@ -134,15 +138,14 @@ impl PrivateKey {
134138

135139
/// deserializes from a big endian byte array
136140
pub fn from_bytes(bytes: &[u8]) -> Result<Self, error::Format> {
137-
// the version of generic-array used by p256 panics if the input length
138-
// is incorrect (including when using `.try_into()`)
139-
if bytes.len() != 32 {
140-
return Err(Format::InvalidKeySize(bytes.len()));
141-
}
142-
SigningKey::from_bytes(bytes.into())
143-
.map(PrivateKey)
144-
.map_err(|s| s.to_string())
145-
.map_err(Format::InvalidKey)
141+
SigningKey::from_bytes(
142+
bytes
143+
.try_into()
144+
.map_err(|_| Format::InvalidKeySize(bytes.len()))?,
145+
)
146+
.map(PrivateKey)
147+
.map_err(|s| s.to_string())
148+
.map_err(Format::InvalidKey)
146149
}
147150

148151
/// deserializes from an hex-encoded string

biscuit-auth/src/time.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//!
77
//! code from <https://github.com/rust-lang/rust/issues/48564#issuecomment-698712971>
88
9-
#[cfg(feature = "wasm")]
10-
use std::convert::TryInto;
119
use std::ops::{Add, AddAssign, Sub, SubAssign};
1210
#[cfg(feature = "wasm")]
1311
use wasm_bindgen::prelude::*;

biscuit-auth/src/token/builder/biscuit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ impl BiscuitBuilder {
133133
root_key: &KeyPair,
134134
symbols: SymbolTable,
135135
) -> Result<Biscuit, error::Token> {
136-
self.build_with_rng(root_key, symbols, &mut rand::rngs::OsRng)
136+
self.build_with_rng(root_key, symbols, &mut rand::rng())
137137
}
138138

139-
pub fn build_with_rng<R: RngCore + CryptoRng>(
139+
pub fn build_with_rng<R: RngCore + CryptoRng + ?Sized>(
140140
self,
141141
root: &KeyPair,
142142
symbols: SymbolTable,

biscuit-auth/src/token/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl Biscuit {
174174
/// since the public key is integrated into the token, the keypair can be
175175
/// discarded right after calling this function
176176
pub fn append(&self, block_builder: BlockBuilder) -> Result<Self, error::Token> {
177-
let keypair = KeyPair::new_with_rng(builder::Algorithm::Ed25519, &mut rand::rngs::OsRng);
177+
let keypair = KeyPair::new_with_rng(builder::Algorithm::Ed25519, &mut rand::rng());
178178
self.append_with_keypair(&keypair, block_builder)
179179
}
180180

@@ -251,7 +251,7 @@ impl Biscuit {
251251
/// creates a new token, using a provided CSPRNG
252252
///
253253
/// the public part of the root keypair must be used for verification
254-
pub(crate) fn new_with_rng<T: RngCore + CryptoRng>(
254+
pub(crate) fn new_with_rng<T: RngCore + CryptoRng + ?Sized>(
255255
rng: &mut T,
256256
root_key_id: Option<u32>,
257257
root: &KeyPair,
@@ -413,8 +413,7 @@ impl Biscuit {
413413
external_key: PublicKey,
414414
response: ThirdPartyBlock,
415415
) -> Result<Self, error::Token> {
416-
let next_keypair =
417-
KeyPair::new_with_rng(builder::Algorithm::Ed25519, &mut rand::rngs::OsRng);
416+
let next_keypair = KeyPair::new_with_rng(builder::Algorithm::Ed25519, &mut rand::rng());
418417

419418
self.append_third_party_with_keypair(external_key, response, next_keypair)
420419
}

biscuit-auth/src/token/unverified.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ impl UnverifiedBiscuit {
105105
/// since the public key is integrated into the token, the keypair can be
106106
/// discarded right after calling this function
107107
pub fn append(&self, block_builder: BlockBuilder) -> Result<Self, error::Token> {
108-
let keypair =
109-
KeyPair::new_with_rng(super::builder::Algorithm::Ed25519, &mut rand::rngs::OsRng);
108+
let keypair = KeyPair::new_with_rng(super::builder::Algorithm::Ed25519, &mut rand::rng());
110109
self.append_with_keypair(&keypair, block_builder)
111110
}
112111

@@ -302,7 +301,7 @@ impl UnverifiedBiscuit {
302301

303302
pub fn append_third_party(&self, slice: &[u8]) -> Result<Self, error::Token> {
304303
let next_keypair =
305-
KeyPair::new_with_rng(super::builder::Algorithm::Ed25519, &mut rand::rngs::OsRng);
304+
KeyPair::new_with_rng(super::builder::Algorithm::Ed25519, &mut rand::rng());
306305
self.append_third_party_with_keypair(slice, next_keypair)
307306
}
308307

biscuit-capi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ biscuit-auth = { version = "6.0.0", path = "../biscuit-auth", features = [
1919
"pem",
2020
] }
2121
libc = "0.2"
22-
rand = "0.8"
22+
rand = "0.9"
2323

2424
[dev-dependencies]
2525
inline-c = "0.1"

0 commit comments

Comments
 (0)