123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- typedef uint8_t token[SGX_AESGCM_MAC_SIZE];
- typedef uint8_t aes_key[SGX_AESGCM_KEY_SIZE];
- // #define VERBOSE_CLIENT
- // #define RANDOMIZE_CLIENT_RETRY_SLEEP_TIME
- #define CLIENT_UNIQUE_IP
- #define PORT_START 32768
- #define PORT_END 65534
- /*
- Client -> Ingestion Server (C->I) communication protocols:
- 1) Authentication
- Format: Client sim_id, Epoch number, Authentication token
- 2) Messages
- Format: IV, AESGCM([CM_1], [CM_2], ..., [CM_k]), TAG
- - each CM = Client Message for private channel has the format :
- 4-byte Sender ID, 4-byte Recipient ID, 16-byte Token,
- <Upto msg_size - 24> - bytes of message data
- where the Sender ID and Recipient ID are the TEEMS client id
- (and not sim_id)
- */
- /*
- Structure for capture each individual simulated client's state
- */
- class Client
- {
- private:
- // Clients' have a simulator ID sim_id used for:
- // (i) the simulator to divvy up clients across threads
- // (ii) the simulator and ingestion servers to align simulated clients
- // and their pre-established shared-secrets
- clientid_t sim_id;
- // The actual client id used by TEEMS is id.
- // Format: the first DEST_STORAGE_NODE_BITS bits store the storage node
- // number and the userid at that storage node in the last DEST_UID_BITS
- clientid_t id;
- aes_key ing_key;
- aes_key stg_key;
- // Clients send encrypted messages to ingestion
- // so they set and increment the IV
- unsigned char ing_iv[SGX_AESGCM_IV_SIZE] = {0};
- token *token_list;
- boost::asio::ip::tcp::socket *ingestion_sock = NULL;
- boost::asio::ip::tcp::socket *storage_sock = NULL;
- void generateAuthenticationMessage();
- int sendIngAuthMessage(unsigned long epoch_no);
- int sendStgAuthMessage(unsigned long epoch_no);
- void generateMessageBundle(uint8_t priv_out, uint32_t msg_size,
- unsigned char *pt_msgbundle);
- bool encryptMessageBundle(uint32_t bundle_size, unsigned char *pt_msgbundle,
- unsigned char* enc_msgbundle);
- void sendMessageBundle();
- void initializeIngSocket(boost::asio::io_context &ioc, NodeConfig &ing_server,
- std::string raw_ip_addr, uint16_t &port_no);
- void initializeStgSocket(boost::asio::io_context &ioc, NodeConfig &ing_server,
- std::string raw_ip_addr, uint16_t &port_no);
- void initClient(clientid_t cid, uint16_t stg_id, aes_key ikey, aes_key skey);
- public:
- Client() {}
- ~Client() {
- free(token_list);
- delete(ingestion_sock);
- delete(storage_sock);
- }
- void setup_client(boost::asio::io_context &ioc, uint32_t sim_id,
- uint16_t ing_node_id, uint16_t stg_node_id, std::string, uint16_t pno);
- void epoch_process();
- };
|