#include #include "../Decryptor/Decryptor_u.h" #include "UntrustedInclude/LocalAttestationUntrusted.h" #include "UntrustedInclude/SealingUntrusted.h" #include "sgx_eid.h" #include "sgx_urts.h" #define __STDC_FORMAT_MACROS #include #include #define Decryptor_PATH "libDecryptor.so" ////////////////////////////////////////////////// int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) { sgx_enclave_id_t enclave_id = 0; uint32_t ret_status; sgx_status_t status; // For sgx setup int launch_token_updated; sgx_launch_token_t launch_token; uint32_t counter; int server_fd, accept_fd; uint8_t verification_key[64]; status = sgx_create_enclave(Decryptor_PATH, SGX_DEBUG_FLAG, &launch_token, &launch_token_updated, &enclave_id, NULL); if(status != SGX_SUCCESS) { printf("\nLoad Enclave Failure: 0x%02x \n", status); return -1; } printf("\nDecryptor - EnclaveID %" PRIx64, enclave_id); fflush(stdout); ret_status = SealingUntrusted::look_for_signing_key_or_regenerate_it(enclave_id, "sealed_signing_key.txt"); if(ret_status != 0) { printf("Error in unsealing or generating LT signing verification keypair: 0x%02x \n", ret_status); fflush(stdout); sgx_destroy_enclave(enclave_id); return 0xFFFFFFFF; } Decryptor_get_long_term_verification_key_wrapper(enclave_id, verification_key); printf("Verification key\n"); fflush(stdout); for(counter=0;counter<32;counter++) printf("%02x", verification_key[counter]); printf("\n"); fflush(stdout); for(counter=0;counter<32;counter++) printf("%02x", verification_key[counter + 32]); printf("\n"); fflush(stdout); ret_status = LocalAttestationUntrusted::prepare_local_attestation_as_responder_msg1(enclave_id); if(ret_status !=0) { printf("Could not prepare_local_attestation_as_responder_msg1"); fflush(stdout); sgx_destroy_enclave(enclave_id); return ret_status; } server_fd=LocalAttestationUntrusted::setup_socket_for_local_attestation_requests(3824); if(server_fd <=0) { printf("Error in setting up server socket."); fflush(stdout); sgx_destroy_enclave(enclave_id); return server_fd; } printf("Successfully set up a socket to communicate with the verifier enclave.\n"); fflush(stdout); // LA with the verifier ret_status = LocalAttestationUntrusted::local_attestation_as_responder_msg2_msg3(enclave_id, server_fd, &accept_fd); if(ret_status!=0) { printf("local attestation - with the verifier - did not successfully return: %x\n", ret_status); fflush(stdout); sgx_destroy_enclave(enclave_id); return 0x32; } ret_status = LocalAttestationUntrusted::post_local_attestation_with_verifier(enclave_id, accept_fd); if(ret_status!=0) { printf("post local attestation - with the verifier - did not successfully return: %x\n", ret_status); fflush(stdout); sgx_destroy_enclave(enclave_id); return 0x33; } // LA with apache server_fd=LocalAttestationUntrusted::setup_socket_for_local_attestation_requests(3825); if(server_fd <=0) { printf("Error in setting up server socket."); fflush(stdout); sgx_destroy_enclave(enclave_id); return 0x34; } printf("Successfully set up a socket to communicate with the Apache enclave.\n"); fflush(stdout); ret_status = LocalAttestationUntrusted::local_attestation_as_responder_msg2_msg3(enclave_id,server_fd,&accept_fd); if(ret_status != 0) { printf("local attestation - with the apache - did not successfully return: %x\n", ret_status); fflush(stdout); sgx_destroy_enclave(enclave_id); return 0x35; } ret_status = LocalAttestationUntrusted::post_local_attestation_with_apache(enclave_id,accept_fd); if(ret_status!=0) { printf("post local attestation - with the apache - did not successfully return: %x\n", ret_status); fflush(stdout); sgx_destroy_enclave(enclave_id); return 0x36; } sgx_destroy_enclave(enclave_id); return 0; }