#include "Enclave_t.h" #include "utils.hpp" #include "client.hpp" bool authenticateClient(unsigned char *auth_message, const sgx_aes_gcm_128bit_key_t *ckey) { int auth_success = 0; unsigned long epoch_no = *((unsigned long*) auth_message); auth_message+=(sizeof(unsigned long)); unsigned char computed_auth[SGX_AESGCM_KEY_SIZE]; unsigned char zeroes[SGX_AESGCM_KEY_SIZE] = {0}; unsigned char iv[SGX_AESGCM_IV_SIZE] = {0}; sgx_aes_gcm_128bit_tag_t mac; memcpy(iv, &epoch_no, sizeof(epoch_no)); sgx_status_t ret = SGX_SUCCESS; ret = sgx_rijndael128GCM_encrypt(ckey, zeroes, SGX_AESGCM_KEY_SIZE, computed_auth, iv, SGX_AESGCM_IV_SIZE, NULL, 0, &mac); if(ret!=SGX_SUCCESS) { return false; } auth_success = memcmp(auth_message, computed_auth, SGX_AESGCM_KEY_SIZE); if(auth_success == 0) { return true; } else { printf("authentication FAIL\n"); return false; } }