|
@@ -139,6 +139,16 @@ static inline uint32_t ptMsgBundleSize(uint16_t priv_out, uint16_t msg_size)
|
|
|
return(priv_out * (msg_size + TOKEN_SIZE));
|
|
|
}
|
|
|
|
|
|
+static inline uint32_t encMailboxSize(uint16_t priv_in, uint16_t msg_size)
|
|
|
+{
|
|
|
+ return(SGX_AESGCM_IV_SIZE + (priv_in * msg_size) + SGX_AESGCM_MAC_SIZE);
|
|
|
+}
|
|
|
+
|
|
|
+static inline uint32_t ptMailboxSize(uint16_t priv_in, uint16_t msg_size)
|
|
|
+{
|
|
|
+ return(priv_in * msg_size);
|
|
|
+}
|
|
|
+
|
|
|
bool config_parse(Config &config, const std::string configstr,
|
|
|
std::vector<NodeConfig> &ingestion_nodes,
|
|
|
std::vector<NodeConfig> &storage_nodes,
|
|
@@ -476,7 +486,13 @@ void Client::sendMessageBundle()
|
|
|
|
|
|
boost::asio::async_write(*ingestion_sock,
|
|
|
boost::asio::buffer(send_enc_msgbundle, send_enc_msgbundle_size),
|
|
|
- [this] (boost::system::error_code ecc, std::size_t) {
|
|
|
+ [this, send_enc_msgbundle] (boost::system::error_code ecc, std::size_t) {
|
|
|
+
|
|
|
+#ifdef VERBOSE_CLIENT
|
|
|
+ if(sim_id==0){
|
|
|
+ printf("TEST: Client 0 send their msgbundle\n");
|
|
|
+ }
|
|
|
+#endif
|
|
|
|
|
|
if (ecc) {
|
|
|
if(ecc == boost::asio::error::eof) {
|
|
@@ -489,7 +505,11 @@ void Client::sendMessageBundle()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ free(send_enc_msgbundle);
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
+ free(send_pt_msgbundle);
|
|
|
}
|
|
|
|
|
|
int Client::sendIngAuthMessage(unsigned long epoch_no)
|
|
@@ -663,7 +683,7 @@ void Client::epoch_process() {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
+#ifdef VERBOSE_CLIENT
|
|
|
if(sim_id == 0) {
|
|
|
printf("TEST: Client 0: Encrypted token bundle received:\n");
|
|
|
for(uint32_t i = 0; i < token_bundle_size; i++) {
|
|
@@ -671,22 +691,26 @@ void Client::epoch_process() {
|
|
|
}
|
|
|
printf("\n");
|
|
|
}
|
|
|
- */
|
|
|
+#endif
|
|
|
+
|
|
|
|
|
|
// Decrypt the token bundle
|
|
|
unsigned char *enc_tkn_ptr = enc_tokens + SGX_AESGCM_IV_SIZE;
|
|
|
unsigned char *enc_tkn_tag = enc_tokens + SGX_AESGCM_IV_SIZE + pt_token_size;
|
|
|
|
|
|
+
|
|
|
int decrypted_bytes = gcm_decrypt(enc_tkn_ptr, pt_token_size,
|
|
|
NULL, 0, enc_tkn_tag, (unsigned char*) &(this->stg_key),
|
|
|
enc_tokens, SGX_AESGCM_IV_SIZE, (unsigned char*) (this->token_list));
|
|
|
+
|
|
|
if(decrypted_bytes != pt_token_size) {
|
|
|
- printf("Client::epoch_process gcm_decrypt tokens failed \n");
|
|
|
+ printf("Client::epoch_process gcm_decrypt tokens failed. decrypted_bytes = %d \n", decrypted_bytes);
|
|
|
}
|
|
|
|
|
|
- unsigned char *tkn_ptr = (unsigned char*) this->token_list;
|
|
|
free(enc_tokens);
|
|
|
+
|
|
|
/*
|
|
|
+ unsigned char *tkn_ptr = (unsigned char*) this->token_list;
|
|
|
if(sim_id==0) {
|
|
|
printf("TEST: Client 0: Decrypted client tokens:\n");
|
|
|
for(int i = 0; i < 2 * SGX_AESGCM_KEY_SIZE; i++) {
|
|
@@ -699,14 +723,14 @@ void Client::epoch_process() {
|
|
|
// Async read the messages recieved in the last epoch
|
|
|
uint16_t priv_in = config.m_priv_in;
|
|
|
uint16_t msg_size = config.msg_size;
|
|
|
- uint32_t recv_pt_msgbundle_size = ptMsgBundleSize(priv_in, msg_size);
|
|
|
- uint32_t recv_enc_msgbundle_size = encMsgBundleSize(priv_in, msg_size);
|
|
|
- unsigned char *recv_pt_msgbundle = (unsigned char*) malloc (recv_pt_msgbundle_size);
|
|
|
- unsigned char *recv_enc_msgbundle = (unsigned char*) malloc (recv_enc_msgbundle_size);
|
|
|
+ uint32_t recv_pt_mailbox_size = ptMailboxSize(priv_in, msg_size);
|
|
|
+ uint32_t recv_enc_mailbox_size = encMailboxSize(priv_in, msg_size);
|
|
|
+ unsigned char *recv_pt_mailbox = (unsigned char*) malloc (recv_pt_mailbox_size);
|
|
|
+ unsigned char *recv_enc_mailbox = (unsigned char*) malloc (recv_enc_mailbox_size);
|
|
|
|
|
|
boost::asio::async_read(*storage_sock,
|
|
|
- boost::asio::buffer(recv_enc_msgbundle, recv_enc_msgbundle_size),
|
|
|
- [this, recv_pt_msgbundle, recv_enc_msgbundle]
|
|
|
+ boost::asio::buffer(recv_enc_mailbox, recv_enc_mailbox_size),
|
|
|
+ [this, recv_pt_mailbox, recv_enc_mailbox]
|
|
|
(boost::system::error_code ecc, std::size_t) {
|
|
|
|
|
|
if (ecc) {
|
|
@@ -720,15 +744,20 @@ void Client::epoch_process() {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+#ifdef VERBOSE_CLIENT
|
|
|
+ if(sim_id == 0) {
|
|
|
+ printf("TEST: Client 0: Encrypted msgbundle received\n");
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
// Do whatever processing with the received messages here
|
|
|
- free(recv_enc_msgbundle);
|
|
|
- free(recv_pt_msgbundle);
|
|
|
+ free(recv_enc_mailbox);
|
|
|
+ free(recv_pt_mailbox);
|
|
|
|
|
|
// Send this epoch's message bundle
|
|
|
sendMessageBundle();
|
|
|
+ epoch_process();
|
|
|
});
|
|
|
-
|
|
|
- epoch_process();
|
|
|
});
|
|
|
|
|
|
}
|