Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 92 additions & 27 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 sqlx-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ crc = "3.0.0"
hkdf = "0.12.0"
hmac = { version = "0.12.0", default-features = false, features = ["reset"]}
md-5 = { version = "0.10.0", default-features = false }
rand = { version = "0.8.4", default-features = false, features = ["std", "std_rng"] }
rand = { version = "0.9.0", default-features = false, features = ["std", "std_rng", "thread_rng"] }
sha2 = { version = "0.10.0", default-features = false }

# Type Integrations (versions inherited from `[workspace.dependencies]`)
Expand Down
14 changes: 7 additions & 7 deletions sqlx-postgres/src/connection/sasl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ pub(crate) async fn authenticate(

// nonce is a sequence of random printable bytes
fn gen_nonce() -> String {
let mut rng = rand::thread_rng();
let count = rng.gen_range(64..128);
let mut rng = rand::rng();
let count = rng.random_range(64..128);

// printable = %x21-2B / %x2D-7E
// ;; Printable ASCII except ",".
// ;; Note that any "printable" is also
// ;; a valid "value".
let nonce: String = std::iter::repeat(())
.map(|()| {
let mut c = rng.gen_range(0x21u8..0x7F);
let mut c = rng.random_range(0x21u8..0x7F);

while c == 0x2C {
c = rng.gen_range(0x21u8..0x7F);
c = rng.random_range(0x21u8..0x7F);
}

c
Expand All @@ -182,7 +182,7 @@ fn gen_nonce() -> String {
.map(|c| c as char)
.collect();

rng.gen_range(32..128);
rng.random_range(32..128);
format!("{NONCE_ATTR}={nonce}")
}

Expand Down Expand Up @@ -210,9 +210,9 @@ fn hi<'a>(s: &'a str, salt: &'a [u8], iter_count: u32) -> Result<[u8; 32], Error
fn bench_sasl_hi(b: &mut test::Bencher) {
use test::black_box;

let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let nonce: Vec<u8> = std::iter::repeat(())
.map(|()| rng.sample(rand::distributions::Alphanumeric))
.map(|()| rng.sample(rand::distr::Alphanumeric))
.take(64)
.collect();
b.iter(|| {
Expand Down
Loading