#include "LocalAttestationUntrusted.h" namespace LocalAttestationUntrusted { namespace { uint32_t session_id = 0; protobuf_sgx_dh_msg1_t protobuf_msg1; uint32_t local_attestation_msg2_msg3(uint32_t own_enclave_id, int accept_fd) { uint32_t protobuf_sgx_ret; protobuf_sgx_dh_msg2_t protobuf_msg2; protobuf_sgx_dh_msg3_t protobuf_msg3; printf("Writing message 1\n"); fflush(stdout); if (protobufReadWrite::write_protobuf_msg_to_fd(accept_fd, protobuf_msg1) != 0) return 0x1; printf("Reading message 2\n"); fflush(stdout); if (protobufReadWrite::read_protobuf_msg_from_fd(accept_fd, protobuf_msg2) != 0) return 0x2; protobuf_sgx_ret = process_protobuf_dh_msg2_generate_protobuf_dh_msg3(own_enclave_id, protobuf_msg2, protobuf_msg3, &session_id); if (protobuf_sgx_ret != 0) { printf("Error in generate_protobuf_dh_msg2: 0x%x", protobuf_sgx_ret); fflush(stdout); return protobuf_sgx_ret; } printf("Writing message 3\n"); fflush(stdout); if (protobufReadWrite::write_protobuf_msg_to_fd(accept_fd, protobuf_msg3) != 0) return 0x3; return 0; } } /* void get_lengths_for_protobuf_serialized_array(extension_to_decryptor_enclosed_msg &protobuf_ext_to_decryptor, uint32_t *output_lengths) { uint32_t number_of_ciphertext_fields, counter, total_length; // Didn't use bytesize() or bytesizelong() for getting the lengths of the public key or the ciphertext string // as that gives the *serialized* length of the message which should be an upper-bound. // Can switch to that if necessary for time performance reasons. total_length=protobuf_ext_to_decryptor.ciphertext_client_public_key().length(); number_of_ciphertext_fields=protobuf_ext_to_decryptor.ciphertext_fields_size(); for(counter=0; counter