sgx_status_t ECALL_put_secret_data(
sgx_ra_context_t context,
uint8_t *p_secret,
uint32_t secret_size,
uint8_t *p_gcm_mac,
uint32_t provisioner_type)
{
sgx_status_t ret = SGX_SUCCESS;
uint32_t i;
uint8_t aes_gcm_iv[12] = {0};
do {
if(provisioner_type == 1) // DataConsumer
{
ret = sgx_ra_get_keys(context, SGX_RA_KEY_SK, &sk_key_DC);
if(SGX_SUCCESS != ret)
{
printf("[ENCLAVE] Get keys failed.\n");
break;
}
ret = sgx_rijndael128GCM_decrypt(&sk_key_DC,
p_secret,
secret_size,
&g_secret_DC[0],
&aes_gcm_iv[0],
12,
NULL,
0,
(const sgx_aes_gcm_128bit_tag_t *)(p_gcm_mac));
if (ret != SGX_SUCCESS)
{
printf("[ENCLAVE] 128GCM decrypt failed\n");
}
// ------------------------------------------------------------------!!! INFORMATION LEAK HERE!!!
printf("\n[ENCLAVE] DataConsumer's secret is:\n");
for(i=0;i<secret_size;i++)
{
printf("0x%02X ", g_secret_DC[i]);
}
printf("\n");
}
else // iDataAgent
{
ret = sgx_ra_get_keys(context, SGX_RA_KEY_SK, &sk_key_iDA);
if(SGX_SUCCESS != ret)
{
printf("[ENCLAVE] Get keys failed.\n");
break;
}
ret = sgx_rijndael128GCM_decrypt(&sk_key_iDA,
p_secret,
secret_size,
&g_secret_iDA[0],
&aes_gcm_iv[0],
12,
NULL,
0,
(const sgx_aes_gcm_128bit_tag_t *)(p_gcm_mac));
// ------------------------------------------------------------------!!! INFORMATION LEAK HERE!!!
printf("\n[ENCLAVE] DataOwner's data key is:\n");
for(i=0;i<secret_size;i++)
{
printf("0x%02X ", g_secret_iDA[i]);
}
printf("\n");
}
// Once the server has the shared secret, it should be sealed to
// persistent storage for future use. This will prevents having to
// perform remote attestation until the secret goes stale. Once the
// enclave is created again, the secret can be unsealed.
} while(0);
return ret;
}