Skip to content

Commit

Permalink
added 3des-cbc cipher support
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Aug 5, 2024
1 parent 9b9e145 commit 4eaa080
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This is a fork of [Thrussh](https://nest.pijul.com/pijul/thrussh) by Pierre-Éti
* `aes256-cbc`
* `aes192-cbc`
* `aes128-cbc`
* `3des-cbc`
* Key exchanges:
* `curve25519-sha256@libssh.org`
* `diffie-hellman-group1-sha1`
Expand Down
1 change: 1 addition & 0 deletions russh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ tokio = { workspace = true, features = [
"macros",
"process",
] }
des = "0.8.1"

[dev-dependencies]
anyhow = "1.0"
Expand Down
6 changes: 6 additions & 0 deletions russh/src/cipher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use aes::{Aes128, Aes192, Aes256};
use byteorder::{BigEndian, ByteOrder};
use cbc::CbcWrapper;
use ctr::Ctr128BE;
use des::TdesEde3;
use log::debug;
use once_cell::sync::Lazy;
use tokio::io::{AsyncRead, AsyncReadExt};
Expand Down Expand Up @@ -70,6 +71,8 @@ pub(crate) trait Cipher {

/// `clear`
pub const CLEAR: Name = Name("clear");
/// `3des-cbc`
pub const TRIPLE_DES_CBC: Name = Name("3des-cbc");
/// `aes128-ctr`
pub const AES_128_CTR: Name = Name("aes128-ctr");
/// `aes192-ctr`
Expand All @@ -90,6 +93,7 @@ pub const CHACHA20_POLY1305: Name = Name("chacha20-poly1305@openssh.com");
pub const NONE: Name = Name("none");

static _CLEAR: Clear = Clear {};
static _3DES_CBC: SshBlockCipher<CbcWrapper<TdesEde3>> = SshBlockCipher(PhantomData);
static _AES_128_CTR: SshBlockCipher<Ctr128BE<Aes128>> = SshBlockCipher(PhantomData);
static _AES_192_CTR: SshBlockCipher<Ctr128BE<Aes192>> = SshBlockCipher(PhantomData);
static _AES_256_CTR: SshBlockCipher<Ctr128BE<Aes256>> = SshBlockCipher(PhantomData);
Expand All @@ -102,6 +106,7 @@ static _CHACHA20_POLY1305: SshChacha20Poly1305Cipher = SshChacha20Poly1305Cipher
pub static ALL_CIPHERS: &[&Name] = &[
&CLEAR,
&NONE,
&TRIPLE_DES_CBC,
&AES_128_CTR,
&AES_192_CTR,
&AES_256_CTR,
Expand All @@ -117,6 +122,7 @@ pub(crate) static CIPHERS: Lazy<HashMap<&'static Name, &(dyn Cipher + Send + Syn
let mut h: HashMap<&'static Name, &(dyn Cipher + Send + Sync)> = HashMap::new();
h.insert(&CLEAR, &_CLEAR);
h.insert(&NONE, &_CLEAR);
h.insert(&TRIPLE_DES_CBC, &_3DES_CBC);
h.insert(&AES_128_CTR, &_AES_128_CTR);
h.insert(&AES_192_CTR, &_AES_192_CTR);
h.insert(&AES_256_CTR, &_AES_256_CTR);
Expand Down

0 comments on commit 4eaa080

Please sign in to comment.