12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- typedef uint8_t token[SGX_AESGCM_MAC_SIZE];
- typedef uint8_t aes_key[SGX_AESGCM_KEY_SIZE];
- // #define VERBOSE_CLIENT
- /*
- 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};
- boost::asio::ip::tcp::socket *ingestion_sock = NULL;
- void generateAuthenticationMessage();
- 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);
- public:
- Client () {}
- void initClient(clientid_t cid, aes_key ikey, aes_key skey,
- uint16_t num_storage_nodes, std::vector<uint16_t> &storage_map);
- bool socketReady(){
- return(ingestion_sock!=NULL);
- }
- void initializeSocket(boost::asio::io_context &ioc, NodeConfig &ing_server);
- int sendAuthMessage(unsigned long epoch_no);
- void sendMessageBundle(uint16_t priv_out, uint16_t msg_size,
- unsigned char *pt_msgbundle, unsigned char *enc_msgbundle);
- };
|