I DID PROGRESS!
This commit is contained in:
parent
4119a1bbcd
commit
253fdd2a40
6 changed files with 51 additions and 7 deletions
13
README.md
13
README.md
|
@ -9,3 +9,16 @@
|
||||||
[ ] Refine protocol using the implementation (and update stuff that got changed in impl)
|
[ ] Refine protocol using the implementation (and update stuff that got changed in impl)
|
||||||
[ ] Finish implementing the protocol
|
[ ] Finish implementing the protocol
|
||||||
[ ] Update the protocol file with the latest structs and stuff
|
[ ] Update the protocol file with the latest structs and stuff
|
||||||
|
|
||||||
|
## Protocol todo:
|
||||||
|
|
||||||
|
[ ] Figure out how a message and message ack payload will look
|
||||||
|
[ ] Figure out server responses (hopefully manages to be stuck in a 512 bit block as well)
|
||||||
|
|
||||||
|
|
||||||
|
## client todo:
|
||||||
|
|
||||||
|
[ ] Check for key when turned on
|
||||||
|
[ ] generate key and register if no key is preset, and save it after registration is done
|
||||||
|
[ ] if key is present, start by getting messages (which makes sure we are signed in)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Client;
|
namespace Client;
|
||||||
|
|
||||||
|
@ -9,6 +11,10 @@ public class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
RSA key = RSA.Create(512);
|
||||||
|
Console.WriteLine($"key: {key.ExportRSAPrivateKey().Length}");
|
||||||
|
Console.WriteLine(key.ExportRSAPublicKeyPem());
|
||||||
using TcpClient client = new("127.0.0.1", 12345);
|
using TcpClient client = new("127.0.0.1", 12345);
|
||||||
|
|
||||||
byte[] toSend = Encoding.ASCII.GetBytes("hello server");
|
byte[] toSend = Encoding.ASCII.GetBytes("hello server");
|
||||||
|
@ -29,6 +35,15 @@ public class Program
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if(input.StartsWith('/')) {
|
||||||
|
// Commands :D, i like commands
|
||||||
|
switch(input.ToLower()) {
|
||||||
|
case "/quit":
|
||||||
|
case "/exit":
|
||||||
|
case "/q!":
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
stream.Write(Encoding.ASCII.GetBytes(input));
|
stream.Write(Encoding.ASCII.GetBytes(input));
|
||||||
Console.WriteLine($"[{DateTime.Now}]Sent to server: {input}");
|
Console.WriteLine($"[{DateTime.Now}]Sent to server: {input}");
|
||||||
|
@ -42,7 +57,7 @@ public class Program
|
||||||
int readLen = await stream.ReadAsync(buffer);
|
int readLen = await stream.ReadAsync(buffer);
|
||||||
if(readLen != 0) {
|
if(readLen != 0) {
|
||||||
string fromServer = Encoding.ASCII.GetString(buffer[..readLen]);
|
string fromServer = Encoding.ASCII.GetString(buffer[..readLen]);
|
||||||
Console.WriteLine($"[{DateTime.Now}]\t\tFrom server: {fromServer}");
|
Console.WriteLine($"[{DateTime.Now}] From server: {fromServer}");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\lib\lib.csproj"/>
|
<ProjectReference Include="..\lib\lib.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Cryptography" Version="1.0.0"/>
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
11
lib/Crypto.cs
Normal file
11
lib/Crypto.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace lib;
|
||||||
|
|
||||||
|
public static class Crypto {
|
||||||
|
public static RSA GenerateKey() {
|
||||||
|
return RSA.Create(512);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Cryptography" Version="1.0.0"/>
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
|
|
@ -76,7 +76,9 @@ I think it all can go into a:
|
||||||
```
|
```
|
||||||
and we can just append encrypted payloads to it (in SendMessage and SendAck)
|
and we can just append encrypted payloads to it (in SendMessage and SendAck)
|
||||||
|
|
||||||
To each message we also append a sha3-256 signed hash
|
To each message we also append a sha3-256 signed hash, this shit really feels like overkill and im not sure about it,
|
||||||
|
on the other i do want to have a bigger key size and 512 seems like an okay-ish thing to have, as 256 is short and 1024 is
|
||||||
|
amusingly long for the amount of data the server needs to encrypt
|
||||||
|
|
||||||
enc_server( request - 256 bits, signed sha3-256 )
|
enc_server( request - 256 bits, signed sha3-256 )
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue