Skip to content

Commit 960fb17

Browse files
committed
chore(deps): update crypto ecosystem
1 parent 4af4e16 commit 960fb17

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ package.version = "0.10.0"
55

66
[workspace.dependencies]
77
beam-lib = { path = "./beam-lib", features = [ "strict-ids" ] }
8+
rsa = "0.10.0-rc.9"
9+
rand = "0.9"
810
# Command Line Interface
911
clap = { version = "4", features = ["env", "derive"] }
1012

proxy/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ serde = "1"
3030
serde_json = "1"
3131

3232
# Encryption handling
33-
rsa = "0.9"
33+
rsa.workspace = true
3434

3535
# Server-sent Events (SSE) support
3636
tokio-util = { version = "0.7", features = ["io"] }
@@ -51,4 +51,4 @@ sockets = ["dep:chacha20poly1305", "dep:dashmap", "tokio-util/codec", "tokio-uti
5151
build-data = "0"
5252

5353
[dev-dependencies]
54-
rand = "0.8.5"
54+
rand.workspace = true

shared/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ tracing = "0.1"
2828
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
2929

3030
# Crypto
31-
rand = "0.8"
32-
rsa = "0.9"
33-
sha2 = "0.10"
31+
rand.workspace = true
32+
rsa.workspace = true
33+
sha2 = "0.11.0-rc.2"
34+
chacha20poly1305 = "0.11.0-rc.1"
3435
openssl = "0.10"
35-
chacha20poly1305 = "0.10"
3636
itertools = "0.14.0"
3737
jwt-simple = "0.11"
3838

shared/src/crypto.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,8 @@ pub fn load_certificates_from_dir(ca_dir: Option<PathBuf>) -> Result<Vec<reqwest
823823
/// Checks whether or not a x509 certificate matches a private key by comparing the (public) modulus
824824
pub fn is_cert_from_privkey(cert: &X509, key: &RsaPrivateKey) -> Result<bool, ErrorStack> {
825825
let cert_rsa = cert.public_key()?.rsa()?;
826-
let cert_mod = cert_rsa.n();
827-
let key_mod = key.n();
828-
let key_mod_bignum = openssl::bn::BigNum::from_slice(&key_mod.to_bytes_be())?;
829-
let is_equal = cert_mod.ucmp(&key_mod_bignum) == std::cmp::Ordering::Equal;
826+
let cert_mod = rsa::BoxedUint::from_be_slice_vartime(&cert_rsa.n().to_vec());
827+
let is_equal = cert_mod.cmp(&key.n()) == std::cmp::Ordering::Equal;
830828
if !is_equal {
831829
match ProxyCertInfo::try_from(cert) {
832830
Ok(x) => {

shared/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use beam_lib::{AppId, AppOrProxyId, ProxyId, FailureStrategy, WorkStatus};
44
use chacha20poly1305::{
5-
aead::{Aead, AeadCore, KeyInit, OsRng},
5+
aead::{Aead, AeadCore, KeyInit},
66
XChaCha20Poly1305, XNonce,
77
};
88
use crypto_jwt::extract_jwt;
@@ -21,7 +21,7 @@ use std::{
2121
time::{Duration, Instant, SystemTime}, net::SocketAddr, error::Error,
2222
};
2323

24-
use rand::Rng;
24+
use rand::{rng, rngs::OsRng, Rng};
2525
use serde::{
2626
de::{DeserializeOwned, Visitor},
2727
Deserialize, Serialize,
@@ -302,9 +302,9 @@ pub trait EncryptableMsg: Msg + Serialize + Sized {
302302
receivers_public_keys: &Vec<RsaPublicKey>,
303303
) -> Result<Self::Output, SamplyBeamError> {
304304
// Generate Symmetric Key and Nonce
305-
let mut rng = rand::thread_rng();
306-
let symmetric_key = XChaCha20Poly1305::generate_key(&mut rng);
307-
let nonce = XChaCha20Poly1305::generate_nonce(&mut rng);
305+
let mut rng = rng();
306+
let symmetric_key = XChaCha20Poly1305::generate_key_with_rng(&mut rng);
307+
let nonce = XChaCha20Poly1305::generate_nonce_with_rng(&mut rng);
308308

309309
// Encrypt symmetric key with receivers' public keys
310310
let Ok(encrypted_keys) = receivers_public_keys
@@ -753,7 +753,7 @@ mod tests {
753753
};
754754

755755
//Setup Keypairs
756-
let mut rng = rand::thread_rng();
756+
let mut rng = rand::rng();
757757
let rsa_length: usize = 2048;
758758
let p1_private = RsaPrivateKey::new(&mut rng, rsa_length)
759759
.expect("Failed to generate private key for proxy 1");
@@ -799,7 +799,7 @@ mod tests {
799799
};
800800

801801
//Setup Keypairs
802-
let mut rng = rand::thread_rng();
802+
let mut rng = rand::rng();
803803
let rsa_length: usize = 2048;
804804
let p1_private = RsaPrivateKey::new(&mut rng, rsa_length)
805805
.expect("Failed to generate private key for proxy 1");

tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ beam-lib = { workspace = true, features = ["http-util"] }
1111
once_cell = "1"
1212
serde_json = "1"
1313
anyhow = "1"
14-
rand = "0.8"
14+
rand.workspace = true
1515
serde = { version = "1", features = ["derive"] }
1616
reqwest = { version = "0.12", features = ["stream"], default-features = false }
1717
futures = "0.3.28"

0 commit comments

Comments
 (0)