I DID PROGRESS!

This commit is contained in:
Rusty Striker 2024-12-14 19:10:09 +02:00
parent 4119a1bbcd
commit 253fdd2a40
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
6 changed files with 51 additions and 7 deletions

View file

@ -9,3 +9,16 @@
[ ] Refine protocol using the implementation (and update stuff that got changed in impl)
[ ] Finish implementing the protocol
[ ] 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)

View file

@ -2,6 +2,8 @@
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Linq;
namespace Client;
@ -9,6 +11,10 @@ public class Program
{
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);
byte[] toSend = Encoding.ASCII.GetBytes("hello server");
@ -29,6 +35,15 @@ public class Program
await Task.Delay(100);
continue;
}
else if(input.StartsWith('/')) {
// Commands :D, i like commands
switch(input.ToLower()) {
case "/quit":
case "/exit":
case "/q!":
return;
}
}
else {
stream.Write(Encoding.ASCII.GetBytes(input));
Console.WriteLine($"[{DateTime.Now}]Sent to server: {input}");
@ -42,7 +57,7 @@ public class Program
int readLen = await stream.ReadAsync(buffer);
if(readLen != 0) {
string fromServer = Encoding.ASCII.GetString(buffer[..readLen]);
Console.WriteLine($"[{DateTime.Now}]\t\tFrom server: {fromServer}");
Console.WriteLine($"[{DateTime.Now}] From server: {fromServer}");
}
}

View file

@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\lib\lib.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Cryptography" Version="1.0.0"/>
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

11
lib/Crypto.cs Normal file
View file

@ -0,0 +1,11 @@
using System.Security.Cryptography;
namespace lib;
public static class Crypto {
public static RSA GenerateKey() {
return RSA.Create(512);
}
}

View file

@ -1,5 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Cryptography" Version="1.0.0"/>
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>

View file

@ -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)
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 )