diff --git a/radicle-crypto/src/ssh.rs b/radicle-crypto/src/ssh.rs index d0d8c778..b051bf3b 100644 --- a/radicle-crypto/src/ssh.rs +++ b/radicle-crypto/src/ssh.rs @@ -227,6 +227,12 @@ pub struct ExtendedSignature { signature: crypto::Signature, } +impl From for (crypto::PublicKey, crypto::Signature) { + fn from(ex: ExtendedSignature) -> Self { + (ex.public_key, ex.signature) + } +} + impl Encodable for ExtendedSignature { type Error = ExtendedSignatureError; @@ -263,6 +269,17 @@ impl ExtendedSignature { const ARMORED_WIDTH: usize = 70; const MAGIC_PREAMBLE: &[u8] = b"SSHSIG"; + pub fn new(public_key: crypto::PublicKey, signature: crypto::Signature) -> Self { + Self { + version: 1, + public_key, + namespace: b"radicle".to_vec(), + reserved: b"".to_vec(), + hash_algorithm: b"sha256".to_vec(), + signature, + } + } + pub fn from_armored(s: &[u8]) -> Result { let s = s .strip_prefix(Self::ARMORED_HEADER)