Skip to content

Commit

Permalink
Revert "Rename InitialMessage => LoginInitiateMessage to match with d…
Browse files Browse the repository at this point in the history
…escription in MSC4108"

This reverts commit 31b91b2.
  • Loading branch information
hughns committed Apr 19, 2024
1 parent 31b91b2 commit e70d805
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/secure_channel/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ pub enum MessageDecodeError {
}

#[derive(Debug)]
pub struct LoginInitiateMessage {
pub struct InitialMessage {
pub public_key: Curve25519PublicKey,
pub ciphertext: Vec<u8>,
}

impl LoginInitiateMessage {
impl InitialMessage {
pub fn encode(&self) -> String {
let ciphertext = base64_encode(&self.ciphertext);
let key = self.public_key.to_base64();
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Message {
#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SecureChannelMessage {
Initial(LoginInitiateMessage),
Initial(InitialMessage),
Normal(Message),
}

Expand All @@ -85,7 +85,7 @@ impl SecureChannelMessage {
}

pub fn decode(foo: &str) -> Result<Self, MessageDecodeError> {
if let Ok(message) = LoginInitiateMessage::decode(foo) {
if let Ok(message) = InitialMessage::decode(foo) {
Ok(message.into())
} else {
Message::decode(foo).map(Into::into)
Expand All @@ -99,13 +99,13 @@ impl From<Message> for SecureChannelMessage {
}
}

impl From<LoginInitiateMessage> for SecureChannelMessage {
fn from(value: LoginInitiateMessage) -> Self {
impl From<InitialMessage> for SecureChannelMessage {
fn from(value: InitialMessage) -> Self {
Self::Initial(value)
}
}

impl Serialize for LoginInitiateMessage {
impl Serialize for InitialMessage {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -116,7 +116,7 @@ impl Serialize for LoginInitiateMessage {
}
}

impl<'de> Deserialize<'de> for LoginInitiateMessage {
impl<'de> Deserialize<'de> for InitialMessage {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
Expand Down
6 changes: 3 additions & 3 deletions src/secure_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,7 +74,7 @@ impl SecureChannel {

pub fn create_inbound_channel(
self,
message: &LoginInitiateMessage,
message: &InitialMessage,
) -> Result<ChannelCreationResult, SecureChannelError> {
let our_public_key = self.public_key();

Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit e70d805

Please sign in to comment.