Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update getrandom usages

Leendert de Borst0423a6f38754
diff --git a/core/rust/.cargo/config.toml b/core/rust/.cargo/config.toml
new file mode 100644
index 000000000..645d25df7
--- /dev/null
+++ b/core/rust/.cargo/config.toml
@@ -0,0 +1,3 @@
+# getrandom 0.3 config
+[target.wasm32-unknown-unknown]
+rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
diff --git a/core/rust/Cargo.lock b/core/rust/Cargo.lock
index 125f84fb9..da74333a4 100644
--- a/core/rust/Cargo.lock
+++ b/core/rust/Cargo.lock
@@ -10,7 +10,7 @@ dependencies = [
"chrono",
"console_error_panic_hook",
"digest",
- "getrandom 0.2.17",
+ "getrandom",
"num-bigint",
"rand",
"serde",
@@ -346,19 +346,6 @@ dependencies = [
"version_check",
]
-[[package]]
-name = "getrandom"
-version = "0.2.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
-dependencies = [
- "cfg-if",
- "js-sys",
- "libc",
- "wasi",
- "wasm-bindgen",
-]
-
[[package]]
name = "getrandom"
version = "0.3.4"
@@ -366,9 +353,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
+ "js-sys",
"libc",
"r-efi",
"wasip2",
+ "wasm-bindgen",
]
[[package]]
@@ -600,7 +589,7 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
dependencies = [
- "getrandom 0.3.4",
+ "getrandom",
]
[[package]]
@@ -962,12 +951,6 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
-[[package]]
-name = "wasi"
-version = "0.11.1+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
-
[[package]]
name = "wasip2"
version = "1.0.2+wasi-0.2.9"
diff --git a/core/rust/Cargo.toml b/core/rust/Cargo.toml
index fa3a7dd9f..215a86085 100644
--- a/core/rust/Cargo.toml
+++ b/core/rust/Cargo.toml
@@ -43,7 +43,7 @@ rand = { version = "0.9", features = ["std", "std_rng"] }
num-bigint = "0.4"
digest = "0.10"
subtle = "2.5"
-getrandom = { version = "0.2", features = ["js"] }
+getrandom = { version = "0.3", features = ["wasm_js"] }
# Argon2 password hashing
argon2 = "0.5"
diff --git a/core/rust/src/srp/mod.rs b/core/rust/src/srp/mod.rs
index 0eb7c8d20..9b3e84d7f 100644
--- a/core/rust/src/srp/mod.rs
+++ b/core/rust/src/srp/mod.rs
@@ -103,7 +103,7 @@ fn hex_to_bytes(hex: &str) -> Result<Vec<u8>, SrpError> {
/// Generate cryptographically secure random bytes.
fn generate_random_bytes(len: usize) -> Vec<u8> {
let mut bytes = vec![0u8; len];
- rand::thread_rng().fill_bytes(&mut bytes);
+ rand::rng().fill_bytes(&mut bytes);
bytes
}