|
@@ -25,6 +25,10 @@ dh_session_t global_session_info;
|
|
|
|
|
|
sgx_dh_session_t sgx_dh_session;
|
|
|
|
|
|
+ uint8_t iv[12];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
uint32_t verify_peer_enclave_trust(sgx_dh_session_enclave_identity_t* peer_enclave_identity, uint8_t* expected_mr_enclave, uint8_t* expected_mr_signer);
|
|
|
|
|
@@ -74,7 +78,7 @@ uint32_t process_protobuf_dh_msg3(protobuf_sgx_dh_msg3_t& protobuf_msg3, uint32_
|
|
|
ret_status = verify_peer_enclave_trust(&responder_identity, NULL, NULL);
|
|
|
if(ret_status != 0)
|
|
|
return ret_status;
|
|
|
-
|
|
|
+ memset(iv, 0, 12);
|
|
|
memcpy(global_session_info.active.AEK, &dh_aek, sizeof(sgx_key_128bit_t));
|
|
|
global_session_info.session_id = 1;
|
|
|
global_session_info.active.counter = 0;
|
|
@@ -83,7 +87,7 @@ uint32_t process_protobuf_dh_msg3(protobuf_sgx_dh_msg3_t& protobuf_msg3, uint32_
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
uint32_t generate_encrypted_rsa_keypair_hash(uint8_t* op_ciphertext, uint8_t* op_encrypted_tag)
|
|
|
{
|
|
|
uint8_t hash[32]; uint32_t return_status;
|
|
@@ -98,32 +102,9 @@ uint32_t generate_encrypted_rsa_keypair_hash(uint8_t* op_ciphertext, uint8_t* op
|
|
|
uint8_t encryption_tag[16];
|
|
|
int ciphertext_len=32;
|
|
|
uint8_t iv[12];
|
|
|
-
|
|
|
- memset(iv, 0, 12);
|
|
|
-
|
|
|
-
|
|
|
+ memset(iv, 0, 12);
|
|
|
return_status=aes_cipher(1, key, iv, hash, 32, op_ciphertext, &ciphertext_len, op_encrypted_tag);
|
|
|
-
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- for(count=0;count<32; count++)
|
|
|
- *(op_ciphertext+count) = ciphertext[count];
|
|
|
-
|
|
|
- for(count=0;count<16;count++)
|
|
|
- *(op_encrypted_tag+count) = encryption_tag[count];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
for(count=0;count<32;count++)
|
|
|
- {
|
|
|
- printf("0x%02x ", hash[count]);
|
|
|
- }
|
|
|
- printf("\n");
|
|
|
- fflush(stdout);
|
|
|
-*/ for(count=0;count<32;count++)
|
|
|
{
|
|
|
printf("0x%02x ", op_ciphertext[count]);
|
|
|
}
|
|
@@ -134,15 +115,37 @@ uint32_t generate_encrypted_rsa_keypair_hash(uint8_t* op_ciphertext, uint8_t* op
|
|
|
printf("0x%02x ", op_encrypted_tag[count]);
|
|
|
}
|
|
|
printf("\n"); fflush(stdout);
|
|
|
-
|
|
|
- {
|
|
|
- printf("0x%02x ", op_ciphertext[count]);
|
|
|
+ return return_status;
|
|
|
+}
|
|
|
+*/
|
|
|
+
|
|
|
+uint32_t decrypt_wrapper(uint8_t* ciphertext, int ciphertext_len, uint8_t* op_plaintext, int* op_plaintext_len, uint8_t* ip_encrypted_tag)
|
|
|
+{
|
|
|
+ uint8_t hash[32]; uint32_t return_status;
|
|
|
+ unsigned char key[16]; uint32_t count;
|
|
|
+ for(count=0;count<16;count++)
|
|
|
+ key[count]=global_session_info.active.AEK[count];
|
|
|
+ printf("Doing decryption\n"); fflush(stdout);
|
|
|
+
|
|
|
+
|
|
|
+ return_status=aes_cipher(0, key, iv, ciphertext, ciphertext_len, op_plaintext, op_plaintext_len, ip_encrypted_tag);
|
|
|
+
|
|
|
+ for(count=0;count<*op_plaintext_len;count++)
|
|
|
+ {
|
|
|
+ printf("0x%02x ", op_plaintext[count]);
|
|
|
+ }
|
|
|
+ printf("\n");
|
|
|
+ fflush(stdout);
|
|
|
+ for(count=0;count<16;count++)
|
|
|
+ {
|
|
|
+ printf("0x%02x ", ip_encrypted_tag[count]);
|
|
|
}
|
|
|
printf("\n"); fflush(stdout);
|
|
|
-*/
|
|
|
- return return_status;
|
|
|
+*/ return return_status;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
uint32_t verify_peer_enclave_trust(sgx_dh_session_enclave_identity_t* peer_enclave_identity, uint8_t* expected_mr_enclave, uint8_t* expected_mr_signer)
|
|
|
{
|