Skip to content

Commit abd7c67

Browse files
committed
fix(deps): update RustCrypto ecosystem for rand 0.10 compatibility
Bump the full RustCrypto dependency tree to align with rand 0.10 and rand_core 0.10. This resolves the split dependency graph where ssh-key's transitive deps used signature v3 / elliptic-curve v0.14 while russh used the older stable versions. Key dependency changes: - signature 2.2 → 3.0.0-rc.10 (removes signature_next shim) - elliptic-curve 0.13 → 0.14.0-rc.28, ecdsa 0.16 → 0.17.0-rc.16 - p256/p384/p521 0.13 → 0.14.0-rc.7 - ed25519-dalek 2.x → 3.0.0-pre.6 (add alloc feature for EncodePrivateKey) - curve25519-dalek 4.x → 5.0.0-pre.6 - der 0.7 → 0.8, sec1 0.7 → 0.8, spki 0.7 → 0.8.0-rc.4 - pkcs8 0.10 → 0.11.0-rc.11, pkcs5 0.7 → 0.8.0-rc.13 - num-bigint pinned to git (PR Eugeny#338) for rand_0_10 feature Code changes to match new APIs: - OsRng removed in rand 0.10; replaced with rand::rng() - PrivateKeyInfo/EncryptedPrivateKeyInfo now generic; use Ref aliases - SecretKey::from_bytes → from_slice for ECDSA key construction - FromEncodedPoint/ToEncodedPoint → FromSec1Point/ToSec1Point - EphemeralSecret::random → generate_from_rng (Generate trait) - RandBigInt → BigRng010, gen_biguint_range → random_biguint_range - Remove duplicate Pkcs8Next error variant (now same pkcs8 version) Temporary workarounds (with tracking comments): - [patch.crates-io] hmac: git pin for digest 0.11.2 Clone regression (RustCrypto/MACs#254 merged, awaiting hmac 0.13.0-rc.6 release) - num-bigint: git dep on PR Eugeny#338 branch for rand 0.10 support
1 parent 6041444 commit abd7c67

24 files changed

