#pragma once #include "client.h" #include "cryptography/AES.h" #include "cryptography/RSA.h" #include "network/encrypted_sockets.h" typedef struct ServerConnection ServerConnection; typedef struct Client { str username; Array(u8) user_data_key; Array(u8) token; ServerConnection* server_connection; } Client; typedef struct ServerConnection { EndpointIPv4 server_end; br_rsa_public_key server_pk; RSAEncryptor rsa_enc; u64 session_id; Array(u8) session_key; EncryptedSocketTCP sock; str server_name; str server_description; } ServerConnection; /// @param server_addr_cstr /// @param server_pk_base64 public key encoded by `RSA_serializePublicKey_base64()` Result(ServerConnection*) ServerConnection_open(cstr server_addr_cstr, cstr server_pk_base64); void ServerConnection_close(ServerConnection* conn); /// updates conn->server_name Result(void) ServerConnection_requestServerName(ServerConnection* conn); /// updates conn->server_description Result(void) ServerConnection_requestServerDescription(ServerConnection* conn);