cryptography rework and beginning of tcp-chat-protocol

This commit is contained in:
2025-10-31 23:19:08 +05:00
parent 42702ffbe7
commit a0bcd2560a
24 changed files with 682 additions and 283 deletions

View File

@@ -1,26 +1,28 @@
#pragma once
#include "cryptography/cryptography.h"
#include "network/EncryptedSocket.h"
#include "cryptography/AES.h"
#include "cryptography/RSA.h"
#include "network/encrypted_sockets.h"
Result(void) client_run();
typedef struct ClientCredential {
str username;
Array(u8) aes_key;
EncryptorAES user_data_aes_enc;
DecryptorAES user_data_aes_dec;
AESBlockEncryptor user_data_aes_enc;
AESBlockDecryptor user_data_aes_dec;
} ClientCredential;
Result(ClientCredential*) ClientCredential_create(str username, str password);
void ClientCredential_free(ClientCredential* cred);
typedef struct ServerConnection {
u64 session_id;
EndpointIPv4 server_end;
br_rsa_public_key server_pk;
EncryptorRSA rsa_enc;
RSAEncryptor rsa_enc;
Array(u8) session_key;
EncryptedSocket system_socket;
EncryptedSocket content_socket;
EncryptedSocketTCP system_socket;
EncryptedSocketTCP content_socket;
} ServerConnection;
Result(ServerConnection*) ServerConnection_open(ClientCredential* client_credential, cstr server_link_cstr);