Skip to content

Commit 2a82141

Browse files
committed
Merge branch 'main' into pr/656
2 parents a8b8fba + 0f51860 commit 2a82141

41 files changed

Lines changed: 345 additions & 294 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.all-contributorsrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,24 @@
679679
"contributions": [
680680
"code"
681681
]
682+
},
683+
{
684+
"login": "Mota-Link",
685+
"name": "Mota-Link",
686+
"avatar_url": "https://avatars.githubusercontent.com/u/83714159?v=4",
687+
"profile": "https://github.com/Mota-Link",
688+
"contributions": [
689+
"code"
690+
]
691+
},
692+
{
693+
"login": "mjc",
694+
"name": "Mika Cohen",
695+
"avatar_url": "https://avatars.githubusercontent.com/u/1977?v=4",
696+
"profile": "https://github.com/mjc",
697+
"contributions": [
698+
"code"
699+
]
682700
}
683701
],
684702
"contributorsPerLine": 7,

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ ssh-key = { version = "=0.6.16", features = [
2828
"ppk",
2929
"hazmat-allow-insecure-rsa-keys",
3030
], package = "internal-russh-forked-ssh-key" }
31-
thiserror = "1.0.30"
31+
thiserror = "2.0.18"
3232
tokio = { version = "1.17.0" }
3333
tokio-stream = { version = "0.1.3", features = ["net", "sync"] }

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Russh
22

