diff --git a/src/proto/private_key.rs b/src/proto/private_key.rs index ef07a60..cf44124 100644 --- a/src/proto/private_key.rs +++ b/src/proto/private_key.rs @@ -21,6 +21,15 @@ pub struct Ed25519PrivateKey { pub k_enc_a: Vec } +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct SkEd25519PrivateKey { + pub enc_a: Vec, + pub application: String, + pub flags: u8, + pub key_handle: Vec, + pub reserved: Vec +} + #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct RsaPrivateKey { pub n: MpInt, @@ -38,12 +47,24 @@ pub struct EcDsaPrivateKey { pub d: MpInt } +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct SkEcDsaPrivateKey { + pub identifier: String, + pub q: MpInt, + pub application: String, + pub flags: u8, + pub key_handle: Vec, + pub reserved: Vec +} + #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub enum PrivateKey { Dss(DssPrivateKey), Ed25519(Ed25519PrivateKey), + SkEd25519(SkEd25519PrivateKey), Rsa(RsaPrivateKey), - EcDsa(EcDsaPrivateKey) + EcDsa(EcDsaPrivateKey), + SkEcDsa(SkEcDsaPrivateKey) } impl KeyType for RsaPrivateKey { @@ -58,6 +79,10 @@ impl KeyType for Ed25519PrivateKey { const KEY_TYPE: &'static str = "ssh-ed25519"; } +impl KeyType for SkEd25519PrivateKey { + const KEY_TYPE: &'static str = "sk-ssh-ed25519@openssh.com"; +} + impl KeyType for EcDsaPrivateKey { const KEY_TYPE: &'static str = "ecdsa-sha2"; @@ -66,10 +91,20 @@ impl KeyType for EcDsaPrivateKey { } } +impl KeyType for SkEcDsaPrivateKey { + const KEY_TYPE: &'static str = "sk-ecdsa-sha2"; + + fn key_type(&self) -> String { + format!("{}-{}@openssh.com", Self::KEY_TYPE, self.identifier) + } +} + impl_key_type_enum_ser_de!( PrivateKey, (PrivateKey::Dss, DssPrivateKey), (PrivateKey::Rsa, RsaPrivateKey), (PrivateKey::EcDsa, EcDsaPrivateKey), - (PrivateKey::Ed25519, Ed25519PrivateKey) + (PrivateKey::SkEcDsa, SkEcDsaPrivateKey), + (PrivateKey::Ed25519, Ed25519PrivateKey), + (PrivateKey::SkEd25519, SkEd25519PrivateKey) ); diff --git a/src/proto/public_key.rs b/src/proto/public_key.rs index 7c40b36..b386209 100644 --- a/src/proto/public_key.rs +++ b/src/proto/public_key.rs @@ -27,17 +27,32 @@ pub struct EcDsaPublicKey { pub q: MpInt } +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct SkEcDsaPublicKey { + pub identifier: String, + pub q: MpInt, + pub application: String, +} + #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] pub struct Ed25519PublicKey { pub enc_a: Vec } +#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] +pub struct SkEd25519PublicKey { + pub enc_a: Vec, + pub application: String, +} + #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub enum PublicKey { Dss(DssPublicKey), Ed25519(Ed25519PublicKey), + SkEd25519(SkEd25519PublicKey), Rsa(RsaPublicKey), - EcDsa(EcDsaPublicKey) + EcDsa(EcDsaPublicKey), + SkEcDsa(SkEcDsaPublicKey), } impl KeyType for RsaPublicKey { @@ -60,13 +75,27 @@ impl KeyType for EcDsaPublicKey { } } +impl KeyType for SkEd25519PublicKey { + const KEY_TYPE: &'static str = "sk-ssh-ed25519@openssh.com"; +} + +impl KeyType for SkEcDsaPublicKey { + const KEY_TYPE: &'static str = "sk-ecdsa-sha2"; + + fn key_type(&self) -> String { + format!("{}-{}@openssh.com", Self::KEY_TYPE, self.identifier) + } +} + impl From for PublicKey { fn from(key: PrivateKey) -> Self { match key { PrivateKey::Dss(key) => PublicKey::Dss(DssPublicKey::from(key)), PrivateKey::Ed25519(key) => PublicKey::Ed25519(Ed25519PublicKey::from(key)), + PrivateKey::SkEd25519(key) => PublicKey::SkEd25519(SkEd25519PublicKey::from(key)), PrivateKey::Rsa(key) => PublicKey::Rsa(RsaPublicKey::from(key)), PrivateKey::EcDsa(key) => PublicKey::EcDsa(EcDsaPublicKey::from(key)), + PrivateKey::SkEcDsa(key) => PublicKey::SkEcDsa(SkEcDsaPublicKey::from(key)), } } } @@ -100,6 +129,16 @@ impl From for EcDsaPublicKey { } } +impl From for SkEcDsaPublicKey { + fn from(key: SkEcDsaPrivateKey) -> Self { + Self { + identifier: key.identifier, + q: key.q, + application: key.application + } + } +} + impl From for Ed25519PublicKey { fn from(key: Ed25519PrivateKey) -> Self { Self { @@ -108,6 +147,15 @@ impl From for Ed25519PublicKey { } } +impl From for SkEd25519PublicKey { + fn from(key: SkEd25519PrivateKey) -> Self { + Self { + enc_a: key.enc_a, + application: key.application + } + } +} + impl From<&PrivateKey> for PublicKey { fn from(key: &PrivateKey) -> Self { Self::from(key.clone()) @@ -143,7 +191,9 @@ impl_key_type_enum_ser_de!( (PublicKey::Dss, DssPublicKey), (PublicKey::Rsa, RsaPublicKey), (PublicKey::EcDsa, EcDsaPublicKey), - (PublicKey::Ed25519, Ed25519PublicKey) + (PublicKey::SkEcDsa, SkEcDsaPublicKey), + (PublicKey::Ed25519, Ed25519PublicKey), + (PublicKey::SkEd25519, SkEd25519PublicKey) ); diff --git a/src/proto/signature.rs b/src/proto/signature.rs index 0a315c6..d5260e2 100644 --- a/src/proto/signature.rs +++ b/src/proto/signature.rs @@ -15,6 +15,14 @@ pub struct Signature { pub blob: Vec } +#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +pub struct SkSignature { + pub algorithm: String, + pub blob: Vec, + pub flags: u8, + pub counter: u32 +} + #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub struct EcDsaSignature { pub identifier: String,