|
@@ -9,7 +9,7 @@
|
|
|
|
|
|
StgClient *clients;
|
|
|
uint8_t *epoch_tokens;
|
|
|
-uint8_t *epoch_msgbundles;
|
|
|
+uint8_t *epoch_mailboxes;
|
|
|
|
|
|
static struct {
|
|
|
uint32_t max_users;
|
|
@@ -165,21 +165,20 @@ bool generate_all_tokens()
|
|
|
/* processMsgs
|
|
|
- Take all the messages in storage_state.stg_buf
|
|
|
- Encrypt them all with their corresponding client key and IV and store into
|
|
|
- epoch_msgbundles
|
|
|
- - ecall_send_msgbundle();
|
|
|
+ epoch_mailboxes
|
|
|
*/
|
|
|
bool processMsgs() {
|
|
|
- unsigned char *epoch_buf_ptr = epoch_msgbundles;
|
|
|
+ unsigned char *epoch_buf_ptr = epoch_mailboxes;
|
|
|
unsigned char *stg_buf_ptr = storage_state.stg_buf.buf;
|
|
|
- uint32_t msg_bundle_size = g_teems_config.m_priv_in * g_teems_config.msg_size;
|
|
|
- uint32_t enc_msg_bundle_size = msg_bundle_size + SGX_AESGCM_IV_SIZE + SGX_AESGCM_MAC_SIZE;
|
|
|
+ uint32_t mailbox_size = g_teems_config.m_priv_in * g_teems_config.msg_size;
|
|
|
+ uint32_t enc_mailbox_size = mailbox_size + SGX_AESGCM_IV_SIZE + SGX_AESGCM_MAC_SIZE;
|
|
|
sgx_status_t ret = SGX_SUCCESS;
|
|
|
unsigned char *epoch_buf_ct_ptr = epoch_buf_ptr + SGX_AESGCM_IV_SIZE;
|
|
|
- unsigned char *epoch_buf_tag_ptr = epoch_buf_ct_ptr + msg_bundle_size;
|
|
|
+ unsigned char *epoch_buf_tag_ptr = epoch_buf_ct_ptr + mailbox_size;
|
|
|
|
|
|
for(uint32_t lcid = 0; lcid <storage_state.max_users; lcid++) {
|
|
|
memcpy(epoch_buf_ptr, clients[lcid].iv, SGX_AESGCM_IV_SIZE);
|
|
|
- ret = sgx_rijndael128GCM_encrypt(&(clients[lcid].key), stg_buf_ptr, msg_bundle_size,
|
|
|
+ ret = sgx_rijndael128GCM_encrypt(&(clients[lcid].key), stg_buf_ptr, mailbox_size,
|
|
|
(uint8_t*) epoch_buf_ct_ptr, epoch_buf_ptr, SGX_AESGCM_IV_SIZE, NULL, 0,
|
|
|
(sgx_aes_gcm_128bit_tag_t*) epoch_buf_tag_ptr);
|
|
|
if(ret!=SGX_SUCCESS) {
|
|
@@ -198,10 +197,10 @@ bool processMsgs() {
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
- stg_buf_ptr+=msg_bundle_size;
|
|
|
- epoch_buf_ptr+=enc_msg_bundle_size;
|
|
|
- epoch_buf_ct_ptr+=enc_msg_bundle_size;
|
|
|
- epoch_buf_tag_ptr+=enc_msg_bundle_size;
|
|
|
+ stg_buf_ptr+=mailbox_size;
|
|
|
+ epoch_buf_ptr+=enc_mailbox_size;
|
|
|
+ epoch_buf_ct_ptr+=enc_mailbox_size;
|
|
|
+ epoch_buf_tag_ptr+=enc_mailbox_size;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
@@ -229,9 +228,7 @@ bool storage_init(uint32_t max_users, uint32_t msg_buf_size)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- printf("my_stg_pos = %d\n", my_stg_pos);
|
|
|
storage_generateClientKeys(max_users, my_stg_pos);
|
|
|
- // sendClientTokens();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -379,7 +376,7 @@ void storage_received(MsgBuffer &storage_buf)
|
|
|
storage_buf.reset();
|
|
|
pthread_mutex_unlock(&storage_buf.mutex);
|
|
|
|
|
|
- generate_all_tokens();
|
|
|
+ bool ret = generate_all_tokens();
|
|
|
|
|
|
uint32_t num_expected_msgs = g_teems_config.m_priv_in * storage_state.max_users;
|
|
|
processMsgs();
|
|
@@ -395,22 +392,27 @@ void storage_received(MsgBuffer &storage_buf)
|
|
|
|
|
|
bool ecall_storage_authenticate(clientid_t cid, unsigned char *auth_message)
|
|
|
{
|
|
|
+ printf("In ecall_storage_authenticate!\n");
|
|
|
bool ret = false;
|
|
|
uint32_t lcid = cid / g_teems_config.num_storage_nodes;
|
|
|
const sgx_aes_gcm_128bit_key_t *ckey = &(clients[lcid].key);
|
|
|
|
|
|
+ printf("In Enc/Stg::auth: invoked on cid = %d, lcid = %d\n", cid, lcid);
|
|
|
+
|
|
|
ret = authenticateClient(auth_message, ckey);
|
|
|
+ printf("After authenticateClient, ret = %d\n", ret);
|
|
|
|
|
|
if(!ret) {
|
|
|
printf("Storage authentication FAIL\n");
|
|
|
}
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
|
|
|
-void ecall_supply_storage_buffers(unsigned char *msgbundles,
|
|
|
- uint32_t msgbundles_size, unsigned char *tokens, uint32_t tokens_size)
|
|
|
+void ecall_supply_storage_buffers(unsigned char *mailboxes,
|
|
|
+ uint32_t mailboxes_size, unsigned char *tokens, uint32_t tokens_size)
|
|
|
{
|
|
|
- epoch_msgbundles = msgbundles;
|
|
|
+ epoch_mailboxes = mailboxes;
|
|
|
epoch_tokens = tokens;
|
|
|
}
|