Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/kex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const marker_only_kexs: &[&str] = &[

const fixed_options_hostsig: &[&str] = &[
SSH_NAME_ED25519,
#[cfg(feature = "ecdsa256")]
SSH_NAME_ECDSA256,
#[cfg(feature = "rsa")]
SSH_NAME_RSA_SHA256,
];
Expand Down Expand Up @@ -1280,11 +1282,23 @@ mod tests {
#[test]
fn test_each_kex() {
for name in fixed_options_kex {
test_kex_allow(name)
test_kex_allow(name, SSH_NAME_ED25519, crate::KeyType::Ed25519);
}
}

fn test_kex_allow(chosen_kex: &'static str) {
#[cfg(feature = "ecdsa256")]
#[test]
fn test_p256_hostkey() {
for name in fixed_options_kex {
test_kex_allow(name, SSH_NAME_ECDSA256, crate::KeyType::ECDSA256);
}
}

fn test_kex_allow(
chosen_kex: &'static str,
chosen_hostsig: &'static str,
key_type: crate::KeyType,
) {
// #![allow(unused)]
init_test_log();
let mut cli_conf = kex::AlgoConfig::new(true);
Expand All @@ -1293,15 +1307,16 @@ mod tests {
// Use the tested kex algorithm
cli_conf.kexs = LocalNames::new();
cli_conf.kexs.0.push(chosen_kex).unwrap();
cli_conf.hostsig = LocalNames::new();
cli_conf.hostsig.0.push(chosen_hostsig).unwrap();

// needs to be hardcoded because that's what we send.
let mut s = Vec::from(crate::ident::OUR_VERSION);
s.extend_from_slice(b"\r\n");
let mut version = RemoteVersion::new(true);
version.consume(s.as_slice()).unwrap();

let keys =
[crate::SignKey::generate(crate::KeyType::Ed25519, None).unwrap()];
let keys = [crate::SignKey::generate(key_type, None).unwrap()];
let keys: Vec<&SignKey> = keys.iter().collect();

let mut ts = TrafCatcher::new();
Expand Down