#ifndef _REMOTE_ATTESTATION_H_ #define _REMOTE_ATTESTATION_H_ #include "crypto.h" #include "ra_result.h" #include "ra_ecp.h" #include "ra_ias.h" #include "sgx_tcrypto.h" #include "sgx_ukey_exchange.h" // This is a context data structure used on SP side typedef struct _ra_session_t { sgx_ec256_public_t g_a; sgx_ec256_public_t g_b; sgx_ec_key_128bit_t vk_key;// Shared secret key for the REPORT_DATA sgx_ec_key_128bit_t mk_key;// Shared secret key for generating MAC's sgx_ec_key_128bit_t sk_key;// Shared secret key for encryption sgx_ec_key_128bit_t smk_key;// Used only for SIGMA protocol sgx_ec256_private_t b; // sgx_ps_sec_prop_desc_t ps_sec_prop; }ra_session_t; static const sgx_ec256_private_t g_sp_priv_key = { { 0x90, 0xe7, 0x6c, 0xbb, 0x2d, 0x52, 0xa1, 0xce, 0x3b, 0x66, 0xde, 0x11, 0x43, 0x9c, 0x87, 0xec, 0x1f, 0x86, 0x6a, 0x3b, 0x65, 0xb6, 0xae, 0xea, 0xad, 0x57, 0x34, 0x53, 0xd1, 0x03, 0x8c, 0x01 } }; // This is the public EC key of SP, this key is hard coded in isv_enclave. // It is based on NIST P-256 curve. Not used in the SP code. static const sgx_ec256_public_t g_sp_pub_key = { { 0x72, 0x12, 0x8a, 0x7a, 0x17, 0x52, 0x6e, 0xbf, 0x85, 0xd0, 0x3a, 0x62, 0x37, 0x30, 0xae, 0xad, 0x3e, 0x3d, 0xaa, 0xee, 0x9c, 0x60, 0x73, 0x1d, 0xb0, 0x5b, 0xe8, 0x62, 0x1c, 0x4b, 0xeb, 0x38 }, { 0xd4, 0x81, 0x40, 0xd9, 0x50, 0xe2, 0x57, 0x7b, 0x26, 0xee, 0xb7, 0x41, 0xe7, 0xc6, 0x14, 0xe2, 0x24, 0xb7, 0xbd, 0xc9, 0x03, 0xf2, 0x9a, 0x28, 0xa8, 0x3c, 0xc8, 0x10, 0x11, 0x14, 0x5e, 0x06 } }; /*Key Derivation Function ID : 0x0001 AES-CMAC Entropy Extraction and Key Expansion*/ const uint16_t CMAC_KDF_ID = 0x0001; #define QUOTE_UNLINKABLE_SIGNATURE 0 #define QUOTE_LINKABLE_SIGNATURE 1 int doRemoteAttestation(); int handleMSG0(uint32_t extended_epid_group_id); int handleMSG1(sgx_ra_msg1_t* msg1, uint32_t msg1_size, sgx_ra_msg2_t** msg2, uint32_t* msg2_size); int handleMSG3(sgx_ra_msg3_t* msg3, uint32_t msg3_size, ra_msg_t** msg3_resp, uint32_t* msg3_resp_size); int checkMSG3Basic(sgx_ra_msg3_t* msg3, uint32_t msg3_size); int caculateSecret(uint8_t* secret, uint32_t secret_size, ra_msg_t** result_msg, uint32_t* result_msg_size); int caculateDHKey(ecc_state_handle_t* ecc_state, ra_session_t* session, sgx_ra_msg1_t* msg1); int checkEnclaveIdendty(const sgx_report_body_t& report_data); extern uint32_t context; extern ra_session_t session; #endif