From 5ee02573e1cc40b8cf69d101038028f36a2f64ec Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Tue, 14 Mar 2023 23:58:29 -0400 Subject: [PATCH] work on palmdef --- .gitignore | 1 + .idea/.gitignore | 8 +++++++ .idea/misc.xml | 6 +++++ .idea/modules.xml | 8 +++++++ .idea/palm.iml | 11 +++++++++ .idea/vcs.xml | 6 +++++ Cargo.lock | 7 ++++++ Cargo.toml | 8 +++++++ palmdef/palmdef.proto | 56 +++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 3 +++ 10 files changed, 114 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/palm.iml create mode 100644 .idea/vcs.xml create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 palmdef/palmdef.proto create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3ce3588 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b0c0509 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/palm.iml b/.idea/palm.iml new file mode 100644 index 0000000..c254557 --- /dev/null +++ b/.idea/palm.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..e1586a4 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "palm" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..72f9b34 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "palm" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/palmdef/palmdef.proto b/palmdef/palmdef.proto new file mode 100644 index 0000000..e240fbc --- /dev/null +++ b/palmdef/palmdef.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; + +/* + There are four types of messages that palm can send. + 1. Unencrypted reflection. This is unencrypted communication between a relay and a client. + 2. Encrypted reflection. This is encrypted communication between a relay and a client. + 3. Unencrypted tunnel. This is unencrypted communication between a client and a client, through a relay. Note that it is encrypted both ways via encrypted reflection. + 4. Encrypted tunnel. This is doubly-encrypted communcation between a client and a client, through a relay. + + The following convention is used: + C2R Client to Relay - Reflection + R2C Relay to Client - Reflection + I2R Initiating Client to Receiving Client - Tunneled + R2I Receiving Client to Initiating Client - Tunneled + */ + +/////// UNENCRYPTED REFLECTION /////// + +// Sent by client at start of connection +message PalmC2RHandshakeStart { + bytes ClientPublicKey = 1; // 32-byte X25519 public key + bytes SessionIV = 2; // 12-byte randomized IV generated by the client + bytes Check = 3; // 32-byte randomized value used to check encryption +} + +// Sent by relay in response to PalmC2RHandshakeStart +message PalmR2CHandshakeFinish { + bytes ServerPublicKey = 1; // 32-byte X25519 public key + bytes Check = 2; // The same 32-byte value provided in PalmC2SHandshakeStart, used to tie this response to the original session +} + +/////// ENCRYPTED REFLECTED MESSAGES /////// + +// Sent by client after receiving PalmR2CHandshakeFinish. +// Used by the client to request a room on the server. +message PalmC2RRelayRequest { + bytes Check = 1; // The same 32-byte value used in initial reflected handshake, ties this to the session. + string ChannelID = 2; // The string channel ID this client is requested to be routed to. +} + +// Represents the states a room/channel can be in. +enum PalmRoomStatus { + NotReady = 0; // Waiting for a peer to join + Ready = 1; // A peer has joined, and the relay is ready to relay the connection + InUse = 2; // This channel is already in use and cannot be used currently +} + +// Send at *any time* by the server to indicate the current status of the server. +// Must also be sent in response to PalmC2RRelayRequest to indicate the current status of the room. +// If the other peer is disconnected, PalmR2CChannelStatus will be sent again with Status = NotReady; +// The client must handle this correctly. +message PalmR2CChannelStatus { + bytes Check = 1; // The same 32-byte value used in previous packets, ties this packet to the session. + string ChannelID = 2; // The channel that the client requested. + PalmRoomStatus Status = 3; // The current status of the room. +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}