diff --git a/src/secure_channel/messages.rs b/src/secure_channel/messages.rs index 5693a5f2..95d07637 100644 --- a/src/secure_channel/messages.rs +++ b/src/secure_channel/messages.rs @@ -28,12 +28,12 @@ pub enum MessageDecodeError { } #[derive(Debug)] -pub struct LoginInitiateMessage { +pub struct InitialMessage { pub public_key: Curve25519PublicKey, pub ciphertext: Vec, } -impl LoginInitiateMessage { +impl InitialMessage { pub fn encode(&self) -> String { let ciphertext = base64_encode(&self.ciphertext); let key = self.public_key.to_base64(); @@ -72,7 +72,7 @@ impl Message { #[derive(Debug, Serialize, Deserialize)] #[serde(untagged)] pub enum SecureChannelMessage { - Initial(LoginInitiateMessage), + Initial(InitialMessage), Normal(Message), } @@ -85,7 +85,7 @@ impl SecureChannelMessage { } pub fn decode(foo: &str) -> Result { - if let Ok(message) = LoginInitiateMessage::decode(foo) { + if let Ok(message) = InitialMessage::decode(foo) { Ok(message.into()) } else { Message::decode(foo).map(Into::into) @@ -99,13 +99,13 @@ impl From for SecureChannelMessage { } } -impl From for SecureChannelMessage { - fn from(value: LoginInitiateMessage) -> Self { +impl From for SecureChannelMessage { + fn from(value: InitialMessage) -> Self { Self::Initial(value) } } -impl Serialize for LoginInitiateMessage { +impl Serialize for InitialMessage { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -116,7 +116,7 @@ impl Serialize for LoginInitiateMessage { } } -impl<'de> Deserialize<'de> for LoginInitiateMessage { +impl<'de> Deserialize<'de> for InitialMessage { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, diff --git a/src/secure_channel/mod.rs b/src/secure_channel/mod.rs index e12a5ad1..d268287d 100644 --- a/src/secure_channel/mod.rs +++ b/src/secure_channel/mod.rs @@ -20,7 +20,7 @@ use thiserror::Error; use x25519_dalek::{EphemeralSecret, SharedSecret}; use zeroize::{Zeroize, ZeroizeOnDrop}; -pub use self::messages::{LoginInitiateMessage, Message, SecureChannelMessage}; +pub use self::messages::{InitialMessage, Message, SecureChannelMessage}; use crate::Curve25519PublicKey; mod messages; @@ -74,7 +74,7 @@ impl SecureChannel { pub fn create_inbound_channel( self, - message: &LoginInitiateMessage, + message: &InitialMessage, ) -> Result { let our_public_key = self.public_key(); @@ -277,7 +277,7 @@ impl EstablishedSecureChannel { if self.initiator && nonce.as_slice() == &[0u8; 12] { // we are Device G, we send the LoginInitiateMessage - LoginInitiateMessage { ciphertext, public_key: self.our_public_key }.into() + InitialMessage { ciphertext, public_key: self.our_public_key }.into() } else { Message { ciphertext }.into() }