mirror of
https://github.com/Noratrieb/cluelessh.git
synced 2026-01-14 16:35:06 +01:00
cleanup
This commit is contained in:
parent
b6d0675976
commit
b0acf03502
22 changed files with 84 additions and 26 deletions
|
|
@ -4,7 +4,10 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
eyre = "0.6.12"
|
||||
eyre.workspace = true
|
||||
cluelessh-transport = { path = "../cluelessh-transport" }
|
||||
tokio = { version = "1.39.3", features = ["net"] }
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl Request {
|
|||
} => {
|
||||
p.u8(numbers::SSH_AGENTC_ADD_IDENTITY);
|
||||
p.string(key_type.as_bytes());
|
||||
p.raw(&key_contents);
|
||||
p.raw(key_contents);
|
||||
p.string(key_comment.as_bytes());
|
||||
}
|
||||
Self::RemoveAllIdentities => p.u8(numbers::SSH_AGENTC_REMOVE_ALL_IDENTITIES),
|
||||
|
|
@ -56,8 +56,8 @@ impl Request {
|
|||
flags,
|
||||
} => {
|
||||
p.u8(numbers::SSH_AGENTC_SIGN_REQUEST);
|
||||
p.string(&key_blob);
|
||||
p.string(&data);
|
||||
p.string(key_blob);
|
||||
p.string(data);
|
||||
p.u32(*flags);
|
||||
}
|
||||
Self::Lock { passphrase } => {
|
||||
|
|
@ -186,7 +186,7 @@ impl AgentConnection {
|
|||
mut bytes: &'a [u8],
|
||||
) -> impl Iterator<Item = eyre::Result<ServerResponse>> + 'a {
|
||||
std::iter::from_fn(move || -> Option<eyre::Result<ServerResponse>> {
|
||||
if bytes.len() == 0 {
|
||||
if bytes.is_empty() {
|
||||
return None;
|
||||
}
|
||||
match self.packets.recv_plaintext_bytes(bytes) {
|
||||
|
|
|
|||
|
|
@ -9,3 +9,6 @@ tracing.workspace = true
|
|||
|
||||
[dev-dependencies]
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -11,3 +11,6 @@ ed25519-dalek = { version = "2.1.1", features = ["rand_core"] }
|
|||
pem = "3.0.4"
|
||||
rand = "0.8.5"
|
||||
cluelessh-transport = { path = "../cluelessh-transport" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -92,12 +92,12 @@ impl EncryptedPrivateKeys {
|
|||
p.array(*MAGIC);
|
||||
p.string(self.cipher.name().as_bytes());
|
||||
p.string(self.kdf.name().as_bytes());
|
||||
p.string(&self.kdf.options());
|
||||
p.string(self.kdf.options());
|
||||
|
||||
p.u32(self.public_keys.len() as u32);
|
||||
|
||||
for pubkey in &self.public_keys {
|
||||
p.string(&pubkey.to_wire_encoding());
|
||||
p.string(pubkey.to_wire_encoding());
|
||||
}
|
||||
|
||||
p.string(&self.encrypted_private_keys);
|
||||
|
|
@ -124,7 +124,7 @@ impl EncryptedPrivateKeys {
|
|||
let mut output = vec![0; key_size + iv_size];
|
||||
self.kdf.derive(passphrase, &mut output)?;
|
||||
let (key, iv) = output.split_at(key_size);
|
||||
self.cipher.crypt_in_place(&mut data, &key, &iv);
|
||||
self.cipher.crypt_in_place(&mut data, key, iv);
|
||||
}
|
||||
Ok(data)
|
||||
}
|
||||
|
|
@ -254,12 +254,12 @@ impl PlaintextPrivateKey {
|
|||
} => {
|
||||
// <https://datatracker.ietf.org/doc/html/draft-miller-ssh-agent#section-3.2.3>
|
||||
enc.string(b"ssh-ed25519");
|
||||
enc.string(&public_key);
|
||||
enc.string(public_key);
|
||||
let combined = private_key.len() + public_key.len();
|
||||
enc.u32(combined as u32);
|
||||
enc.raw(&private_key);
|
||||
enc.raw(&public_key);
|
||||
enc.string(&self.comment.as_bytes());
|
||||
enc.string(self.comment.as_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ impl PlaintextPrivateKey {
|
|||
let (key, iv) = output.split_at(key_size);
|
||||
params
|
||||
.cipher
|
||||
.crypt_in_place(&mut encrypted_private_keys, &key, &iv);
|
||||
.crypt_in_place(&mut encrypted_private_keys, key, iv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,3 +9,5 @@ cluelessh-connection = { path = "../cluelessh-connection" }
|
|||
cluelessh-transport = { path = "../cluelessh-transport" }
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -4,10 +4,13 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
eyre = "0.6.12"
|
||||
eyre.workspace = true
|
||||
cluelessh-transport = { path = "../cluelessh-transport" }
|
||||
cluelessh-connection = { path = "../cluelessh-connection" }
|
||||
cluelessh-protocol = { path = "../cluelessh-protocol" }
|
||||
tokio = { version = "1.39.3", features = ["net"] }
|
||||
tracing.workspace = true
|
||||
futures = "0.3.30"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::{collections::HashMap, pin::Pin, sync::Arc};
|
|||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
|
||||
use cluelessh_protocol::{ChannelUpdateKind, SshStatus};
|
||||
use eyre::{bail, ContextCompat, OptionExt, Result, WrapErr};
|
||||
use eyre::{bail, ContextCompat, Result, WrapErr};
|
||||
use futures::future::BoxFuture;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
use tracing::{debug, info, warn};
|
||||
|
|
|
|||
|
|
@ -22,3 +22,6 @@ base64 = "0.22.1"
|
|||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.4.1"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ pub fn hostkey_ed25519(hostkey_private: Vec<u8>) -> HostKeySigningAlgorithm {
|
|||
// <https://datatracker.ietf.org/doc/html/rfc8709#section-6>
|
||||
let mut data = Writer::new();
|
||||
data.string(b"ssh-ed25519");
|
||||
data.string(&signature.to_bytes());
|
||||
data.string(signature.to_bytes());
|
||||
EncodedSshSignature(data.finish())
|
||||
},
|
||||
verify: |public_key, message, signature| {
|
||||
|
|
@ -216,7 +216,7 @@ pub fn hostkey_ecdsa_sha2_p256(hostkey_private: Vec<u8>) -> HostKeySigningAlgori
|
|||
let mut signature_blob = Writer::new();
|
||||
signature_blob.mpint(p256::U256::from(r.as_ref()));
|
||||
signature_blob.mpint(p256::U256::from(s.as_ref()));
|
||||
data.string(&signature_blob.finish());
|
||||
data.string(signature_blob.finish());
|
||||
EncodedSshSignature(data.finish())
|
||||
},
|
||||
verify: |_public_key, _message, _signature| todo!("ecdsa p256 verification"),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
pub fn remaining(&self) -> &[u8] {
|
||||
&self.0
|
||||
self.0
|
||||
}
|
||||
|
||||
pub fn has_data(&self) -> bool {
|
||||
|
|
|
|||
|
|
@ -99,6 +99,26 @@ impl ServerConnection {
|
|||
|
||||
return Err(SshStatus::Disconnect);
|
||||
}
|
||||
Some(numbers::SSH_MSG_IGNORE) => {
|
||||
// <https://datatracker.ietf.org/doc/html/rfc4253#section-11.2>
|
||||
let mut p = Parser::new(&packet.payload[1..]);
|
||||
let _ = p.string()?;
|
||||
continue;
|
||||
}
|
||||
Some(numbers::SSH_MSG_DEBUG) => {
|
||||
// <https://datatracker.ietf.org/doc/html/rfc4253#section-11.3>
|
||||
let mut p = Parser::new(&packet.payload[1..]);
|
||||
let always_display = p.bool()?;
|
||||
let msg = p.utf8_string()?;
|
||||
let _language_tag = p.utf8_string()?;
|
||||
|
||||
if always_display {
|
||||
info!(%msg, "Received debug message (SSH_MSG_DEBUG)");
|
||||
} else {
|
||||
debug!(%msg, "Received debug message (SSH_MSG_DEBUG)")
|
||||
}
|
||||
continue;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue