12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include "../Decryptor/Decryptor_u.h"
- #include "sgx_eid.h"
- #include "sgx_urts.h"
- #define __STDC_FORMAT_MACROS
- #include <inttypes.h>
- #include "ProtobufLAMessages.pb.h"
- #include "protobufSgxLATransformsInitiator.h"
- #include <stdio.h>
- int generate_protobuf_dh_msg1(uint32_t own_enclave_id, protobuf_sgx_dh_msg1_t& protobuf_msg1, uint32_t* session_id)
- {
- sgx_dh_msg1_t dh_msg1; //Diffie-Hellman Message 1
- memset(&dh_msg1, 0, sizeof(sgx_dh_msg1_t));
- uint32_t ret_status;
- Decryptor_session_request_wrapper(own_enclave_id, &ret_status, &dh_msg1, session_id); // TODO: Check Return status
- if(ret_status != SGX_SUCCESS)
- return 0xffffffff;
- encode_msg1_to_protobuf(protobuf_msg1, &dh_msg1);
- printf("Generated the following Msg1: ------------- \n"); fflush(stdout);
- print_initialized_msg1(protobuf_msg1, &dh_msg1);
- return 0;
- }
- int process_protobuf_dh_msg2_generate_protobuf_dh_msg3(uint32_t own_enclave_id, protobuf_sgx_dh_msg2_t& protobuf_msg2, protobuf_sgx_dh_msg3_t& protobuf_msg3, uint32_t* session_id)
- {
- uint32_t ret_status;
- sgx_dh_msg2_t dh_msg2; //Diffie-Hellman Message 2
- sgx_dh_msg3_t dh_msg3; //Diffie-Hellman Message 3
- sgx_key_128bit_t dh_aek; // Session Key
- memset(&dh_aek,0, sizeof(sgx_key_128bit_t));
- memset(&dh_msg2, 0, sizeof(sgx_dh_msg2_t));
- memset(&dh_msg3, 0, sizeof(sgx_dh_msg3_t));
- if(decode_msg2_from_protobuf(protobuf_msg2, &dh_msg2)!=0)
- return -1;
- // process msg2 and generate msg3
- Decryptor_exchange_report_wrapper(own_enclave_id, &ret_status, &dh_msg2, &dh_msg3, session_id);
- if(ret_status!=SGX_SUCCESS)
- return 0x35;
- // convert msg3 sgx_dh_msg3_t object to a protobuf msg3 object.
- encode_msg3_to_protobuf(protobuf_msg3, &dh_msg3);
- return 0;
- }
|