|
@@ -60,11 +60,11 @@ int decode_ec256_public_key_from_protobuf(protobuf_sgx_ec256_public_t* protobuf_
|
|
|
temp32 = protobuf_g_a->gx(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(g_a->gx[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ",g_a->gx[counter]);
|
|
|
+ printf("%02x ",g_a->gx[counter]);
|
|
|
temp32 = protobuf_g_a->gy(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(g_a->gy[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ",g_a->gy[counter]);
|
|
|
+ printf("%02x ",g_a->gy[counter]);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -89,16 +89,21 @@ int decode_attributes_from_protobuf(protobuf_sgx_attributes_t* protobuf_attribut
|
|
|
// TODO: private
|
|
|
void encode_report_to_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_report_t* report)
|
|
|
{
|
|
|
+ printf("message 3 ------------------------------------------------------------ \n"); fflush(stdout);
|
|
|
int counter; google::protobuf::uint32 temp32;
|
|
|
+ printf("Key ID\n");
|
|
|
for(counter=0;counter<SGX_KEYID_SIZE;counter++)
|
|
|
{
|
|
|
temp32=report->key_id.id[counter];
|
|
|
+ printf("%02x ", temp32);
|
|
|
protobuf_report->add_key_id(temp32);
|
|
|
}
|
|
|
|
|
|
+ printf("MAC\n");
|
|
|
for(counter=0;counter<SGX_MAC_SIZE;counter++)
|
|
|
{
|
|
|
temp32=report->mac[counter];
|
|
|
+ printf("%02x ", temp32);
|
|
|
protobuf_report->add_mac(temp32);
|
|
|
}
|
|
|
|
|
@@ -137,21 +142,27 @@ void encode_report_to_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repor
|
|
|
protobuf_report->mutable_body()->add_reserved4(temp32);
|
|
|
}
|
|
|
|
|
|
+ printf("\n enclave measurement\n");
|
|
|
for(counter=0;counter<SGX_HASH_SIZE;counter++)
|
|
|
{
|
|
|
temp32=report->body.mr_enclave.m[counter];
|
|
|
+ printf("%02x ", temp32);
|
|
|
protobuf_report->mutable_body()->add_mr_enclave(temp32);
|
|
|
}
|
|
|
|
|
|
+ printf("\n signer measurement\n");
|
|
|
for(counter=0;counter<SGX_HASH_SIZE;counter++)
|
|
|
{
|
|
|
temp32=report->body.mr_signer.m[counter];
|
|
|
+ printf("%02x ", temp32);
|
|
|
protobuf_report->mutable_body()->add_mr_signer(temp32);
|
|
|
}
|
|
|
|
|
|
+ printf("\n report data\n");
|
|
|
for(counter=0;counter<SGX_REPORT_DATA_SIZE;counter++)
|
|
|
{
|
|
|
temp32=report->body.report_data.d[counter];
|
|
|
+ printf("%02x ", temp32);
|
|
|
protobuf_report->mutable_body()->add_report_data(temp32);
|
|
|
}
|
|
|
}
|
|
@@ -161,13 +172,13 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
{
|
|
|
int counter; google::protobuf::uint32 temp32;
|
|
|
|
|
|
- printf("\nreport body keyid\n");
|
|
|
+ printf("\n decoding report body:\n keyid\n");
|
|
|
for(counter=0;counter<SGX_KEYID_SIZE;counter++)
|
|
|
{
|
|
|
temp32=protobuf_report->key_id(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->key_id.id[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->key_id.id[counter]);
|
|
|
+ printf("%02x ", report->key_id.id[counter]);
|
|
|
}
|
|
|
|
|
|
printf("\nreport mac\n");
|
|
@@ -176,19 +187,19 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
temp32=protobuf_report->mac(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->mac[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->mac[counter]);
|
|
|
+ printf("%02x ", report->mac[counter]);
|
|
|
}
|
|
|
|
|
|
report->body.misc_select=protobuf_report->mutable_body()->misc_select(); // 32 bit
|
|
|
temp32=protobuf_report->mutable_body()->isv_svn();
|
|
|
if(fit_32_into_uint16_t(temp32, &(report->body.isv_svn))!=0)
|
|
|
return -1;
|
|
|
- printf("\nmisc select %d \n", report->body.misc_select);
|
|
|
+ printf("\nmisc select %02x \n", report->body.misc_select);
|
|
|
|
|
|
temp32=protobuf_report->mutable_body()->isv_prod_id();
|
|
|
if(fit_32_into_uint16_t(temp32, &(report->body.isv_prod_id))!=0)
|
|
|
return -1;
|
|
|
- printf("\nprod id %d \n", report->body.isv_prod_id);
|
|
|
+ printf("\nprod id %02x \n", report->body.isv_prod_id);
|
|
|
|
|
|
decode_attributes_from_protobuf(protobuf_report->mutable_body()->mutable_attributes(), &(report->body.attributes));
|
|
|
|
|
@@ -198,17 +209,17 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
temp32=protobuf_report->mutable_body()->cpu_svn(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.cpu_svn.svn[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->body.cpu_svn.svn[counter]);
|
|
|
+ printf("%02x ", report->body.cpu_svn.svn[counter]);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+/*
|
|
|
printf("\n reserved1 \n");
|
|
|
for(counter=0;counter<SGX_REPORT_BODY_RESERVED1;counter++)
|
|
|
{
|
|
|
temp32=protobuf_report->mutable_body()->reserved1(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.reserved1[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->body.reserved1[counter]);
|
|
|
+ printf("%02x ", report->body.reserved1[counter]);
|
|
|
}
|
|
|
|
|
|
printf("\n reserved2 \n");
|
|
@@ -217,7 +228,7 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
temp32=protobuf_report->mutable_body()->reserved2(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.reserved2[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->body.reserved2[counter]);
|
|
|
+ printf("%02x ", report->body.reserved2[counter]);
|
|
|
}
|
|
|
|
|
|
printf("\n reserved3 \n");
|
|
@@ -226,7 +237,7 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
temp32=protobuf_report->mutable_body()->reserved3(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.reserved3[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->body.reserved3[counter]);
|
|
|
+ printf("%02x ", report->body.reserved3[counter]);
|
|
|
}
|
|
|
|
|
|
printf("\n reserved4 \n");
|
|
@@ -235,17 +246,17 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
temp32=protobuf_report->mutable_body()->reserved4(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.reserved4[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->body.reserved4[counter]);
|
|
|
+ printf("%02x ", report->body.reserved4[counter]);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+*/
|
|
|
printf("\n mrenclave \n");
|
|
|
for(counter=0;counter<SGX_HASH_SIZE;counter++)
|
|
|
{
|
|
|
temp32=protobuf_report->mutable_body()->mr_enclave(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.mr_enclave.m[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%x ", report->body.mr_enclave.m[counter]);
|
|
|
+ printf("%02x ", report->body.mr_enclave.m[counter]);
|
|
|
}
|
|
|
|
|
|
printf("\n mrsigner \n");
|
|
@@ -254,7 +265,7 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
temp32=protobuf_report->mutable_body()->mr_signer(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.mr_signer.m[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%x ", report->body.mr_signer.m[counter]);
|
|
|
+ printf("%02x ", report->body.mr_signer.m[counter]);
|
|
|
}
|
|
|
|
|
|
printf("\n report data\n");
|
|
@@ -263,7 +274,7 @@ int decode_report_from_protobuf(protobuf_sgx_report_t* protobuf_report, sgx_repo
|
|
|
temp32=protobuf_report->mutable_body()->report_data(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(report->body.report_data.d[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ", report->body.report_data.d[counter]);
|
|
|
+ printf("%02x ", report->body.report_data.d[counter]);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -319,13 +330,14 @@ void encode_msg3_to_protobuf(protobuf_sgx_dh_msg3_t& protobuf_dhmsg3, sgx_dh_msg
|
|
|
int decode_msg2_from_protobuf(protobuf_sgx_dh_msg2_t& protobuf_dhmsg2, sgx_dh_msg2_t* native_dhmsg2)
|
|
|
{
|
|
|
int counter; google::protobuf::uint32 temp32; //google::protobuf::uint64 temp64;
|
|
|
+ printf("RECEIVED the following msg2\n"); fflush(stdout);
|
|
|
printf("\ncmac\n");
|
|
|
for(counter=0;counter<SGX_DH_MAC_SIZE;counter++)
|
|
|
{
|
|
|
temp32=protobuf_dhmsg2.cmac(counter);
|
|
|
if(fit_32_into_uint8_t(temp32, &(native_dhmsg2->cmac[counter]))!=0)
|
|
|
return -1;
|
|
|
- printf("%d ",native_dhmsg2->cmac[counter]);
|
|
|
+ printf("%02x ",native_dhmsg2->cmac[counter]);
|
|
|
}
|
|
|
|
|
|
if(decode_ec256_public_key_from_protobuf(protobuf_dhmsg2.mutable_g_b(), &(native_dhmsg2->g_b)) !=0)
|
|
@@ -340,38 +352,40 @@ int decode_msg2_from_protobuf(protobuf_sgx_dh_msg2_t& protobuf_dhmsg2, sgx_dh_ms
|
|
|
int print_initialized_msg1( protobuf_sgx_dh_msg1_t& protobuf_dhmsg1, sgx_dh_msg1_t* native_dhmsg1)
|
|
|
{
|
|
|
int counter;
|
|
|
+ printf("Printing msg1:\n");
|
|
|
printf("gx\n");
|
|
|
for(counter=0;counter<SGX_ECP256_KEY_SIZE;counter++)
|
|
|
{
|
|
|
- printf("%d ", protobuf_dhmsg1.g_a().gx(counter));
|
|
|
- printf("%d ", native_dhmsg1->g_a.gx[counter]);
|
|
|
+ printf("%02x ", protobuf_dhmsg1.g_a().gx(counter));
|
|
|
+// printf("%02x ", native_dhmsg1->g_a.gx[counter]);
|
|
|
}
|
|
|
printf("\ngy\n");
|
|
|
for(counter=0;counter<SGX_ECP256_KEY_SIZE;counter++)
|
|
|
{
|
|
|
- printf("%d ", protobuf_dhmsg1.g_a().gy(counter));
|
|
|
- printf("%d ", native_dhmsg1->g_a.gy[counter]);
|
|
|
+ printf("%02x ", protobuf_dhmsg1.g_a().gy(counter));
|
|
|
+// printf("%02x ", native_dhmsg1->g_a.gy[counter]);
|
|
|
}
|
|
|
|
|
|
- printf("\nmrenclave in target\n");
|
|
|
+ printf("\nmrenclave for target\n");
|
|
|
for(counter=0;counter<SGX_HASH_SIZE;counter++)
|
|
|
{
|
|
|
- printf("%" PRIu32 " ", protobuf_dhmsg1.target().mr_enclave(counter));
|
|
|
- printf("%d ", native_dhmsg1->target.mr_enclave.m[counter]);
|
|
|
+ printf("%02x ", protobuf_dhmsg1.target().mr_enclave(counter));
|
|
|
+// printf("%02x ", native_dhmsg1->target.mr_enclave.m[counter]);
|
|
|
|
|
|
}
|
|
|
+ /*
|
|
|
printf("\nreserved1 in target\n");
|
|
|
for(counter=0;counter<SGX_TARGET_INFO_RESERVED1_BYTES;counter++)
|
|
|
{
|
|
|
printf("%" PRIu32 " ", protobuf_dhmsg1.target().reserved1(counter));
|
|
|
- printf("%d ", native_dhmsg1->target.reserved1[counter]);
|
|
|
+ printf("%02x ", native_dhmsg1->target.reserved1[counter]);
|
|
|
|
|
|
}
|
|
|
printf("\nreserved2 in target\n");
|
|
|
for(counter=0;counter<SGX_TARGET_INFO_RESERVED2_BYTES;counter++)
|
|
|
{
|
|
|
printf("%" PRIu32 " ", protobuf_dhmsg1.target().reserved2(counter));
|
|
|
- printf("%d ", native_dhmsg1->target.reserved2[counter]);
|
|
|
+ printf("%02x ", native_dhmsg1->target.reserved2[counter]);
|
|
|
}
|
|
|
|
|
|
printf("\n %" PRIu64 "\n", native_dhmsg1->target.attributes.flags);
|
|
@@ -380,6 +394,7 @@ int print_initialized_msg1( protobuf_sgx_dh_msg1_t& protobuf_dhmsg1, sgx_dh_msg1
|
|
|
printf("\n %" PRIu64 "\n", protobuf_dhmsg1.target().attributes().xfrm());
|
|
|
printf("\n %" PRIu32 "\n", native_dhmsg1->target.misc_select);
|
|
|
printf("\n %" PRIu32 "\n", protobuf_dhmsg1.target().misc_select());
|
|
|
-
|
|
|
+ */
|
|
|
+ fflush(stdout);
|
|
|
return 0;
|
|
|
}
|