Add ssh-agent native auth
ci / test (push) Has been cancelled
ci / remote-bench (push) Has been cancelled

This commit is contained in:
DuProcess
2026-06-13 15:21:21 -04:00
parent e7f3679fc1
commit 55a0fc1ab4
5 changed files with 484 additions and 14 deletions
+15 -11
View File
@@ -546,7 +546,7 @@ fn strip_quotes(raw: &str) -> &str {
.unwrap_or(raw)
}
fn parse_ssh_ed25519_public_blob(blob: &[u8]) -> Result<[u8; 32]> {
pub fn parse_ssh_ed25519_public_blob(blob: &[u8]) -> Result<[u8; 32]> {
let mut cursor = blob;
let key_type = read_ssh_string(&mut cursor)?;
anyhow::ensure!(key_type == b"ssh-ed25519", "key blob type mismatch");
@@ -558,6 +558,13 @@ fn parse_ssh_ed25519_public_blob(blob: &[u8]) -> Result<[u8; 32]> {
Ok(out)
}
pub fn ssh_ed25519_public_blob(public_key: &[u8; 32]) -> Vec<u8> {
let mut out = Vec::new();
write_ssh_string(&mut out, b"ssh-ed25519");
write_ssh_string(&mut out, public_key);
out
}
fn read_ssh_string<'a>(cursor: &mut &'a [u8]) -> Result<&'a [u8]> {
anyhow::ensure!(cursor.len() >= 4, "truncated SSH string length");
let len = u32::from_be_bytes(cursor[..4].try_into().unwrap()) as usize;
@@ -568,21 +575,18 @@ fn read_ssh_string<'a>(cursor: &mut &'a [u8]) -> Result<&'a [u8]> {
Ok(value)
}
#[cfg(test)]
fn ssh_ed25519_authorized_key_line(signing_key: &SigningKey) -> String {
let verifying = VerifyingKey::from(signing_key);
let mut blob = Vec::new();
write_ssh_string(&mut blob, b"ssh-ed25519");
write_ssh_string(&mut blob, &verifying.to_bytes());
format!("ssh-ed25519 {} test-key", STANDARD.encode(blob))
}
#[cfg(test)]
fn write_ssh_string(out: &mut Vec<u8>, value: &[u8]) {
out.extend_from_slice(&(value.len() as u32).to_be_bytes());
out.extend_from_slice(value);
}
#[cfg(test)]
fn ssh_ed25519_authorized_key_line(signing_key: &SigningKey) -> String {
let verifying = VerifyingKey::from(signing_key);
let blob = ssh_ed25519_public_blob(&verifying.to_bytes());
format!("ssh-ed25519 {} test-key", STANDARD.encode(blob))
}
pub fn known_host_line(host: &str, key: &HostPublicKey, source: &str, first_seen: u64) -> String {
format!(
"{} {} {} first-seen={} source={}",