more progress :D

This commit is contained in:
Rusty Striker 2024-12-17 20:41:30 +02:00
parent d49131bc67
commit c4524fb62e
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
6 changed files with 210 additions and 51 deletions

View file

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

View file

@ -3,8 +3,31 @@
public enum RequestType {
Register = 1,
ConfirmRegister = 2,
GetMessages = 3,
GetUserKey = 4,
SendMessage = 5,
SendAck = 6
Login = 3,
GetMessages = 4,
GetUserKey = 5,
SendMessage = 6,
}
public static class Request {
public static byte[] CreateRequest(RequestType Type, ref byte counter, byte[] data) {
if(data.Length > 13) {
throw new Exception("extra data is too long");
}
byte[] msg = new byte[128];
msg[0] = 0; // version
msg[1] = (byte)Type;
msg[2] = counter;
if(counter == byte.MaxValue) {
counter = 0;
}
else {
counter += 1;
}
// insert data 3..16
Array.Copy(data, 0, msg, 3, data.Length);
return msg;
}
}