feat: update ssh agent
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -562,6 +562,7 @@ dependencies = [
|
|||||||
"spki 0.7.3",
|
"spki 0.7.3",
|
||||||
"ssh-agent",
|
"ssh-agent",
|
||||||
"ssh-agent-lib",
|
"ssh-agent-lib",
|
||||||
|
"ssh-encoding",
|
||||||
"ssh-key",
|
"ssh-key",
|
||||||
"sshcerts",
|
"sshcerts",
|
||||||
"swift-secure-enclave-tool-rs",
|
"swift-secure-enclave-tool-rs",
|
||||||
|
|||||||
@@ -65,5 +65,6 @@ external-command-rs = "0.1.1"
|
|||||||
ssh-agent-lib = { version = "0.5.1" }
|
ssh-agent-lib = { version = "0.5.1" }
|
||||||
ssh-key = { version = "0.6", features = ["ecdsa"] }
|
ssh-key = { version = "0.6", features = ["ecdsa"] }
|
||||||
tokio = "1.45.1"
|
tokio = "1.45.1"
|
||||||
|
ssh-encoding = { version = "0.2.0", features = ["alloc"] }
|
||||||
#lazy_static = "1.4.0"
|
#lazy_static = "1.4.0"
|
||||||
#ctap-hid-fido2 = "2.1.3"
|
#ctap-hid-fido2 = "2.1.3"
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ use std::path::PathBuf;
|
|||||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||||
|
|
||||||
use crate::ecdsautil::{generate_ecdsa_keypair, EcdsaAlgorithm};
|
use crate::ecdsautil::{generate_ecdsa_keypair, EcdsaAlgorithm};
|
||||||
|
use crate::util::base64_encode;
|
||||||
use rust_util::util_clap::{Command, CommandError};
|
use rust_util::util_clap::{Command, CommandError};
|
||||||
use rust_util::XResult;
|
use rust_util::XResult;
|
||||||
use ssh_agent_lib::agent::{listen, Session};
|
use ssh_agent_lib::agent::{listen, Session};
|
||||||
use ssh_agent_lib::error::AgentError;
|
use ssh_agent_lib::error::AgentError;
|
||||||
use ssh_agent_lib::proto::{Identity, SignRequest};
|
use ssh_agent_lib::proto::{Extension, Identity, SignRequest};
|
||||||
|
use ssh_agent_lib::ssh_encoding::Encode;
|
||||||
use ssh_agent_lib::ssh_key::public::KeyData;
|
use ssh_agent_lib::ssh_key::public::KeyData;
|
||||||
use ssh_agent_lib::ssh_key::{Algorithm, Signature};
|
use ssh_agent_lib::ssh_key::{Algorithm, Signature};
|
||||||
use tokio::net::UnixListener as Listener;
|
use tokio::net::UnixListener as Listener;
|
||||||
@@ -35,12 +37,16 @@ impl Session for MySshAgent {
|
|||||||
debugging!("request_identities");
|
debugging!("request_identities");
|
||||||
// let p256_private_key_d = ecdsautil::parse_p256_private_key(&self.private_key_pem).unwrap();
|
// let p256_private_key_d = ecdsautil::parse_p256_private_key(&self.private_key_pem).unwrap();
|
||||||
let public_key_point = hex::decode("0474b7b8dcac7587afc8c461e96d713d05a4caae9dc4188924697fcb8dec2b8001d337e9ff4da1fb30042fef53375bde0cbe4964c71298b9d56bd9131c347119f3").unwrap();
|
let public_key_point = hex::decode("0474b7b8dcac7587afc8c461e96d713d05a4caae9dc4188924697fcb8dec2b8001d337e9ff4da1fb30042fef53375bde0cbe4964c71298b9d56bd9131c347119f3").unwrap();
|
||||||
Ok(vec![Identity {
|
let identity = Identity {
|
||||||
pubkey: KeyData::Ecdsa(
|
pubkey: KeyData::Ecdsa(
|
||||||
ssh_key::public::EcdsaPublicKey::from_sec1_bytes(&public_key_point).unwrap(),
|
ssh_key::public::EcdsaPublicKey::from_sec1_bytes(&public_key_point).unwrap(),
|
||||||
),
|
),
|
||||||
comment: "".to_string(),
|
comment: "test".to_string(),
|
||||||
}])
|
};
|
||||||
|
let mut writer = vec![];
|
||||||
|
identity.pubkey.encode(&mut writer).unwrap();
|
||||||
|
println!("{}", base64_encode(&writer));
|
||||||
|
Ok(vec![identity])
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn sign(&mut self, request: SignRequest) -> Result<Signature, AgentError> {
|
async fn sign(&mut self, request: SignRequest) -> Result<Signature, AgentError> {
|
||||||
@@ -53,6 +59,11 @@ impl Session for MySshAgent {
|
|||||||
)
|
)
|
||||||
.map_err(AgentError::other)?)
|
.map_err(AgentError::other)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn extension(&mut self, extension: Extension) -> Result<Option<Extension>, AgentError> {
|
||||||
|
debugging!("extension: {:?}", extension);
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CommandImpl;
|
pub struct CommandImpl;
|
||||||
|
|||||||
Reference in New Issue
Block a user