feat: v1.9.11, piv meta outputs ssh public key

This commit is contained in:
2024-07-04 22:20:55 +08:00
parent 7287193e49
commit f47a4fc90a
5 changed files with 37 additions and 24 deletions

View File

@@ -18,4 +18,25 @@ pub fn generate_ssh_string(e: &[u8], n: &[u8], comment: &str) -> String {
pub fn append_slice_with_len(v: &mut Vec<u8>, s: &[u8]) {
v.extend_from_slice(&(s.len() as u32).to_be_bytes()[..]);
v.extend_from_slice(s);
}
}
pub trait SshVecWriter {
fn write_bytes(&mut self, bytes: &[u8]) -> ();
fn write_u32(&mut self, num: u32) -> ();
fn write_string(&mut self, bytes: &[u8]) -> ();
}
impl SshVecWriter for Vec<u8> {
fn write_bytes(&mut self, bytes: &[u8]) -> () {
self.extend_from_slice(bytes);
}
fn write_u32(&mut self, num: u32) -> () {
self.write_bytes(&num.to_be_bytes());
}
fn write_string(&mut self, bytes: &[u8]) -> () {
self.write_u32(bytes.len() as u32);
self.write_bytes(bytes);
}
}