33
[![Rust](https://github.com/warp-tech/russh/actions/workflows/rust.yml/badge.svg)](https://github.com/warp-tech/russh/actions/workflows/rust.yml) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4-
[![All Contributors](https://img.shields.io/badge/all_contributors-75-orange.svg?style=flat-square)](#contributors-)
4+
[![All Contributors](https://img.shields.io/badge/all_contributors-76-orange.svg?style=flat-square)](#contributors-)
55
<!-- ALL-CONTRIBUTORS-BADGE:END -->
66

77
Low-level Tokio SSH2 client and server implementation.
@@ -227,6 +227,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
227227
<td align="center" valign="top" width="14.28%"><a href="https://cubic-vm.org"><img src="https://avatars.githubusercontent.com/u/155455820?v=4?s=100" width="100px;" alt="Roger Knecht"/><br /><sub><b>Roger Knecht</b></sub></a><br /><a href="https://github.com/Eugeny/russh/commits?author=rogkne" title="Code">💻</a></td>
228228
<td align="center" valign="top" width="14.28%"><a href="https://gui.wf"><img src="https://avatars.githubusercontent.com/u/48162143?v=4?s=100" width="100px;" alt="Guilherme Fontes"/><br /><sub><b>Guilherme Fontes</b></sub></a><br /><a href="https://github.com/Eugeny/russh/commits?author=gui-wf" title="Code">💻</a></td>
229229
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zeroleo12345"><img src="https://avatars.githubusercontent.com/u/13072815?v=4?s=100" width="100px;" alt="Lyn"/><br /><sub><b>Lyn</b></sub></a><br /><a href="https://github.com/Eugeny/russh/commits?author=zeroleo12345" title="Code">💻</a></td>
230+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Mota-Link"><img src="https://avatars.githubusercontent.com/u/83714159?v=4?s=100" width="100px;" alt="Mota-Link"/><br /><sub><b>Mota-Link</b></sub></a><br /><a href="https://github.com/Eugeny/russh/commits?author=Mota-Link" title="Code">💻</a></td>
231+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mjc"><img src="https://avatars.githubusercontent.com/u/1977?v=4?s=100" width="100px;" alt="Mika Cohen"/><br /><sub><b>Mika Cohen</b></sub></a><br /><a href="https://github.com/Eugeny/russh/commits?author=mjc" title="Code">💻</a></td>
230232
</tr>
231233
</tbody>
232234
</table>

cryptovec/src/cryptovec.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Debug;
22
use std::ops::{Deref, DerefMut, Index, IndexMut, Range, RangeFrom, RangeFull, RangeTo};
33

4-
use crate::platform::{self, mlock, munlock};
4+
use crate::platform::{mlock, munlock};
55

66
/// A buffer which zeroes its memory on `.clear()`, `.resize()`, and
77
/// reallocations, to avoid copying secrets around.
@@ -208,10 +208,11 @@ impl CryptoVec {
208208
/// version with zeros.
209209
pub fn resize(&mut self, size: usize) {
210210
if size <= self.capacity && size > self.size {
211-
// If this is an expansion, just resize.
211+
// If this is an expansion within capacity, the memory is already zeroed.
212212
self.size = size
213213
} else if size <= self.size {
214-
// If this is a truncation, resize and erase the extra memory.
214+
// If this is a truncation, securely erase the extra memory.
215+
// Uses zeroize (optimization_barrier) to prevent dead-store elimination.
215216
unsafe {
216217
zeroize(self.p.add(size), self.size - size);
217218
}
@@ -365,7 +366,7 @@ impl Drop for CryptoVec {
365366
if self.capacity > 0 {
366367
unsafe {
367368
zeroize(self.p, self.size);
368-
let _ = platform::munlock(self.p, self.capacity);
369+
let _ = munlock(self.p, self.capacity);
369370
let layout = std::alloc::Layout::from_size_align_unchecked(self.capacity, 1);
370371
std::alloc::dealloc(self.p, layout);
371372
}

russh-config/src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ mod proxy;
2626
pub use proxy::*;
2727

2828
#[derive(Clone, Debug, Default)]
29-
struct HostConfig {
29+
pub struct HostConfig {
3030
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#User
31-
user: Option<String>,
31+
pub user: Option<String>,
3232
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#Hostname
33-
hostname: Option<String>,
33+
pub hostname: Option<String>,
3434
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#Port
35-
port: Option<u16>,
35+
pub port: Option<u16>,
3636
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#IdentityFile
37-
identity_file: Option<Vec<PathBuf>>,
37+
pub identity_file: Option<Vec<PathBuf>>,
3838
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#ProxyCommand
39-
proxy_command: Option<String>,
39+
pub proxy_command: Option<String>,
4040
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#ProxyJump
41-
proxy_jump: Option<String>,
41+
pub proxy_jump: Option<String>,
4242
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#AddKeysToAgent
43-
add_keys_to_agent: Option<AddKeysToAgent>,
43+
pub add_keys_to_agent: Option<AddKeysToAgent>,
4444
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#UserKnownHostsFile
45-
user_known_hosts_file: Option<PathBuf>,
45+
pub user_known_hosts_file: Option<PathBuf>,
4646
/// http://man.openbsd.org/OpenBSD-current/man5/ssh_config.5#StrictHostKeyChecking
47-
strict_host_key_checking: Option<bool>,
47+
pub strict_host_key_checking: Option<bool>,
4848
}
4949

5050
impl HostConfig {
@@ -132,10 +132,10 @@ impl SshConfig {
132132

133133
#[derive(Clone, Debug)]
134134
pub struct Config {
135-
host_name: String,
136-
user: Option<String>,
137-
port: Option<u16>,
138-
host_config: HostConfig,
135+
pub host_name: String,
136+
pub user: Option<String>,
137+
pub port: Option<u16>,
138+
pub host_config: HostConfig,
139139
}
140140

141141
impl Config {

russh/examples/echoserver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct Server {
5252
}
5353

5454
impl Server {
55-
async fn post(&mut self, data: CryptoVec) {
55+
async fn post(&mut self, data: Vec<u8>) {
5656
let mut clients = self.clients.lock().await;
5757
for (id, (channel, s)) in clients.iter_mut() {
5858
if *id != self.id {
@@ -116,7 +116,7 @@ impl server::Handler for Server {
116116
return Err(russh::Error::Disconnect);
117117
}
118118

119-
let data = CryptoVec::from(format!("Got data: {}\r\n", String::from_utf8_lossy(data)));
119+
let data = format!("Got data: {}\r\n", String::from_utf8_lossy(data)).into_bytes();
120120
self.post(data.clone()).await;
121121
session.data(channel, data)?;
122122
Ok(())

russh/examples/ratatui_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl TerminalHandle {
3636
let (sender, mut receiver) = unbounded_channel::<Vec<u8>>();
3737
tokio::spawn(async move {
3838
while let Some(data) = receiver.recv().await {
39-
let result = handle.data(channel_id, data.into()).await;
39+
let result = handle.data(channel_id, data).await;
4040
if result.is_err() {
4141
eprintln!("Failed to send data: {result:?}");
4242
}

russh/examples/ratatui_shared_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl TerminalHandle {
3636
let (sender, mut receiver) = unbounded_channel::<Vec<u8>>();
3737
tokio::spawn(async move {
3838
while let Some(data) = receiver.recv().await {
39-
let result = handle.data(channel_id, data.into()).await;
39+
let result = handle.data(channel_id, data).await;
4040
if result.is_err() {
4141
eprintln!("Failed to send data: {result:?}");
4242
}

russh/examples/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl server::Handler for Server {
9090
{
9191
let mut clients = self.clients.lock().unwrap();
9292
for ((_, _channel_id), ref mut channel) in clients.iter_mut() {
93-
session.data(channel.id(), CryptoVec::from(data.to_vec()))?;
93+
session.data(channel.id(), data.to_vec())?;
9494
}
9595
}
9696
Ok(())

russh/src/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ pub enum CurrentRequest {
235235
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
236236
PublicKey {
237237
#[allow(dead_code)]
238-
key: CryptoVec,
238+
key: Vec<u8>,
239239
#[allow(dead_code)]
240-
algo: CryptoVec,
240+
algo: Vec<u8>,
241241
sent_pk_ok: bool,
242242
},
243243
KeyboardInteractive {

0 commit comments

Comments
 (0)