Lines changed: 200 additions & 144 deletions

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ log = "0.4.11"
1616
rand = { version = "0.10", features = ["thread_rng"] }
1717
sha1 = { version = "0.10.5", features = ["oid"] }
1818
sha2 = { version = "0.10.6", features = ["oid"] }
19-
signature = "2.2"
19+
signature = "3.0.0-rc.10"
2020
ssh-encoding = { version = "0.2", features = ["bytes"] }
2121
ssh-key = { version = "=0.6.18", features = [
2222
"ed25519",
@@ -30,3 +30,10 @@ ssh-key = { version = "=0.6.18", features = [
3030
thiserror = "2.0.18"
3131
tokio = { version = "1.17.0" }
3232
tokio-stream = { version = "0.1.3", features = ["net", "sync"] }
33+
34+
[patch.crates-io]
35+
# digest 0.11.2 removed Clone from MacTraits (RustCrypto/traits#2329), breaking
36+
# hmac 0.13.0-rc.5 which still relies on it. The fix landed in hmac's repo
37+
# (RustCrypto/MACs#254) but no rc.6 has been published yet. Remove this patch
38+
# once hmac 0.13.0-rc.6+ is released.
39+
hmac = { git = "https://github.com/RustCrypto/MACs.git", rev = "da485cd7baf0b7f5e501f5b42644bf9ddd428c6b" }

russh/Cargo.toml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ byteorder.workspace = true
3737
bytes.workspace = true
3838
cbc = { version = "0.1" }
3939
ctr = "0.9"
40-
curve25519-dalek = "4.1.3"
40+
curve25519-dalek = "5.0.0-pre.6"
4141
crypto-bigint = { version = "0.7.0-rc.28", features = ["alloc"] }
4242
data-encoding = "2.3"
4343
delegate.workspace = true
4444
digest.workspace = true
45-
der = "0.7"
45+
der = "0.8"
4646
des = { version = "0.8.1", optional = true }
47-
ecdsa = "0.16"
48-
ed25519-dalek = { version = "3.0.0-pre.6", features = ["rand_core", "pkcs8"] }
47+
ecdsa = "0.17.0-rc.16"
48+
ed25519-dalek = { version = "3.0.0-pre.6", features = ["alloc", "rand_core", "pkcs8"] }
4949
elliptic-curve = { version = "0.14.0-rc.28", features = ["ecdh"] }
5050
enum_dispatch = "0.3.13"
5151
flate2 = { version = "1.0.15", optional = true }
@@ -58,15 +58,18 @@ inout = { version = "0.1", features = ["std"] }
5858
libcrux-ml-kem = { version = "0.0.4" }
5959
log.workspace = true
6060
md5 = "0.7"
61-
num-bigint = { version = "0.4.2", features = ["rand"] }
61+
# num-bigint 0.4.x only supports rand 0.8. PR #338 adds rand 0.10 support
62+
# via the `rand_0_10` feature flag. Remove this git dep once a release with
63+
# rand 0.10 support is published. https://github.com/rust-num/num-bigint/pull/338
64+
num-bigint = { git = "https://github.com/rust-num/num-bigint.git", rev = "09ed9207ec8e8cbf770c552d335fb894a894db86", features = ["rand_0_10"] }
6265
# num-integer = "0.1"
6366
p256 = { version = "0.14.0-rc.7", features = ["ecdh"] }
6467
p384 = { version = "0.14.0-rc.7", features = ["ecdh"] }
6568
p521 = { version = "0.14.0-rc.7", features = ["ecdh"] }
6669
pbkdf2 = "0.12"
6770
pkcs1 = { version = "0.8.0-rc.4", optional = true }
68-
pkcs5 = "0.7"
69-
pkcs8 = { version = "0.10", features = ["pkcs5", "encryption", "std"] }
71+
pkcs5 = "0.8.0-rc.13"
72+
pkcs8 = { version = "0.11.0-rc.11", features = ["encryption", "std"] }
7073
rand_core = { version = "0.10.0" }
7174
rand.workspace = true
7275
ring = { version = "0.17.14", optional = true }
@@ -75,12 +78,11 @@ russh-cryptovec = { version = "0.58.0", path = "../cryptovec", features = [
7578
"ssh-encoding",
7679
] }
7780
russh-util = { version = "0.52.0", path = "../russh-util" }
78-
sec1 = { version = "0.7", features = ["pkcs8", "der"] }
81+
sec1 = { version = "0.8", features = ["der"] }
7982
sha1.workspace = true
8083
sha2.workspace = true
8184
signature.workspace = true
82-
signature_next = { package = "signature", version = "3.0.0-rc.10", default-features = false }
83-
spki = "0.7"
85+
spki = "0.8.0-rc.4"
8486
ssh-encoding.workspace = true
8587
ssh-key.workspace = true
8688
subtle = "2.4"

russh/examples/echoserver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::collections::HashMap;
22
use std::sync::Arc;
33

4-
use russh::keys::ssh_key::rand_core::OsRng;
54
use russh::keys::{Certificate, *};
65
use russh::server::{Msg, Server as _, Session};
76
use russh::*;
@@ -19,7 +18,7 @@ async fn main() {
1918
auth_rejection_time: std::time::Duration::from_secs(3),
2019
auth_rejection_time_initial: Some(std::time::Duration::from_secs(0)),
2120
keys: vec![
22-
russh::keys::PrivateKey::random(&mut OsRng, russh::keys::Algorithm::Ed25519).unwrap(),
21+
russh::keys::PrivateKey::random(&mut rand::rng(), russh::keys::Algorithm::Ed25519).unwrap(),
2322
],
2423
preferred: Preferred {
2524
// kex: std::borrow::Cow::Owned(vec![russh::kex::DH_GEX_SHA256]),

russh/examples/ratatui_app.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use ratatui::style::{Color, Style};
77
use ratatui::widgets::{Block, Borders, Clear, Paragraph};
88
use ratatui::{Terminal, TerminalOptions, Viewport};
99
use russh::keys::ssh_key::PublicKey;
10-
use russh::keys::ssh_key::rand_core::OsRng;
1110
use russh::server::*;
1211
use russh::{Channel, ChannelId, Pty};
1312
use tokio::sync::Mutex;
@@ -120,7 +119,7 @@ impl AppServer {
120119
auth_rejection_time: std::time::Duration::from_secs(3),
121120
auth_rejection_time_initial: Some(std::time::Duration::from_secs(0)),
122121
keys: vec![
123-
russh::keys::PrivateKey::random(&mut OsRng, ssh_key::Algorithm::Ed25519).unwrap(),
122+
russh::keys::PrivateKey::random(&mut rand::rng(), ssh_key::Algorithm::Ed25519).unwrap(),
124123
],
125124
nodelay: true,
126125
..Default::default()

russh/examples/ratatui_shared_app.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use ratatui::style::{Color, Style};
77
use ratatui::widgets::{Block, Borders, Clear, Paragraph};
88
use ratatui::{Terminal, TerminalOptions, Viewport};
99
use russh::keys::ssh_key::PublicKey;
10-
use russh::keys::ssh_key::rand_core::OsRng;
1110
use russh::server::*;
1211
use russh::{Channel, ChannelId, Pty};
1312
use tokio::sync::Mutex;
@@ -122,7 +121,7 @@ impl AppServer {
122121
auth_rejection_time: std::time::Duration::from_secs(3),
123122
auth_rejection_time_initial: Some(std::time::Duration::from_secs(0)),
124123
keys: vec![
125-
russh::keys::PrivateKey::random(&mut OsRng, ssh_key::Algorithm::Ed25519).unwrap(),
124+
russh::keys::PrivateKey::random(&mut rand::rng(), ssh_key::Algorithm::Ed25519).unwrap(),
126125
],
127126
nodelay: true,
128127
..Default::default()

russh/examples/sftp_server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::sync::Arc;
44
use std::time::Duration;
55

66
use log::{LevelFilter, error, info};
7-
use russh::keys::ssh_key::rand_core::OsRng;
87
use russh::server::{Auth, Msg, Server as _, Session};
98
use russh::{Channel, ChannelId};
109
use russh_sftp::protocol::{File, FileAttributes, Handle, Name, Status, StatusCode, Version};
@@ -179,7 +178,7 @@ async fn main() {
179178
auth_rejection_time: Duration::from_secs(3),
180179
auth_rejection_time_initial: Some(Duration::from_secs(0)),
181180
keys: vec![
182-
russh::keys::PrivateKey::random(&mut OsRng, ssh_key::Algorithm::Ed25519).unwrap(),
181+
russh::keys::PrivateKey::random(&mut rand::rng(), ssh_key::Algorithm::Ed25519).unwrap(),
183182
],
184183
..Default::default()
185184
};

russh/examples/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::collections::HashMap;
22
use std::sync::{Arc, Mutex};
33

44
use log::debug;
5-
use russh::keys::ssh_key::rand_core::OsRng;
65
use russh::keys::*;
76
use russh::server::{Auth, Msg, Server as _, Session};
87
use russh::*;
@@ -14,7 +13,7 @@ async fn main() -> anyhow::Result<()> {
1413
config.auth_rejection_time = std::time::Duration::from_secs(3);
1514
config
1615
.keys
17-
.push(russh::keys::PrivateKey::random(&mut OsRng, ssh_key::Algorithm::Ed25519).unwrap());
16+
.push(russh::keys::PrivateKey::random(&mut rand::rng(), ssh_key::Algorithm::Ed25519).unwrap());
1817
let config = Arc::new(config);
1918
let mut sh = Server {
2019
clients: Arc::new(Mutex::new(HashMap::new())),

russh/src/cipher/benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use criterion::*;
33
use rand::TryRngCore;
44

55
pub fn bench(c: &mut Criterion) {
6-
let mut rand_generator = black_box(rand::rngs::OsRng {});
6+
let mut rand_generator = black_box(rand::rng());
77

88
let mut packet_length = black_box(vec![0u8; 4]);
99

russh/src/client/encrypted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ impl Encrypted {
10151015
)?;
10161016

10171017
// Extend with self-signature.
1018-
signature_next::Signer::try_sign(key.deref(), buffer)?
1018+
signature::Signer::try_sign(key.deref(), buffer)?
10191019
.encoded()?
10201020
.encode(&mut *buffer)?;
10211021

russh/src/client/kex.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ use std::sync::Arc;
55

66
use bytes::Bytes;
77
use log::{debug, error, warn};
8-
use signature::Verifier;
98
use ssh_encoding::{Decode, Encode};
109
use ssh_key::{Mpint, PublicKey, Signature};
1110

1211
use super::IncomingSshPacket;
1312
use crate::client::{Config, NewKeys};
1413
use crate::kex::dh::groups::DhGroup;
15-
use crate::kex::{KexAlgorithm, KexAlgorithmImplementor, KexCause, KexProgress, KEXES};
14+
use crate::kex::{KEXES, KexAlgorithm, KexAlgorithmImplementor, KexCause, KexProgress};
1615
use crate::keys::key::parse_public_key;
1716
use crate::negotiation::{Names, Select};
1817
use crate::session::Exchange;
1918
use crate::sshbuffer::PacketWriter;
20-
use crate::{msg, negotiation, strict_kex_violation, CryptoVec, Error, SshId};
19+
use crate::{CryptoVec, Error, SshId, msg, negotiation, strict_kex_violation};
2120

2221
thread_local! {
2322
static HASH_BUFFER: RefCell<CryptoVec> = RefCell::new(CryptoVec::new());
@@ -116,7 +115,9 @@ impl ClientKex {
116115

117116
let names = {
118117
// read algorithms from packet.
119-
self.exchange.server_kex_init.extend_from_slice(&input.buffer);
118+
self.exchange
119+
.server_kex_init
120+
.extend_from_slice(&input.buffer);
120121
negotiation::Client::read_kex(
121122
&input.buffer,
122123
&self.config.preferred,
@@ -270,7 +271,9 @@ impl ClientKex {
270271
);
271272

272273
let server_ephemeral = Bytes::decode(r)?;
273-
self.exchange.server_ephemeral.extend_from_slice(&server_ephemeral);
274+
self.exchange
275+
.server_ephemeral
276+
.extend_from_slice(&server_ephemeral);
274277
kex.compute_shared_secret(&self.exchange.server_ephemeral)?;
275278

276279
let mut pubkey_vec = Vec::new();
@@ -288,7 +291,9 @@ impl ClientKex {
288291
let signature = Bytes::decode(r)?;
289292
let signature = Signature::decode(&mut &signature[..])?;
290293

291-
if let Err(e) = signature_next::Verifier::verify(&server_host_key, hash.as_ref(), &signature) {
294+
if let Err(e) =
295+
signature::Verifier::verify(&server_host_key, hash.as_ref(), &signature)
296+
{
292297
debug!("wrong server sig: {e:?}");
293298
return Err(Error::WrongServerSig);
294299
}

0 commit comments

Comments
 (0)