Browse Source

Main extension code. Refactored and added in code to decrypt data between apache and decryptor. Doesnt work with client side extension

dettanym 5 years ago
parent
commit
707aaea629

+ 116 - 36
ProtobufLAInitiator.cpp

@@ -4,7 +4,7 @@
 #include <errno.h>
 #include<unistd.h>
 #include <stdio.h>
-#include "ProtobufLAMessages.h"
+#include "ProtobufLAMessages.pb.h"
 #include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/io/zero_copy_stream_impl.h>
 using namespace google::protobuf::io;
@@ -15,6 +15,8 @@ using namespace google::protobuf::io;
 #include <sys/socket.h>
 #include <netinet/in.h>
 
+int global_decryptor_fd; 
+
 
 // TODO: Make these private functions
 int read_protobuf_msg_from_fd(int accept_fd, google::protobuf::MessageLite& message)
@@ -27,19 +29,20 @@ int read_protobuf_msg_from_fd(int accept_fd, google::protobuf::MessageLite& mess
   coded_input = new CodedInputStream(raw_input);
   if(!coded_input->ReadVarint32(&size))
   {
-    printf("Error in reading size of msg");
+    printf("Error in reading size of msg\n");
     fflush(stdout);
     return -1;
   }
-  //printf("size of msg was read to be %" PRIu32 " \n", size);
+  printf("size of msg was read to be %d \n", size);
   fflush(stdout);
   limit = coded_input->PushLimit(size);
   if(!message.ParseFromCodedStream(coded_input))
   {
-    printf("Error in parsing msg");
+    printf("Error in parsing msg\n");
     fflush(stdout);
     return -1;
   }
+  printf("Done parsing msg\n"); fflush(stdout); 
   coded_input->PopLimit(limit);
   return 0;
 }
@@ -52,7 +55,7 @@ int write_protobuf_msg_to_fd(int accept_fd, google::protobuf::MessageLite& messa
   coded_output->WriteVarint32(message.ByteSize());
   if(!message.SerializeToCodedStream(coded_output))
   {
-    printf("SerializeToCodedStream failed");
+    printf("SerializeToCodedStream failed\n");
     fflush(stdout);
     return -1;
   }
@@ -97,7 +100,7 @@ int set_up_socket_connect(int port)
   return sock;
 }
 
-int local_attestation_initiator(int port, unsigned char* base64_encoded)
+int local_attestation_initiator(int port, unsigned char* base64_encoded_token)
 {
   // declare msg1, msg2, msg3 protobuf objects
   protobuf_sgx_dh_msg1_t protobuf_msg1;
@@ -110,6 +113,8 @@ int local_attestation_initiator(int port, unsigned char* base64_encoded)
 
   // For socket to listen to the Apache enclave.
 //  int server_fd=0; int accept_fd = 0;
+//   std::string protobuf_encrypted_msg_string(protobuf_encrypted_msg.msg());
+  // memcpy(tokenT_and_tag, protobuf_encrypted_msg_string.c_str(), 176); 
 //  struct sockaddr_in own_addr;
 //  struct sockaddr_storage apache_addr; socklen_t apache_addr_size = sizeof(apache_addr);
   uint32_t session_id;
@@ -144,45 +149,25 @@ int local_attestation_initiator(int port, unsigned char* base64_encoded)
   {
       printf("Error in process_protobuf_dh_msg3: 0x%x", protobuf_sgx_ret); fflush(stdout); return protobuf_sgx_ret;
   }
-/*  memset(encrypted_hash,0, 32); memset(encrypted_tag, 0, 16);
-  protobuf_sgx_ret=generate_encrypted_rsa_keypair_hash(encrypted_hash, encrypted_tag); 
-  if(protobuf_sgx_ret==0)
-  {
-	printf("Done encryption of hash.\n"); fflush(stdout); 
-  }
-  else 
-	{
-		printf("Error in enc/dec of hash: 0x%x", protobuf_sgx_ret); fflush(stdout); return protobuf_sgx_ret; 
-	}
-/*   uint32_t count;
-   for(count=0;count<32;count++)
-	printf("0x%x ", hash_and_tag[count]);
-   printf("\n");fflush(stdout); 
+          unsigned char tokenT_and_tag[176]; int protobuf_encrypted_msg_size;
 
-*/
-          uint8_t tokenT_and_tag[176]; size_t bytes_read;
 
-
-   bytes_read = read(decryptor_fd, tokenT_and_tag, 176);
-//   post_la_bytes_written = write(decryptor_fd, encrypted_tag, 16);
-
-   if(bytes_read != 176)
+          protobuf_post_LA_encrypted_msg_t protobuf_encrypted_msg; 
+        if(read_protobuf_msg_from_fd(decryptor_fd, protobuf_encrypted_msg)!=0)
    {
 	printf("Not all of the post-LA message was read\n"); fflush(stdout); return 0xfe; 
-
    }
+   std::string protobuf_encrypted_msg_string(protobuf_encrypted_msg.msg());
+   memcpy(tokenT_and_tag, protobuf_encrypted_msg_string.c_str(), 176); 
+
    printf("Read encrypted signature and tag from the decryptor socket.\n"); fflush(stdout); 
-   if(close(decryptor_fd)!= 0)
-   {
-	printf("Error in closing the socket connection.\n"); fflush(stdout); return 0xfd; 
-   } 
-     uint32_t count;  
+    uint32_t count;  
 	printf("Encrypted data:\n");
 	for(count=0;count<176;count++)
 		printf("0x%02x ", tokenT_and_tag[count]);
 	printf("\n"); fflush(stdout); 
 	uint8_t plaintext_token[160]; int plaintext_length=0;
-	uint32_t ret_decrypt=decrypt_wrapper(tokenT_and_tag, 160, plaintext_token, &plaintext_length, tokenT_and_tag+160);
+	uint32_t ret_decrypt=aes_gcm_wrapper(0, tokenT_and_tag, 160, plaintext_token, &plaintext_length, tokenT_and_tag+160);
 //int aes_cipher(int enc, unsigned char *key, unsigned char *iv, unsigned char* plaintext, int plaintext_len, unsigned char *ciphertext,  int* op_ciphertext_len, unsigned char* tag); 
 	if(ret_decrypt!=0)
 		{
@@ -196,13 +181,108 @@ int local_attestation_initiator(int port, unsigned char* base64_encoded)
 	for(count=64;count<96;count++)
                 printf("0x%02x ", plaintext_token[count]);
 	printf("\n"); fflush(stdout); 
-	count=base64_encoding_wrapper(plaintext_token, base64_encoded, 160);
+	count=base64_encoding_wrapper(plaintext_token, base64_encoded_token, 160);
 	if(count != 216)
 	{
 		printf("Somehow not the entire token was encoded in base64:0x%x\n", count); fflush(stdout); return 0x55;
 	}
-
+	global_decryptor_fd=decryptor_fd;
 	printf("Successfully done Local attestation\n");
 	fflush(stdout);
 	return 0;
 }
+
+// should be called with the base64encoded public key and data to be decrypted
+// base64 encoded public key should be of length 4*(ceil(64/3)) = 88 (at least)
+int decrypt_client_data_through_decryptor(unsigned char* base64_encoded_client_pub_key, unsigned char* ciphertext, uint32_t ciphertext_length, unsigned char* plaintext_user_data, uint32_t* op_plaintext_user_data_length)
+{
+	int openssl_ret_status; 
+	unsigned char client_pub_key[64];
+	uint32_t count; 
+	uint32_t length;
+	unsigned char* client_data_to_decryptor; 
+	unsigned char* client_data_encrypted_to_decryptor; 
+	unsigned char* client_data_from_decryptor;
+	int encryption_result; 
+        protobuf_post_LA_encrypted_msg_t protobuf_encrypted_msg; 
+	int output_length;
+
+	for(count=0; count<ciphertext_length; count++)
+		plaintext_user_data[count] = ciphertext[count]; 
+	*op_plaintext_user_data_length = ciphertext_length;
+
+
+        client_data_to_decryptor = (unsigned char*) malloc(64 + (ciphertext_length * 3/4)); 
+	openssl_ret_status=base64_decoding_wrapper(base64_encoded_client_pub_key, client_data_to_decryptor, 88); 
+	if(openssl_ret_status == -1)
+	{
+		free(client_data_to_decryptor); 
+		return 0xfe;
+	}
+
+	printf("Received the following key from the client:\n"); 
+	for(count=0;count<64;count++)
+		printf("0x%02x ", client_data_to_decryptor[count]);
+        printf("\n"); fflush(stdout);
+	// // TODO: call aes_gcm_wrapper or aes_gcm  *in encryption mode* on ciphertext data of ciphertext_length (where is the iv?) 
+
+	length = base64_decoding_wrapper(ciphertext, client_data_to_decryptor + 64, ciphertext_length);
+	if(length == -1)
+        {
+		free(client_data_to_decryptor);
+		return 0x33; 
+        }
+
+	for(count = 0; count<64 + length; count++)
+		printf("0x%02x ", client_data_to_decryptor[count]); 
+	printf("\n"); fflush(stdout);
+
+	client_data_encrypted_to_decryptor = (unsigned char*) malloc(length + 64 + 16);
+	// TODO: try to call aes_gcm  *in encryption mode* on ciphertext data of ciphertext_length (where is the iv?)
+	// if output_length != length + 64 then problems
+	encryption_result = aes_gcm_wrapper(1, client_data_to_decryptor, length + 64, client_data_encrypted_to_decryptor, &output_length, client_data_encrypted_to_decryptor + length + 80);
+	if(encryption_result != 0)
+  	{
+		free(client_data_to_decryptor);
+		free(client_data_encrypted_to_decryptor);
+		return encryption_result;
+	}
+	// TODO: Increment AESGCM IV here. 
+
+	protobuf_encrypted_msg.set_msg((void*)client_data_encrypted_to_decryptor, output_length);  
+	free(client_data_to_decryptor);
+	free(client_data_encrypted_to_decryptor);
+
+	// write message to decryptor
+        if(write_protobuf_msg_to_fd(global_decryptor_fd, protobuf_encrypted_msg)!=0)
+   	{
+        	printf("Not all of the client's pub key and ciphertext data was written\n"); fflush(stdout); return 0xfe; 
+   	}
+
+	// clear the message before setting it again
+	protobuf_encrypted_msg.clear_msg(); 
+
+	// read encrypted data
+	printf("Reading msg from decryptor"); fflush(stdout); 
+        if(read_protobuf_msg_from_fd(global_decryptor_fd, protobuf_encrypted_msg)!=0)
+	{
+        	printf("Not all of the decryptor's message was read\n"); fflush(stdout); return 0xfe; 
+	}
+	printf("Done reading msg from decryptor\n"); fflush(stdout); 
+
+	// define plaintext array
+	length = protobuf_encrypted_msg.msg().length(); 
+	client_data_from_decryptor=(unsigned char*)malloc(length);	
+	memcpy(client_data_from_decryptor, protobuf_encrypted_msg.msg().c_str(), length); //TODO: THIS might be a problem - c_str might terminate at null bytes? 
+
+	// TODO: decrypt data received in the protobuf_encrypted_msg, set bytes at plaintext_user_data to it. 
+	for(count=0;count<length;count++)
+		printf("0x%02x ", client_data_from_decryptor[count]);
+	printf("\n"); fflush(stdout);
+
+	encryption_result = aes_gcm_wrapper(0, client_data_from_decryptor, length, plaintext_user_data, &output_length, client_data_from_decryptor + length - 16); 
+	if(encryption_result == 0)
+		*op_plaintext_user_data_length = output_length; 
+	free(client_data_from_decryptor);
+	return encryption_result; 
+}

+ 202 - 0
ProtobufLAMessages.pb.cpp

@@ -23,6 +23,7 @@ void protobuf_ShutdownFile_ProtobufLAMessages_2eproto() {
   delete protobuf_sgx_dh_msg2_t::default_instance_;
   delete protobuf_sgx_dh_msg3_body_t::default_instance_;
   delete protobuf_sgx_dh_msg3_t::default_instance_;
+  delete protobuf_post_LA_encrypted_msg_t::default_instance_;
 }
 
 #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
@@ -46,6 +47,7 @@ void protobuf_AddDesc_ProtobufLAMessages_2eproto() {
   protobuf_sgx_dh_msg2_t::default_instance_ = new protobuf_sgx_dh_msg2_t();
   protobuf_sgx_dh_msg3_body_t::default_instance_ = new protobuf_sgx_dh_msg3_body_t();
   protobuf_sgx_dh_msg3_t::default_instance_ = new protobuf_sgx_dh_msg3_t();
+  protobuf_post_LA_encrypted_msg_t::default_instance_ = new protobuf_post_LA_encrypted_msg_t();
   protobuf_sgx_attributes_t::default_instance_->InitAsDefaultInstance();
   protobuf_sgx_ec256_public_t::default_instance_->InitAsDefaultInstance();
   protobuf_sgx_report_body_t::default_instance_->InitAsDefaultInstance();
@@ -55,6 +57,7 @@ void protobuf_AddDesc_ProtobufLAMessages_2eproto() {
   protobuf_sgx_dh_msg2_t::default_instance_->InitAsDefaultInstance();
   protobuf_sgx_dh_msg3_body_t::default_instance_->InitAsDefaultInstance();
   protobuf_sgx_dh_msg3_t::default_instance_->InitAsDefaultInstance();
+  protobuf_post_LA_encrypted_msg_t::default_instance_->InitAsDefaultInstance();
   ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_ProtobufLAMessages_2eproto);
 }
 
@@ -2992,6 +2995,205 @@ void protobuf_sgx_dh_msg3_t::Swap(protobuf_sgx_dh_msg3_t* other) {
 }
 
 
+// ===================================================================
+
+#ifndef _MSC_VER
+const int protobuf_post_LA_encrypted_msg_t::kMsgFieldNumber;
+#endif  // !_MSC_VER
+
+protobuf_post_LA_encrypted_msg_t::protobuf_post_LA_encrypted_msg_t()
+  : ::google::protobuf::MessageLite() {
+  SharedCtor();
+  // @@protoc_insertion_point(constructor:protobuf_post_LA_encrypted_msg_t)
+}
+
+void protobuf_post_LA_encrypted_msg_t::InitAsDefaultInstance() {
+}
+
+protobuf_post_LA_encrypted_msg_t::protobuf_post_LA_encrypted_msg_t(const protobuf_post_LA_encrypted_msg_t& from)
+  : ::google::protobuf::MessageLite() {
+  SharedCtor();
+  MergeFrom(from);
+  // @@protoc_insertion_point(copy_constructor:protobuf_post_LA_encrypted_msg_t)
+}
+
+void protobuf_post_LA_encrypted_msg_t::SharedCtor() {
+  ::google::protobuf::internal::GetEmptyString();
+  _cached_size_ = 0;
+  msg_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+protobuf_post_LA_encrypted_msg_t::~protobuf_post_LA_encrypted_msg_t() {
+  // @@protoc_insertion_point(destructor:protobuf_post_LA_encrypted_msg_t)
+  SharedDtor();
+}
+
+void protobuf_post_LA_encrypted_msg_t::SharedDtor() {
+  if (msg_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    delete msg_;
+  }
+  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
+  if (this != &default_instance()) {
+  #else
+  if (this != default_instance_) {
+  #endif
+  }
+}
+
+void protobuf_post_LA_encrypted_msg_t::SetCachedSize(int size) const {
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const protobuf_post_LA_encrypted_msg_t& protobuf_post_LA_encrypted_msg_t::default_instance() {
+#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
+  protobuf_AddDesc_ProtobufLAMessages_2eproto();
+#else
+  if (default_instance_ == NULL) protobuf_AddDesc_ProtobufLAMessages_2eproto();
+#endif
+  return *default_instance_;
+}
+
+protobuf_post_LA_encrypted_msg_t* protobuf_post_LA_encrypted_msg_t::default_instance_ = NULL;
+
+protobuf_post_LA_encrypted_msg_t* protobuf_post_LA_encrypted_msg_t::New() const {
+  return new protobuf_post_LA_encrypted_msg_t;
+}
+
+void protobuf_post_LA_encrypted_msg_t::Clear() {
+  if (has_msg()) {
+    if (msg_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+      msg_->clear();
+    }
+  }
+  ::memset(_has_bits_, 0, sizeof(_has_bits_));
+  mutable_unknown_fields()->clear();
+}
+
+bool protobuf_post_LA_encrypted_msg_t::MergePartialFromCodedStream(
+    ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
+  ::google::protobuf::uint32 tag;
+  ::google::protobuf::io::StringOutputStream unknown_fields_string(
+      mutable_unknown_fields());
+  ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
+      &unknown_fields_string);
+  // @@protoc_insertion_point(parse_start:protobuf_post_LA_encrypted_msg_t)
+  for (;;) {
+    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+    tag = p.first;
+    if (!p.second) goto handle_unusual;
+    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+      // required bytes msg = 1;
+      case 1: {
+        if (tag == 10) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
+                input, this->mutable_msg()));
+        } else {
+          goto handle_unusual;
+        }
+        if (input->ExpectAtEnd()) goto success;
+        break;
+      }
+
+      default: {
+      handle_unusual:
+        if (tag == 0 ||
+            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+          goto success;
+        }
+        DO_(::google::protobuf::internal::WireFormatLite::SkipField(
+            input, tag, &unknown_fields_stream));
+        break;
+      }
+    }
+  }
+success:
+  // @@protoc_insertion_point(parse_success:protobuf_post_LA_encrypted_msg_t)
+  return true;
+failure:
+  // @@protoc_insertion_point(parse_failure:protobuf_post_LA_encrypted_msg_t)
+  return false;
+#undef DO_
+}
+
+void protobuf_post_LA_encrypted_msg_t::SerializeWithCachedSizes(
+    ::google::protobuf::io::CodedOutputStream* output) const {
+  // @@protoc_insertion_point(serialize_start:protobuf_post_LA_encrypted_msg_t)
+  // required bytes msg = 1;
+  if (has_msg()) {
+    ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
+      1, this->msg(), output);
+  }
+
+  output->WriteRaw(unknown_fields().data(),
+                   unknown_fields().size());
+  // @@protoc_insertion_point(serialize_end:protobuf_post_LA_encrypted_msg_t)
+}
+
+int protobuf_post_LA_encrypted_msg_t::ByteSize() const {
+  int total_size = 0;
+
+  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    // required bytes msg = 1;
+    if (has_msg()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::BytesSize(
+          this->msg());
+    }
+
+  }
+  total_size += unknown_fields().size();
+
+  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+  _cached_size_ = total_size;
+  GOOGLE_SAFE_CONCURRENT_WRITES_END();
+  return total_size;
+}
+
+void protobuf_post_LA_encrypted_msg_t::CheckTypeAndMergeFrom(
+    const ::google::protobuf::MessageLite& from) {
+  MergeFrom(*::google::protobuf::down_cast<const protobuf_post_LA_encrypted_msg_t*>(&from));
+}
+
+void protobuf_post_LA_encrypted_msg_t::MergeFrom(const protobuf_post_LA_encrypted_msg_t& from) {
+  GOOGLE_CHECK_NE(&from, this);
+  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    if (from.has_msg()) {
+      set_msg(from.msg());
+    }
+  }
+  mutable_unknown_fields()->append(from.unknown_fields());
+}
+
+void protobuf_post_LA_encrypted_msg_t::CopyFrom(const protobuf_post_LA_encrypted_msg_t& from) {
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+bool protobuf_post_LA_encrypted_msg_t::IsInitialized() const {
+  if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
+
+  return true;
+}
+
+void protobuf_post_LA_encrypted_msg_t::Swap(protobuf_post_LA_encrypted_msg_t* other) {
+  if (other != this) {
+    std::swap(msg_, other->msg_);
+    std::swap(_has_bits_[0], other->_has_bits_[0]);
+    _unknown_fields_.swap(other->_unknown_fields_);
+    std::swap(_cached_size_, other->_cached_size_);
+  }
+}
+
+::std::string protobuf_post_LA_encrypted_msg_t::GetTypeName() const {
+  return "protobuf_post_LA_encrypted_msg_t";
+}
+
+
 // @@protoc_insertion_point(namespace_scope)
 
 // @@protoc_insertion_point(global_scope)

+ 16 - 3
SgxProtobufLAInitiator.cpp

@@ -1,7 +1,7 @@
 #include "sgx_eid.h"
 #define __STDC_FORMAT_MACROS
 #include <inttypes.h>
-#include "ProtobufLAMessages.h"
+#include "ProtobufLAMessages.pb.h"
 #include <stdio.h>
 
 #include "sgx_trts.h"
@@ -76,8 +76,8 @@ uint32_t process_protobuf_dh_msg3(protobuf_sgx_dh_msg3_t& protobuf_msg3, uint32_
 
   return 0;
 }
-
-uint32_t decrypt_wrapper(uint8_t* ciphertext, int ciphertext_len, uint8_t* op_plaintext, int* op_plaintext_len, uint8_t* ip_encrypted_tag)
+/*
+uint32_t decrypt_wrapper(unsigned char* ciphertext, int ciphertext_len, unsigned char* op_plaintext, int* op_plaintext_len, unsigned char* ip_encrypted_tag)
 {
         uint32_t return_status;
         unsigned char key[16]; uint32_t count;
@@ -87,3 +87,16 @@ uint32_t decrypt_wrapper(uint8_t* ciphertext, int ciphertext_len, uint8_t* op_pl
         return_status=aes_cipher(0, key, iv, ciphertext, ciphertext_len, op_plaintext,  op_plaintext_len, ip_encrypted_tag);
         return return_status;
 }
+*/
+
+uint32_t aes_gcm_wrapper(int enc, unsigned char* ciphertext, int ciphertext_len, unsigned char* op_plaintext, int* op_plaintext_len, unsigned char* ip_tag)
+{
+        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("About to do enc/dec\n"); fflush(stdout); 
+        return_status=aes_gcm(enc, key, iv, ciphertext, ciphertext_len, op_plaintext,  op_plaintext_len, ip_tag);
+        return return_status;
+}
+

+ 1 - 1
SgxProtobufLAInitiator_Transforms.cpp

@@ -21,7 +21,7 @@
 
 #include <stdio.h>
 // For google protobufs and deserialization/serialization
-#include "ProtobufLAMessages.h"
+#include "ProtobufLAMessages.pb.h"
 #include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/io/zero_copy_stream_impl.h>
 using namespace google::protobuf::io;

+ 20 - 1
crypto.cpp

@@ -1,5 +1,6 @@
 #include <stdio.h> 
 #include <string> 
+#include <string.h>
 #include <memory>
 using std::unique_ptr;
 #include <openssl/err.h> 
@@ -53,7 +54,7 @@ void crypto_cleanup()
 }
 
 // Code adapted from here: https://wiki.openssl.org/index.php/EVP_Authenticated_Encryption_and_Decryption 
-int aes_cipher(int enc, unsigned char *key, unsigned char *iv, unsigned char* plaintext, int plaintext_len, unsigned char *ciphertext,  int* op_ciphertext_len, unsigned char* tag)
+int aes_gcm(int enc, unsigned char *key, unsigned char *iv, unsigned char* plaintext, int plaintext_len, unsigned char *ciphertext,  int* op_ciphertext_len, unsigned char* tag)
 {
 	int len;
 	int ciphertext_len;
@@ -142,3 +143,21 @@ uint32_t base64_encoding_wrapper(unsigned char* src, unsigned char* dest, uint32
 	return EVP_EncodeBlock(dest, src, length);
 
 }
+
+uint32_t base64_decoding_wrapper(unsigned char* src, unsigned char* dest, uint32_t length)
+{
+        int length_with_padding = EVP_DecodeBlock(dest, src, length);
+        if(length_with_padding == -1)
+                return length_with_padding; 
+        char* first_equals_character = strstr((char*)src, "=");
+        if(first_equals_character != NULL)
+        {
+                if(first_equals_character == (char*)src + length - 1) // the first equals character is also the last character in the string ==> Only one equals ==> 2 v$
+                        length_with_padding -= 1; 
+                else //if(first_equals_character == src + 38) // assuming that the base64 string is valid (EVP_DecodeBlock would have thrown an error in that case), the$
+                        length_with_padding -= 2; 
+        }
+        
+        return length_with_padding;           
+}
+

+ 3 - 0
include/ProtobufLAInitiator.h

@@ -1 +1,4 @@
 int local_attestation_initiator(int port, unsigned char* base64_encoding); 
+int decrypt_client_data_through_decryptor(unsigned char* base64_encoded_client_pub_key, unsigned char* ciphertext, uint32_t ciphertext_length, unsigned char* plaintext_user_data, uint32_t* op_plaintext_user_data_length);
+//int decrypt_client_data_through_decryptor(unsigned char* base64_encoded_client_pub_key, unsigned char* ciphertext, uint32_t ciphertext_length, unsigned char* plaintext_user_data);
+

+ 0 - 2324
include/ProtobufLAMessages.h

@@ -1,2324 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: dhmsgs.proto
-
-#ifndef PROTOBUF_dhmsgs_2eproto__INCLUDED
-#define PROTOBUF_dhmsgs_2eproto__INCLUDED
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-
-#if GOOGLE_PROTOBUF_VERSION < 2006000
-#error This file was generated by a newer version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please update
-#error your headers.
-#endif
-#if 2006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
-// @@protoc_insertion_point(includes)
-
-// Internal implementation detail -- do not call these.
-void  protobuf_AddDesc_dhmsgs_2eproto();
-void protobuf_AssignDesc_dhmsgs_2eproto();
-void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-class protobuf_sgx_attributes_t;
-class protobuf_sgx_ec256_public_t;
-class protobuf_sgx_report_body_t;
-class protobuf_sgx_report_t;
-class protobuf_sgx_target_info_t;
-class protobuf_sgx_dh_msg1_t;
-class protobuf_sgx_dh_msg2_t;
-class protobuf_sgx_dh_msg3_body_t;
-class protobuf_sgx_dh_msg3_t;
-
-// ===================================================================
-
-class protobuf_sgx_attributes_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_attributes_t();
-  virtual ~protobuf_sgx_attributes_t();
-
-  protobuf_sgx_attributes_t(const protobuf_sgx_attributes_t& from);
-
-  inline protobuf_sgx_attributes_t& operator=(const protobuf_sgx_attributes_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_attributes_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_attributes_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_attributes_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_attributes_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_attributes_t& from);
-  void MergeFrom(const protobuf_sgx_attributes_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required uint64 flags = 1;
-  inline bool has_flags() const;
-  inline void clear_flags();
-  static const int kFlagsFieldNumber = 1;
-  inline ::google::protobuf::uint64 flags() const;
-  inline void set_flags(::google::protobuf::uint64 value);
-
-  // required uint64 xfrm = 2;
-  inline bool has_xfrm() const;
-  inline void clear_xfrm();
-  static const int kXfrmFieldNumber = 2;
-  inline ::google::protobuf::uint64 xfrm() const;
-  inline void set_xfrm(::google::protobuf::uint64 value);
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_attributes_t)
- private:
-  inline void set_has_flags();
-  inline void clear_has_flags();
-  inline void set_has_xfrm();
-  inline void clear_has_xfrm();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::google::protobuf::uint64 flags_;
-  ::google::protobuf::uint64 xfrm_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_attributes_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_ec256_public_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_ec256_public_t();
-  virtual ~protobuf_sgx_ec256_public_t();
-
-  protobuf_sgx_ec256_public_t(const protobuf_sgx_ec256_public_t& from);
-
-  inline protobuf_sgx_ec256_public_t& operator=(const protobuf_sgx_ec256_public_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_ec256_public_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_ec256_public_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_ec256_public_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_ec256_public_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_ec256_public_t& from);
-  void MergeFrom(const protobuf_sgx_ec256_public_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // repeated uint32 gx = 1 [packed = true];
-  inline int gx_size() const;
-  inline void clear_gx();
-  static const int kGxFieldNumber = 1;
-  inline ::google::protobuf::uint32 gx(int index) const;
-  inline void set_gx(int index, ::google::protobuf::uint32 value);
-  inline void add_gx(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      gx() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_gx();
-
-  // repeated uint32 gy = 2 [packed = true];
-  inline int gy_size() const;
-  inline void clear_gy();
-  static const int kGyFieldNumber = 2;
-  inline ::google::protobuf::uint32 gy(int index) const;
-  inline void set_gy(int index, ::google::protobuf::uint32 value);
-  inline void add_gy(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      gy() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_gy();
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_ec256_public_t)
- private:
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > gx_;
-  mutable int _gx_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > gy_;
-  mutable int _gy_cached_byte_size_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_ec256_public_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_report_body_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_report_body_t();
-  virtual ~protobuf_sgx_report_body_t();
-
-  protobuf_sgx_report_body_t(const protobuf_sgx_report_body_t& from);
-
-  inline protobuf_sgx_report_body_t& operator=(const protobuf_sgx_report_body_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_report_body_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_report_body_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_report_body_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_report_body_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_report_body_t& from);
-  void MergeFrom(const protobuf_sgx_report_body_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // repeated uint32 cpu_svn = 1 [packed = true];
-  inline int cpu_svn_size() const;
-  inline void clear_cpu_svn();
-  static const int kCpuSvnFieldNumber = 1;
-  inline ::google::protobuf::uint32 cpu_svn(int index) const;
-  inline void set_cpu_svn(int index, ::google::protobuf::uint32 value);
-  inline void add_cpu_svn(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      cpu_svn() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_cpu_svn();
-
-  // required uint32 misc_select = 9;
-  inline bool has_misc_select() const;
-  inline void clear_misc_select();
-  static const int kMiscSelectFieldNumber = 9;
-  inline ::google::protobuf::uint32 misc_select() const;
-  inline void set_misc_select(::google::protobuf::uint32 value);
-
-  // repeated uint32 reserved1 = 2 [packed = true];
-  inline int reserved1_size() const;
-  inline void clear_reserved1();
-  static const int kReserved1FieldNumber = 2;
-  inline ::google::protobuf::uint32 reserved1(int index) const;
-  inline void set_reserved1(int index, ::google::protobuf::uint32 value);
-  inline void add_reserved1(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      reserved1() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_reserved1();
-
-  // required .protobuf_sgx_attributes_t attributes = 10;
-  inline bool has_attributes() const;
-  inline void clear_attributes();
-  static const int kAttributesFieldNumber = 10;
-  inline const ::protobuf_sgx_attributes_t& attributes() const;
-  inline ::protobuf_sgx_attributes_t* mutable_attributes();
-  inline ::protobuf_sgx_attributes_t* release_attributes();
-  inline void set_allocated_attributes(::protobuf_sgx_attributes_t* attributes);
-
-  // repeated uint32 mr_enclave = 3 [packed = true];
-  inline int mr_enclave_size() const;
-  inline void clear_mr_enclave();
-  static const int kMrEnclaveFieldNumber = 3;
-  inline ::google::protobuf::uint32 mr_enclave(int index) const;
-  inline void set_mr_enclave(int index, ::google::protobuf::uint32 value);
-  inline void add_mr_enclave(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      mr_enclave() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_mr_enclave();
-
-  // repeated uint32 reserved2 = 4 [packed = true];
-  inline int reserved2_size() const;
-  inline void clear_reserved2();
-  static const int kReserved2FieldNumber = 4;
-  inline ::google::protobuf::uint32 reserved2(int index) const;
-  inline void set_reserved2(int index, ::google::protobuf::uint32 value);
-  inline void add_reserved2(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      reserved2() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_reserved2();
-
-  // repeated uint32 mr_signer = 5 [packed = true];
-  inline int mr_signer_size() const;
-  inline void clear_mr_signer();
-  static const int kMrSignerFieldNumber = 5;
-  inline ::google::protobuf::uint32 mr_signer(int index) const;
-  inline void set_mr_signer(int index, ::google::protobuf::uint32 value);
-  inline void add_mr_signer(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      mr_signer() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_mr_signer();
-
-  // repeated uint32 reserved3 = 6 [packed = true];
-  inline int reserved3_size() const;
-  inline void clear_reserved3();
-  static const int kReserved3FieldNumber = 6;
-  inline ::google::protobuf::uint32 reserved3(int index) const;
-  inline void set_reserved3(int index, ::google::protobuf::uint32 value);
-  inline void add_reserved3(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      reserved3() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_reserved3();
-
-  // required uint32 isv_prod_id = 11;
-  inline bool has_isv_prod_id() const;
-  inline void clear_isv_prod_id();
-  static const int kIsvProdIdFieldNumber = 11;
-  inline ::google::protobuf::uint32 isv_prod_id() const;
-  inline void set_isv_prod_id(::google::protobuf::uint32 value);
-
-  // required uint32 isv_svn = 12;
-  inline bool has_isv_svn() const;
-  inline void clear_isv_svn();
-  static const int kIsvSvnFieldNumber = 12;
-  inline ::google::protobuf::uint32 isv_svn() const;
-  inline void set_isv_svn(::google::protobuf::uint32 value);
-
-  // repeated uint32 reserved4 = 7 [packed = true];
-  inline int reserved4_size() const;
-  inline void clear_reserved4();
-  static const int kReserved4FieldNumber = 7;
-  inline ::google::protobuf::uint32 reserved4(int index) const;
-  inline void set_reserved4(int index, ::google::protobuf::uint32 value);
-  inline void add_reserved4(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      reserved4() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_reserved4();
-
-  // repeated uint32 report_data = 8 [packed = true];
-  inline int report_data_size() const;
-  inline void clear_report_data();
-  static const int kReportDataFieldNumber = 8;
-  inline ::google::protobuf::uint32 report_data(int index) const;
-  inline void set_report_data(int index, ::google::protobuf::uint32 value);
-  inline void add_report_data(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      report_data() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_report_data();
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_report_body_t)
- private:
-  inline void set_has_misc_select();
-  inline void clear_has_misc_select();
-  inline void set_has_attributes();
-  inline void clear_has_attributes();
-  inline void set_has_isv_prod_id();
-  inline void clear_has_isv_prod_id();
-  inline void set_has_isv_svn();
-  inline void clear_has_isv_svn();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > cpu_svn_;
-  mutable int _cpu_svn_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > reserved1_;
-  mutable int _reserved1_cached_byte_size_;
-  ::protobuf_sgx_attributes_t* attributes_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > mr_enclave_;
-  mutable int _mr_enclave_cached_byte_size_;
-  ::google::protobuf::uint32 misc_select_;
-  ::google::protobuf::uint32 isv_prod_id_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > reserved2_;
-  mutable int _reserved2_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > mr_signer_;
-  mutable int _mr_signer_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > reserved3_;
-  mutable int _reserved3_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > reserved4_;
-  mutable int _reserved4_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > report_data_;
-  mutable int _report_data_cached_byte_size_;
-  ::google::protobuf::uint32 isv_svn_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_report_body_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_report_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_report_t();
-  virtual ~protobuf_sgx_report_t();
-
-  protobuf_sgx_report_t(const protobuf_sgx_report_t& from);
-
-  inline protobuf_sgx_report_t& operator=(const protobuf_sgx_report_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_report_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_report_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_report_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_report_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_report_t& from);
-  void MergeFrom(const protobuf_sgx_report_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required .protobuf_sgx_report_body_t body = 1;
-  inline bool has_body() const;
-  inline void clear_body();
-  static const int kBodyFieldNumber = 1;
-  inline const ::protobuf_sgx_report_body_t& body() const;
-  inline ::protobuf_sgx_report_body_t* mutable_body();
-  inline ::protobuf_sgx_report_body_t* release_body();
-  inline void set_allocated_body(::protobuf_sgx_report_body_t* body);
-
-  // repeated uint32 key_id = 2 [packed = true];
-  inline int key_id_size() const;
-  inline void clear_key_id();
-  static const int kKeyIdFieldNumber = 2;
-  inline ::google::protobuf::uint32 key_id(int index) const;
-  inline void set_key_id(int index, ::google::protobuf::uint32 value);
-  inline void add_key_id(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      key_id() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_key_id();
-
-  // repeated uint32 mac = 3 [packed = true];
-  inline int mac_size() const;
-  inline void clear_mac();
-  static const int kMacFieldNumber = 3;
-  inline ::google::protobuf::uint32 mac(int index) const;
-  inline void set_mac(int index, ::google::protobuf::uint32 value);
-  inline void add_mac(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      mac() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_mac();
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_report_t)
- private:
-  inline void set_has_body();
-  inline void clear_has_body();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::protobuf_sgx_report_body_t* body_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > key_id_;
-  mutable int _key_id_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > mac_;
-  mutable int _mac_cached_byte_size_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_report_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_target_info_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_target_info_t();
-  virtual ~protobuf_sgx_target_info_t();
-
-  protobuf_sgx_target_info_t(const protobuf_sgx_target_info_t& from);
-
-  inline protobuf_sgx_target_info_t& operator=(const protobuf_sgx_target_info_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_target_info_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_target_info_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_target_info_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_target_info_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_target_info_t& from);
-  void MergeFrom(const protobuf_sgx_target_info_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // repeated uint32 mr_enclave = 1 [packed = true];
-  inline int mr_enclave_size() const;
-  inline void clear_mr_enclave();
-  static const int kMrEnclaveFieldNumber = 1;
-  inline ::google::protobuf::uint32 mr_enclave(int index) const;
-  inline void set_mr_enclave(int index, ::google::protobuf::uint32 value);
-  inline void add_mr_enclave(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      mr_enclave() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_mr_enclave();
-
-  // required .protobuf_sgx_attributes_t attributes = 4;
-  inline bool has_attributes() const;
-  inline void clear_attributes();
-  static const int kAttributesFieldNumber = 4;
-  inline const ::protobuf_sgx_attributes_t& attributes() const;
-  inline ::protobuf_sgx_attributes_t* mutable_attributes();
-  inline ::protobuf_sgx_attributes_t* release_attributes();
-  inline void set_allocated_attributes(::protobuf_sgx_attributes_t* attributes);
-
-  // repeated uint32 reserved1 = 2 [packed = true];
-  inline int reserved1_size() const;
-  inline void clear_reserved1();
-  static const int kReserved1FieldNumber = 2;
-  inline ::google::protobuf::uint32 reserved1(int index) const;
-  inline void set_reserved1(int index, ::google::protobuf::uint32 value);
-  inline void add_reserved1(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      reserved1() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_reserved1();
-
-  // required uint32 misc_select = 5;
-  inline bool has_misc_select() const;
-  inline void clear_misc_select();
-  static const int kMiscSelectFieldNumber = 5;
-  inline ::google::protobuf::uint32 misc_select() const;
-  inline void set_misc_select(::google::protobuf::uint32 value);
-
-  // repeated uint32 reserved2 = 3 [packed = true];
-  inline int reserved2_size() const;
-  inline void clear_reserved2();
-  static const int kReserved2FieldNumber = 3;
-  inline ::google::protobuf::uint32 reserved2(int index) const;
-  inline void set_reserved2(int index, ::google::protobuf::uint32 value);
-  inline void add_reserved2(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      reserved2() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_reserved2();
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_target_info_t)
- private:
-  inline void set_has_attributes();
-  inline void clear_has_attributes();
-  inline void set_has_misc_select();
-  inline void clear_has_misc_select();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > mr_enclave_;
-  mutable int _mr_enclave_cached_byte_size_;
-  ::protobuf_sgx_attributes_t* attributes_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > reserved1_;
-  mutable int _reserved1_cached_byte_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > reserved2_;
-  mutable int _reserved2_cached_byte_size_;
-  ::google::protobuf::uint32 misc_select_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_target_info_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_dh_msg1_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_dh_msg1_t();
-  virtual ~protobuf_sgx_dh_msg1_t();
-
-  protobuf_sgx_dh_msg1_t(const protobuf_sgx_dh_msg1_t& from);
-
-  inline protobuf_sgx_dh_msg1_t& operator=(const protobuf_sgx_dh_msg1_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_dh_msg1_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_dh_msg1_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_dh_msg1_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_dh_msg1_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_dh_msg1_t& from);
-  void MergeFrom(const protobuf_sgx_dh_msg1_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required .protobuf_sgx_ec256_public_t g_a = 1;
-  inline bool has_g_a() const;
-  inline void clear_g_a();
-  static const int kGAFieldNumber = 1;
-  inline const ::protobuf_sgx_ec256_public_t& g_a() const;
-  inline ::protobuf_sgx_ec256_public_t* mutable_g_a();
-  inline ::protobuf_sgx_ec256_public_t* release_g_a();
-  inline void set_allocated_g_a(::protobuf_sgx_ec256_public_t* g_a);
-
-  // required .protobuf_sgx_target_info_t target = 2;
-  inline bool has_target() const;
-  inline void clear_target();
-  static const int kTargetFieldNumber = 2;
-  inline const ::protobuf_sgx_target_info_t& target() const;
-  inline ::protobuf_sgx_target_info_t* mutable_target();
-  inline ::protobuf_sgx_target_info_t* release_target();
-  inline void set_allocated_target(::protobuf_sgx_target_info_t* target);
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_dh_msg1_t)
- private:
-  inline void set_has_g_a();
-  inline void clear_has_g_a();
-  inline void set_has_target();
-  inline void clear_has_target();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::protobuf_sgx_ec256_public_t* g_a_;
-  ::protobuf_sgx_target_info_t* target_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_dh_msg1_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_dh_msg2_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_dh_msg2_t();
-  virtual ~protobuf_sgx_dh_msg2_t();
-
-  protobuf_sgx_dh_msg2_t(const protobuf_sgx_dh_msg2_t& from);
-
-  inline protobuf_sgx_dh_msg2_t& operator=(const protobuf_sgx_dh_msg2_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_dh_msg2_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_dh_msg2_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_dh_msg2_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_dh_msg2_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_dh_msg2_t& from);
-  void MergeFrom(const protobuf_sgx_dh_msg2_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required .protobuf_sgx_ec256_public_t g_b = 1;
-  inline bool has_g_b() const;
-  inline void clear_g_b();
-  static const int kGBFieldNumber = 1;
-  inline const ::protobuf_sgx_ec256_public_t& g_b() const;
-  inline ::protobuf_sgx_ec256_public_t* mutable_g_b();
-  inline ::protobuf_sgx_ec256_public_t* release_g_b();
-  inline void set_allocated_g_b(::protobuf_sgx_ec256_public_t* g_b);
-
-  // required .protobuf_sgx_report_t report = 2;
-  inline bool has_report() const;
-  inline void clear_report();
-  static const int kReportFieldNumber = 2;
-  inline const ::protobuf_sgx_report_t& report() const;
-  inline ::protobuf_sgx_report_t* mutable_report();
-  inline ::protobuf_sgx_report_t* release_report();
-  inline void set_allocated_report(::protobuf_sgx_report_t* report);
-
-  // repeated uint32 cmac = 3 [packed = true];
-  inline int cmac_size() const;
-  inline void clear_cmac();
-  static const int kCmacFieldNumber = 3;
-  inline ::google::protobuf::uint32 cmac(int index) const;
-  inline void set_cmac(int index, ::google::protobuf::uint32 value);
-  inline void add_cmac(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      cmac() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_cmac();
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_dh_msg2_t)
- private:
-  inline void set_has_g_b();
-  inline void clear_has_g_b();
-  inline void set_has_report();
-  inline void clear_has_report();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::protobuf_sgx_ec256_public_t* g_b_;
-  ::protobuf_sgx_report_t* report_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > cmac_;
-  mutable int _cmac_cached_byte_size_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_dh_msg2_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_dh_msg3_body_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_dh_msg3_body_t();
-  virtual ~protobuf_sgx_dh_msg3_body_t();
-
-  protobuf_sgx_dh_msg3_body_t(const protobuf_sgx_dh_msg3_body_t& from);
-
-  inline protobuf_sgx_dh_msg3_body_t& operator=(const protobuf_sgx_dh_msg3_body_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_dh_msg3_body_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_dh_msg3_body_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_dh_msg3_body_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_dh_msg3_body_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_dh_msg3_body_t& from);
-  void MergeFrom(const protobuf_sgx_dh_msg3_body_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required .protobuf_sgx_report_t report = 1;
-  inline bool has_report() const;
-  inline void clear_report();
-  static const int kReportFieldNumber = 1;
-  inline const ::protobuf_sgx_report_t& report() const;
-  inline ::protobuf_sgx_report_t* mutable_report();
-  inline ::protobuf_sgx_report_t* release_report();
-  inline void set_allocated_report(::protobuf_sgx_report_t* report);
-
-  // repeated uint32 additional_prop = 2;
-  inline int additional_prop_size() const;
-  inline void clear_additional_prop();
-  static const int kAdditionalPropFieldNumber = 2;
-  inline ::google::protobuf::uint32 additional_prop(int index) const;
-  inline void set_additional_prop(int index, ::google::protobuf::uint32 value);
-  inline void add_additional_prop(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      additional_prop() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_additional_prop();
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_dh_msg3_body_t)
- private:
-  inline void set_has_report();
-  inline void clear_has_report();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::protobuf_sgx_report_t* report_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > additional_prop_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_dh_msg3_body_t* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class protobuf_sgx_dh_msg3_t : public ::google::protobuf::MessageLite {
- public:
-  protobuf_sgx_dh_msg3_t();
-  virtual ~protobuf_sgx_dh_msg3_t();
-
-  protobuf_sgx_dh_msg3_t(const protobuf_sgx_dh_msg3_t& from);
-
-  inline protobuf_sgx_dh_msg3_t& operator=(const protobuf_sgx_dh_msg3_t& from) {
-    CopyFrom(from);
-    return *this;
-  }
-
-  inline const ::std::string& unknown_fields() const {
-    return _unknown_fields_;
-  }
-
-  inline ::std::string* mutable_unknown_fields() {
-    return &_unknown_fields_;
-  }
-
-  static const protobuf_sgx_dh_msg3_t& default_instance();
-
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  // Returns the internal default instance pointer. This function can
-  // return NULL thus should not be used by the user. This is intended
-  // for Protobuf internal code. Please use default_instance() declared
-  // above instead.
-  static inline const protobuf_sgx_dh_msg3_t* internal_default_instance() {
-    return default_instance_;
-  }
-  #endif
-
-  void Swap(protobuf_sgx_dh_msg3_t* other);
-
-  // implements Message ----------------------------------------------
-
-  protobuf_sgx_dh_msg3_t* New() const;
-  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
-  void CopyFrom(const protobuf_sgx_dh_msg3_t& from);
-  void MergeFrom(const protobuf_sgx_dh_msg3_t& from);
-  void Clear();
-  bool IsInitialized() const;
-
-  int ByteSize() const;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input);
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const;
-  void DiscardUnknownFields();
-  int GetCachedSize() const { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const;
-  public:
-  ::std::string GetTypeName() const;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required .protobuf_sgx_dh_msg3_body_t msg3_body = 1;
-  inline bool has_msg3_body() const;
-  inline void clear_msg3_body();
-  static const int kMsg3BodyFieldNumber = 1;
-  inline const ::protobuf_sgx_dh_msg3_body_t& msg3_body() const;
-  inline ::protobuf_sgx_dh_msg3_body_t* mutable_msg3_body();
-  inline ::protobuf_sgx_dh_msg3_body_t* release_msg3_body();
-  inline void set_allocated_msg3_body(::protobuf_sgx_dh_msg3_body_t* msg3_body);
-
-  // repeated uint32 cmac = 2 [packed = true];
-  inline int cmac_size() const;
-  inline void clear_cmac();
-  static const int kCmacFieldNumber = 2;
-  inline ::google::protobuf::uint32 cmac(int index) const;
-  inline void set_cmac(int index, ::google::protobuf::uint32 value);
-  inline void add_cmac(::google::protobuf::uint32 value);
-  inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-      cmac() const;
-  inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-      mutable_cmac();
-
-  // @@protoc_insertion_point(class_scope:protobuf_sgx_dh_msg3_t)
- private:
-  inline void set_has_msg3_body();
-  inline void clear_has_msg3_body();
-
-  ::std::string _unknown_fields_;
-
-  ::google::protobuf::uint32 _has_bits_[1];
-  mutable int _cached_size_;
-  ::protobuf_sgx_dh_msg3_body_t* msg3_body_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > cmac_;
-  mutable int _cmac_cached_byte_size_;
-  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  friend void  protobuf_AddDesc_dhmsgs_2eproto_impl();
-  #else
-  friend void  protobuf_AddDesc_dhmsgs_2eproto();
-  #endif
-  friend void protobuf_AssignDesc_dhmsgs_2eproto();
-  friend void protobuf_ShutdownFile_dhmsgs_2eproto();
-
-  void InitAsDefaultInstance();
-  static protobuf_sgx_dh_msg3_t* default_instance_;
-};
-// ===================================================================
-
-
-// ===================================================================
-
-// protobuf_sgx_attributes_t
-
-// required uint64 flags = 1;
-inline bool protobuf_sgx_attributes_t::has_flags() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void protobuf_sgx_attributes_t::set_has_flags() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void protobuf_sgx_attributes_t::clear_has_flags() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void protobuf_sgx_attributes_t::clear_flags() {
-  flags_ = GOOGLE_ULONGLONG(0);
-  clear_has_flags();
-}
-inline ::google::protobuf::uint64 protobuf_sgx_attributes_t::flags() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_attributes_t.flags)
-  return flags_;
-}
-inline void protobuf_sgx_attributes_t::set_flags(::google::protobuf::uint64 value) {
-  set_has_flags();
-  flags_ = value;
-  // @@protoc_insertion_point(field_set:protobuf_sgx_attributes_t.flags)
-}
-
-// required uint64 xfrm = 2;
-inline bool protobuf_sgx_attributes_t::has_xfrm() const {
-  return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void protobuf_sgx_attributes_t::set_has_xfrm() {
-  _has_bits_[0] |= 0x00000002u;
-}
-inline void protobuf_sgx_attributes_t::clear_has_xfrm() {
-  _has_bits_[0] &= ~0x00000002u;
-}
-inline void protobuf_sgx_attributes_t::clear_xfrm() {
-  xfrm_ = GOOGLE_ULONGLONG(0);
-  clear_has_xfrm();
-}
-inline ::google::protobuf::uint64 protobuf_sgx_attributes_t::xfrm() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_attributes_t.xfrm)
-  return xfrm_;
-}
-inline void protobuf_sgx_attributes_t::set_xfrm(::google::protobuf::uint64 value) {
-  set_has_xfrm();
-  xfrm_ = value;
-  // @@protoc_insertion_point(field_set:protobuf_sgx_attributes_t.xfrm)
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_ec256_public_t
-
-// repeated uint32 gx = 1 [packed = true];
-inline int protobuf_sgx_ec256_public_t::gx_size() const {
-  return gx_.size();
-}
-inline void protobuf_sgx_ec256_public_t::clear_gx() {
-  gx_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_ec256_public_t::gx(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_ec256_public_t.gx)
-  return gx_.Get(index);
-}
-inline void protobuf_sgx_ec256_public_t::set_gx(int index, ::google::protobuf::uint32 value) {
-  gx_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_ec256_public_t.gx)
-}
-inline void protobuf_sgx_ec256_public_t::add_gx(::google::protobuf::uint32 value) {
-  gx_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_ec256_public_t.gx)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_ec256_public_t::gx() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_ec256_public_t.gx)
-  return gx_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_ec256_public_t::mutable_gx() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_ec256_public_t.gx)
-  return &gx_;
-}
-
-// repeated uint32 gy = 2 [packed = true];
-inline int protobuf_sgx_ec256_public_t::gy_size() const {
-  return gy_.size();
-}
-inline void protobuf_sgx_ec256_public_t::clear_gy() {
-  gy_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_ec256_public_t::gy(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_ec256_public_t.gy)
-  return gy_.Get(index);
-}
-inline void protobuf_sgx_ec256_public_t::set_gy(int index, ::google::protobuf::uint32 value) {
-  gy_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_ec256_public_t.gy)
-}
-inline void protobuf_sgx_ec256_public_t::add_gy(::google::protobuf::uint32 value) {
-  gy_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_ec256_public_t.gy)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_ec256_public_t::gy() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_ec256_public_t.gy)
-  return gy_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_ec256_public_t::mutable_gy() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_ec256_public_t.gy)
-  return &gy_;
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_report_body_t
-
-// repeated uint32 cpu_svn = 1 [packed = true];
-inline int protobuf_sgx_report_body_t::cpu_svn_size() const {
-  return cpu_svn_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_cpu_svn() {
-  cpu_svn_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::cpu_svn(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.cpu_svn)
-  return cpu_svn_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_cpu_svn(int index, ::google::protobuf::uint32 value) {
-  cpu_svn_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.cpu_svn)
-}
-inline void protobuf_sgx_report_body_t::add_cpu_svn(::google::protobuf::uint32 value) {
-  cpu_svn_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.cpu_svn)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::cpu_svn() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.cpu_svn)
-  return cpu_svn_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_cpu_svn() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.cpu_svn)
-  return &cpu_svn_;
-}
-
-// required uint32 misc_select = 9;
-inline bool protobuf_sgx_report_body_t::has_misc_select() const {
-  return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void protobuf_sgx_report_body_t::set_has_misc_select() {
-  _has_bits_[0] |= 0x00000002u;
-}
-inline void protobuf_sgx_report_body_t::clear_has_misc_select() {
-  _has_bits_[0] &= ~0x00000002u;
-}
-inline void protobuf_sgx_report_body_t::clear_misc_select() {
-  misc_select_ = 0u;
-  clear_has_misc_select();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::misc_select() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.misc_select)
-  return misc_select_;
-}
-inline void protobuf_sgx_report_body_t::set_misc_select(::google::protobuf::uint32 value) {
-  set_has_misc_select();
-  misc_select_ = value;
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.misc_select)
-}
-
-// repeated uint32 reserved1 = 2 [packed = true];
-inline int protobuf_sgx_report_body_t::reserved1_size() const {
-  return reserved1_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_reserved1() {
-  reserved1_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::reserved1(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.reserved1)
-  return reserved1_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_reserved1(int index, ::google::protobuf::uint32 value) {
-  reserved1_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.reserved1)
-}
-inline void protobuf_sgx_report_body_t::add_reserved1(::google::protobuf::uint32 value) {
-  reserved1_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.reserved1)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::reserved1() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.reserved1)
-  return reserved1_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_reserved1() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.reserved1)
-  return &reserved1_;
-}
-
-// required .protobuf_sgx_attributes_t attributes = 10;
-inline bool protobuf_sgx_report_body_t::has_attributes() const {
-  return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void protobuf_sgx_report_body_t::set_has_attributes() {
-  _has_bits_[0] |= 0x00000008u;
-}
-inline void protobuf_sgx_report_body_t::clear_has_attributes() {
-  _has_bits_[0] &= ~0x00000008u;
-}
-inline void protobuf_sgx_report_body_t::clear_attributes() {
-  if (attributes_ != NULL) attributes_->::protobuf_sgx_attributes_t::Clear();
-  clear_has_attributes();
-}
-inline const ::protobuf_sgx_attributes_t& protobuf_sgx_report_body_t::attributes() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.attributes)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return attributes_ != NULL ? *attributes_ : *default_instance().attributes_;
-#else
-  return attributes_ != NULL ? *attributes_ : *default_instance_->attributes_;
-#endif
-}
-inline ::protobuf_sgx_attributes_t* protobuf_sgx_report_body_t::mutable_attributes() {
-  set_has_attributes();
-  if (attributes_ == NULL) attributes_ = new ::protobuf_sgx_attributes_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_report_body_t.attributes)
-  return attributes_;
-}
-inline ::protobuf_sgx_attributes_t* protobuf_sgx_report_body_t::release_attributes() {
-  clear_has_attributes();
-  ::protobuf_sgx_attributes_t* temp = attributes_;
-  attributes_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_report_body_t::set_allocated_attributes(::protobuf_sgx_attributes_t* attributes) {
-  delete attributes_;
-  attributes_ = attributes;
-  if (attributes) {
-    set_has_attributes();
-  } else {
-    clear_has_attributes();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_report_body_t.attributes)
-}
-
-// repeated uint32 mr_enclave = 3 [packed = true];
-inline int protobuf_sgx_report_body_t::mr_enclave_size() const {
-  return mr_enclave_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_mr_enclave() {
-  mr_enclave_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::mr_enclave(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.mr_enclave)
-  return mr_enclave_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_mr_enclave(int index, ::google::protobuf::uint32 value) {
-  mr_enclave_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.mr_enclave)
-}
-inline void protobuf_sgx_report_body_t::add_mr_enclave(::google::protobuf::uint32 value) {
-  mr_enclave_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.mr_enclave)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::mr_enclave() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.mr_enclave)
-  return mr_enclave_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_mr_enclave() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.mr_enclave)
-  return &mr_enclave_;
-}
-
-// repeated uint32 reserved2 = 4 [packed = true];
-inline int protobuf_sgx_report_body_t::reserved2_size() const {
-  return reserved2_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_reserved2() {
-  reserved2_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::reserved2(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.reserved2)
-  return reserved2_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_reserved2(int index, ::google::protobuf::uint32 value) {
-  reserved2_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.reserved2)
-}
-inline void protobuf_sgx_report_body_t::add_reserved2(::google::protobuf::uint32 value) {
-  reserved2_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.reserved2)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::reserved2() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.reserved2)
-  return reserved2_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_reserved2() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.reserved2)
-  return &reserved2_;
-}
-
-// repeated uint32 mr_signer = 5 [packed = true];
-inline int protobuf_sgx_report_body_t::mr_signer_size() const {
-  return mr_signer_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_mr_signer() {
-  mr_signer_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::mr_signer(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.mr_signer)
-  return mr_signer_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_mr_signer(int index, ::google::protobuf::uint32 value) {
-  mr_signer_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.mr_signer)
-}
-inline void protobuf_sgx_report_body_t::add_mr_signer(::google::protobuf::uint32 value) {
-  mr_signer_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.mr_signer)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::mr_signer() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.mr_signer)
-  return mr_signer_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_mr_signer() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.mr_signer)
-  return &mr_signer_;
-}
-
-// repeated uint32 reserved3 = 6 [packed = true];
-inline int protobuf_sgx_report_body_t::reserved3_size() const {
-  return reserved3_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_reserved3() {
-  reserved3_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::reserved3(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.reserved3)
-  return reserved3_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_reserved3(int index, ::google::protobuf::uint32 value) {
-  reserved3_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.reserved3)
-}
-inline void protobuf_sgx_report_body_t::add_reserved3(::google::protobuf::uint32 value) {
-  reserved3_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.reserved3)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::reserved3() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.reserved3)
-  return reserved3_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_reserved3() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.reserved3)
-  return &reserved3_;
-}
-
-// required uint32 isv_prod_id = 11;
-inline bool protobuf_sgx_report_body_t::has_isv_prod_id() const {
-  return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void protobuf_sgx_report_body_t::set_has_isv_prod_id() {
-  _has_bits_[0] |= 0x00000100u;
-}
-inline void protobuf_sgx_report_body_t::clear_has_isv_prod_id() {
-  _has_bits_[0] &= ~0x00000100u;
-}
-inline void protobuf_sgx_report_body_t::clear_isv_prod_id() {
-  isv_prod_id_ = 0u;
-  clear_has_isv_prod_id();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::isv_prod_id() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.isv_prod_id)
-  return isv_prod_id_;
-}
-inline void protobuf_sgx_report_body_t::set_isv_prod_id(::google::protobuf::uint32 value) {
-  set_has_isv_prod_id();
-  isv_prod_id_ = value;
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.isv_prod_id)
-}
-
-// required uint32 isv_svn = 12;
-inline bool protobuf_sgx_report_body_t::has_isv_svn() const {
-  return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void protobuf_sgx_report_body_t::set_has_isv_svn() {
-  _has_bits_[0] |= 0x00000200u;
-}
-inline void protobuf_sgx_report_body_t::clear_has_isv_svn() {
-  _has_bits_[0] &= ~0x00000200u;
-}
-inline void protobuf_sgx_report_body_t::clear_isv_svn() {
-  isv_svn_ = 0u;
-  clear_has_isv_svn();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::isv_svn() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.isv_svn)
-  return isv_svn_;
-}
-inline void protobuf_sgx_report_body_t::set_isv_svn(::google::protobuf::uint32 value) {
-  set_has_isv_svn();
-  isv_svn_ = value;
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.isv_svn)
-}
-
-// repeated uint32 reserved4 = 7 [packed = true];
-inline int protobuf_sgx_report_body_t::reserved4_size() const {
-  return reserved4_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_reserved4() {
-  reserved4_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::reserved4(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.reserved4)
-  return reserved4_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_reserved4(int index, ::google::protobuf::uint32 value) {
-  reserved4_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.reserved4)
-}
-inline void protobuf_sgx_report_body_t::add_reserved4(::google::protobuf::uint32 value) {
-  reserved4_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.reserved4)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::reserved4() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.reserved4)
-  return reserved4_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_reserved4() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.reserved4)
-  return &reserved4_;
-}
-
-// repeated uint32 report_data = 8 [packed = true];
-inline int protobuf_sgx_report_body_t::report_data_size() const {
-  return report_data_.size();
-}
-inline void protobuf_sgx_report_body_t::clear_report_data() {
-  report_data_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_body_t::report_data(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_body_t.report_data)
-  return report_data_.Get(index);
-}
-inline void protobuf_sgx_report_body_t::set_report_data(int index, ::google::protobuf::uint32 value) {
-  report_data_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_body_t.report_data)
-}
-inline void protobuf_sgx_report_body_t::add_report_data(::google::protobuf::uint32 value) {
-  report_data_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_body_t.report_data)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_body_t::report_data() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_body_t.report_data)
-  return report_data_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_body_t::mutable_report_data() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_body_t.report_data)
-  return &report_data_;
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_report_t
-
-// required .protobuf_sgx_report_body_t body = 1;
-inline bool protobuf_sgx_report_t::has_body() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void protobuf_sgx_report_t::set_has_body() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void protobuf_sgx_report_t::clear_has_body() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void protobuf_sgx_report_t::clear_body() {
-  if (body_ != NULL) body_->::protobuf_sgx_report_body_t::Clear();
-  clear_has_body();
-}
-inline const ::protobuf_sgx_report_body_t& protobuf_sgx_report_t::body() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_t.body)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return body_ != NULL ? *body_ : *default_instance().body_;
-#else
-  return body_ != NULL ? *body_ : *default_instance_->body_;
-#endif
-}
-inline ::protobuf_sgx_report_body_t* protobuf_sgx_report_t::mutable_body() {
-  set_has_body();
-  if (body_ == NULL) body_ = new ::protobuf_sgx_report_body_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_report_t.body)
-  return body_;
-}
-inline ::protobuf_sgx_report_body_t* protobuf_sgx_report_t::release_body() {
-  clear_has_body();
-  ::protobuf_sgx_report_body_t* temp = body_;
-  body_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_report_t::set_allocated_body(::protobuf_sgx_report_body_t* body) {
-  delete body_;
-  body_ = body;
-  if (body) {
-    set_has_body();
-  } else {
-    clear_has_body();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_report_t.body)
-}
-
-// repeated uint32 key_id = 2 [packed = true];
-inline int protobuf_sgx_report_t::key_id_size() const {
-  return key_id_.size();
-}
-inline void protobuf_sgx_report_t::clear_key_id() {
-  key_id_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_t::key_id(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_t.key_id)
-  return key_id_.Get(index);
-}
-inline void protobuf_sgx_report_t::set_key_id(int index, ::google::protobuf::uint32 value) {
-  key_id_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_t.key_id)
-}
-inline void protobuf_sgx_report_t::add_key_id(::google::protobuf::uint32 value) {
-  key_id_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_t.key_id)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_t::key_id() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_t.key_id)
-  return key_id_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_t::mutable_key_id() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_t.key_id)
-  return &key_id_;
-}
-
-// repeated uint32 mac = 3 [packed = true];
-inline int protobuf_sgx_report_t::mac_size() const {
-  return mac_.size();
-}
-inline void protobuf_sgx_report_t::clear_mac() {
-  mac_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_report_t::mac(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_report_t.mac)
-  return mac_.Get(index);
-}
-inline void protobuf_sgx_report_t::set_mac(int index, ::google::protobuf::uint32 value) {
-  mac_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_report_t.mac)
-}
-inline void protobuf_sgx_report_t::add_mac(::google::protobuf::uint32 value) {
-  mac_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_report_t.mac)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_report_t::mac() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_report_t.mac)
-  return mac_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_report_t::mutable_mac() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_report_t.mac)
-  return &mac_;
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_target_info_t
-
-// repeated uint32 mr_enclave = 1 [packed = true];
-inline int protobuf_sgx_target_info_t::mr_enclave_size() const {
-  return mr_enclave_.size();
-}
-inline void protobuf_sgx_target_info_t::clear_mr_enclave() {
-  mr_enclave_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_target_info_t::mr_enclave(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_target_info_t.mr_enclave)
-  return mr_enclave_.Get(index);
-}
-inline void protobuf_sgx_target_info_t::set_mr_enclave(int index, ::google::protobuf::uint32 value) {
-  mr_enclave_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_target_info_t.mr_enclave)
-}
-inline void protobuf_sgx_target_info_t::add_mr_enclave(::google::protobuf::uint32 value) {
-  mr_enclave_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_target_info_t.mr_enclave)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_target_info_t::mr_enclave() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_target_info_t.mr_enclave)
-  return mr_enclave_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_target_info_t::mutable_mr_enclave() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_target_info_t.mr_enclave)
-  return &mr_enclave_;
-}
-
-// required .protobuf_sgx_attributes_t attributes = 4;
-inline bool protobuf_sgx_target_info_t::has_attributes() const {
-  return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void protobuf_sgx_target_info_t::set_has_attributes() {
-  _has_bits_[0] |= 0x00000002u;
-}
-inline void protobuf_sgx_target_info_t::clear_has_attributes() {
-  _has_bits_[0] &= ~0x00000002u;
-}
-inline void protobuf_sgx_target_info_t::clear_attributes() {
-  if (attributes_ != NULL) attributes_->::protobuf_sgx_attributes_t::Clear();
-  clear_has_attributes();
-}
-inline const ::protobuf_sgx_attributes_t& protobuf_sgx_target_info_t::attributes() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_target_info_t.attributes)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return attributes_ != NULL ? *attributes_ : *default_instance().attributes_;
-#else
-  return attributes_ != NULL ? *attributes_ : *default_instance_->attributes_;
-#endif
-}
-inline ::protobuf_sgx_attributes_t* protobuf_sgx_target_info_t::mutable_attributes() {
-  set_has_attributes();
-  if (attributes_ == NULL) attributes_ = new ::protobuf_sgx_attributes_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_target_info_t.attributes)
-  return attributes_;
-}
-inline ::protobuf_sgx_attributes_t* protobuf_sgx_target_info_t::release_attributes() {
-  clear_has_attributes();
-  ::protobuf_sgx_attributes_t* temp = attributes_;
-  attributes_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_target_info_t::set_allocated_attributes(::protobuf_sgx_attributes_t* attributes) {
-  delete attributes_;
-  attributes_ = attributes;
-  if (attributes) {
-    set_has_attributes();
-  } else {
-    clear_has_attributes();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_target_info_t.attributes)
-}
-
-// repeated uint32 reserved1 = 2 [packed = true];
-inline int protobuf_sgx_target_info_t::reserved1_size() const {
-  return reserved1_.size();
-}
-inline void protobuf_sgx_target_info_t::clear_reserved1() {
-  reserved1_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_target_info_t::reserved1(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_target_info_t.reserved1)
-  return reserved1_.Get(index);
-}
-inline void protobuf_sgx_target_info_t::set_reserved1(int index, ::google::protobuf::uint32 value) {
-  reserved1_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_target_info_t.reserved1)
-}
-inline void protobuf_sgx_target_info_t::add_reserved1(::google::protobuf::uint32 value) {
-  reserved1_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_target_info_t.reserved1)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_target_info_t::reserved1() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_target_info_t.reserved1)
-  return reserved1_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_target_info_t::mutable_reserved1() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_target_info_t.reserved1)
-  return &reserved1_;
-}
-
-// required uint32 misc_select = 5;
-inline bool protobuf_sgx_target_info_t::has_misc_select() const {
-  return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void protobuf_sgx_target_info_t::set_has_misc_select() {
-  _has_bits_[0] |= 0x00000008u;
-}
-inline void protobuf_sgx_target_info_t::clear_has_misc_select() {
-  _has_bits_[0] &= ~0x00000008u;
-}
-inline void protobuf_sgx_target_info_t::clear_misc_select() {
-  misc_select_ = 0u;
-  clear_has_misc_select();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_target_info_t::misc_select() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_target_info_t.misc_select)
-  return misc_select_;
-}
-inline void protobuf_sgx_target_info_t::set_misc_select(::google::protobuf::uint32 value) {
-  set_has_misc_select();
-  misc_select_ = value;
-  // @@protoc_insertion_point(field_set:protobuf_sgx_target_info_t.misc_select)
-}
-
-// repeated uint32 reserved2 = 3 [packed = true];
-inline int protobuf_sgx_target_info_t::reserved2_size() const {
-  return reserved2_.size();
-}
-inline void protobuf_sgx_target_info_t::clear_reserved2() {
-  reserved2_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_target_info_t::reserved2(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_target_info_t.reserved2)
-  return reserved2_.Get(index);
-}
-inline void protobuf_sgx_target_info_t::set_reserved2(int index, ::google::protobuf::uint32 value) {
-  reserved2_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_target_info_t.reserved2)
-}
-inline void protobuf_sgx_target_info_t::add_reserved2(::google::protobuf::uint32 value) {
-  reserved2_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_target_info_t.reserved2)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_target_info_t::reserved2() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_target_info_t.reserved2)
-  return reserved2_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_target_info_t::mutable_reserved2() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_target_info_t.reserved2)
-  return &reserved2_;
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_dh_msg1_t
-
-// required .protobuf_sgx_ec256_public_t g_a = 1;
-inline bool protobuf_sgx_dh_msg1_t::has_g_a() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void protobuf_sgx_dh_msg1_t::set_has_g_a() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void protobuf_sgx_dh_msg1_t::clear_has_g_a() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void protobuf_sgx_dh_msg1_t::clear_g_a() {
-  if (g_a_ != NULL) g_a_->::protobuf_sgx_ec256_public_t::Clear();
-  clear_has_g_a();
-}
-inline const ::protobuf_sgx_ec256_public_t& protobuf_sgx_dh_msg1_t::g_a() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg1_t.g_a)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return g_a_ != NULL ? *g_a_ : *default_instance().g_a_;
-#else
-  return g_a_ != NULL ? *g_a_ : *default_instance_->g_a_;
-#endif
-}
-inline ::protobuf_sgx_ec256_public_t* protobuf_sgx_dh_msg1_t::mutable_g_a() {
-  set_has_g_a();
-  if (g_a_ == NULL) g_a_ = new ::protobuf_sgx_ec256_public_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_dh_msg1_t.g_a)
-  return g_a_;
-}
-inline ::protobuf_sgx_ec256_public_t* protobuf_sgx_dh_msg1_t::release_g_a() {
-  clear_has_g_a();
-  ::protobuf_sgx_ec256_public_t* temp = g_a_;
-  g_a_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_dh_msg1_t::set_allocated_g_a(::protobuf_sgx_ec256_public_t* g_a) {
-  delete g_a_;
-  g_a_ = g_a;
-  if (g_a) {
-    set_has_g_a();
-  } else {
-    clear_has_g_a();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_dh_msg1_t.g_a)
-}
-
-// required .protobuf_sgx_target_info_t target = 2;
-inline bool protobuf_sgx_dh_msg1_t::has_target() const {
-  return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void protobuf_sgx_dh_msg1_t::set_has_target() {
-  _has_bits_[0] |= 0x00000002u;
-}
-inline void protobuf_sgx_dh_msg1_t::clear_has_target() {
-  _has_bits_[0] &= ~0x00000002u;
-}
-inline void protobuf_sgx_dh_msg1_t::clear_target() {
-  if (target_ != NULL) target_->::protobuf_sgx_target_info_t::Clear();
-  clear_has_target();
-}
-inline const ::protobuf_sgx_target_info_t& protobuf_sgx_dh_msg1_t::target() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg1_t.target)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return target_ != NULL ? *target_ : *default_instance().target_;
-#else
-  return target_ != NULL ? *target_ : *default_instance_->target_;
-#endif
-}
-inline ::protobuf_sgx_target_info_t* protobuf_sgx_dh_msg1_t::mutable_target() {
-  set_has_target();
-  if (target_ == NULL) target_ = new ::protobuf_sgx_target_info_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_dh_msg1_t.target)
-  return target_;
-}
-inline ::protobuf_sgx_target_info_t* protobuf_sgx_dh_msg1_t::release_target() {
-  clear_has_target();
-  ::protobuf_sgx_target_info_t* temp = target_;
-  target_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_dh_msg1_t::set_allocated_target(::protobuf_sgx_target_info_t* target) {
-  delete target_;
-  target_ = target;
-  if (target) {
-    set_has_target();
-  } else {
-    clear_has_target();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_dh_msg1_t.target)
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_dh_msg2_t
-
-// required .protobuf_sgx_ec256_public_t g_b = 1;
-inline bool protobuf_sgx_dh_msg2_t::has_g_b() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void protobuf_sgx_dh_msg2_t::set_has_g_b() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void protobuf_sgx_dh_msg2_t::clear_has_g_b() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void protobuf_sgx_dh_msg2_t::clear_g_b() {
-  if (g_b_ != NULL) g_b_->::protobuf_sgx_ec256_public_t::Clear();
-  clear_has_g_b();
-}
-inline const ::protobuf_sgx_ec256_public_t& protobuf_sgx_dh_msg2_t::g_b() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg2_t.g_b)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return g_b_ != NULL ? *g_b_ : *default_instance().g_b_;
-#else
-  return g_b_ != NULL ? *g_b_ : *default_instance_->g_b_;
-#endif
-}
-inline ::protobuf_sgx_ec256_public_t* protobuf_sgx_dh_msg2_t::mutable_g_b() {
-  set_has_g_b();
-  if (g_b_ == NULL) g_b_ = new ::protobuf_sgx_ec256_public_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_dh_msg2_t.g_b)
-  return g_b_;
-}
-inline ::protobuf_sgx_ec256_public_t* protobuf_sgx_dh_msg2_t::release_g_b() {
-  clear_has_g_b();
-  ::protobuf_sgx_ec256_public_t* temp = g_b_;
-  g_b_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_dh_msg2_t::set_allocated_g_b(::protobuf_sgx_ec256_public_t* g_b) {
-  delete g_b_;
-  g_b_ = g_b;
-  if (g_b) {
-    set_has_g_b();
-  } else {
-    clear_has_g_b();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_dh_msg2_t.g_b)
-}
-
-// required .protobuf_sgx_report_t report = 2;
-inline bool protobuf_sgx_dh_msg2_t::has_report() const {
-  return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void protobuf_sgx_dh_msg2_t::set_has_report() {
-  _has_bits_[0] |= 0x00000002u;
-}
-inline void protobuf_sgx_dh_msg2_t::clear_has_report() {
-  _has_bits_[0] &= ~0x00000002u;
-}
-inline void protobuf_sgx_dh_msg2_t::clear_report() {
-  if (report_ != NULL) report_->::protobuf_sgx_report_t::Clear();
-  clear_has_report();
-}
-inline const ::protobuf_sgx_report_t& protobuf_sgx_dh_msg2_t::report() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg2_t.report)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return report_ != NULL ? *report_ : *default_instance().report_;
-#else
-  return report_ != NULL ? *report_ : *default_instance_->report_;
-#endif
-}
-inline ::protobuf_sgx_report_t* protobuf_sgx_dh_msg2_t::mutable_report() {
-  set_has_report();
-  if (report_ == NULL) report_ = new ::protobuf_sgx_report_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_dh_msg2_t.report)
-  return report_;
-}
-inline ::protobuf_sgx_report_t* protobuf_sgx_dh_msg2_t::release_report() {
-  clear_has_report();
-  ::protobuf_sgx_report_t* temp = report_;
-  report_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_dh_msg2_t::set_allocated_report(::protobuf_sgx_report_t* report) {
-  delete report_;
-  report_ = report;
-  if (report) {
-    set_has_report();
-  } else {
-    clear_has_report();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_dh_msg2_t.report)
-}
-
-// repeated uint32 cmac = 3 [packed = true];
-inline int protobuf_sgx_dh_msg2_t::cmac_size() const {
-  return cmac_.size();
-}
-inline void protobuf_sgx_dh_msg2_t::clear_cmac() {
-  cmac_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_dh_msg2_t::cmac(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg2_t.cmac)
-  return cmac_.Get(index);
-}
-inline void protobuf_sgx_dh_msg2_t::set_cmac(int index, ::google::protobuf::uint32 value) {
-  cmac_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_dh_msg2_t.cmac)
-}
-inline void protobuf_sgx_dh_msg2_t::add_cmac(::google::protobuf::uint32 value) {
-  cmac_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_dh_msg2_t.cmac)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_dh_msg2_t::cmac() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_dh_msg2_t.cmac)
-  return cmac_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_dh_msg2_t::mutable_cmac() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_dh_msg2_t.cmac)
-  return &cmac_;
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_dh_msg3_body_t
-
-// required .protobuf_sgx_report_t report = 1;
-inline bool protobuf_sgx_dh_msg3_body_t::has_report() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void protobuf_sgx_dh_msg3_body_t::set_has_report() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void protobuf_sgx_dh_msg3_body_t::clear_has_report() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void protobuf_sgx_dh_msg3_body_t::clear_report() {
-  if (report_ != NULL) report_->::protobuf_sgx_report_t::Clear();
-  clear_has_report();
-}
-inline const ::protobuf_sgx_report_t& protobuf_sgx_dh_msg3_body_t::report() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg3_body_t.report)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return report_ != NULL ? *report_ : *default_instance().report_;
-#else
-  return report_ != NULL ? *report_ : *default_instance_->report_;
-#endif
-}
-inline ::protobuf_sgx_report_t* protobuf_sgx_dh_msg3_body_t::mutable_report() {
-  set_has_report();
-  if (report_ == NULL) report_ = new ::protobuf_sgx_report_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_dh_msg3_body_t.report)
-  return report_;
-}
-inline ::protobuf_sgx_report_t* protobuf_sgx_dh_msg3_body_t::release_report() {
-  clear_has_report();
-  ::protobuf_sgx_report_t* temp = report_;
-  report_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_dh_msg3_body_t::set_allocated_report(::protobuf_sgx_report_t* report) {
-  delete report_;
-  report_ = report;
-  if (report) {
-    set_has_report();
-  } else {
-    clear_has_report();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_dh_msg3_body_t.report)
-}
-
-// repeated uint32 additional_prop = 2;
-inline int protobuf_sgx_dh_msg3_body_t::additional_prop_size() const {
-  return additional_prop_.size();
-}
-inline void protobuf_sgx_dh_msg3_body_t::clear_additional_prop() {
-  additional_prop_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_dh_msg3_body_t::additional_prop(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg3_body_t.additional_prop)
-  return additional_prop_.Get(index);
-}
-inline void protobuf_sgx_dh_msg3_body_t::set_additional_prop(int index, ::google::protobuf::uint32 value) {
-  additional_prop_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_dh_msg3_body_t.additional_prop)
-}
-inline void protobuf_sgx_dh_msg3_body_t::add_additional_prop(::google::protobuf::uint32 value) {
-  additional_prop_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_dh_msg3_body_t.additional_prop)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_dh_msg3_body_t::additional_prop() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_dh_msg3_body_t.additional_prop)
-  return additional_prop_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_dh_msg3_body_t::mutable_additional_prop() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_dh_msg3_body_t.additional_prop)
-  return &additional_prop_;
-}
-
-// -------------------------------------------------------------------
-
-// protobuf_sgx_dh_msg3_t
-
-// required .protobuf_sgx_dh_msg3_body_t msg3_body = 1;
-inline bool protobuf_sgx_dh_msg3_t::has_msg3_body() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void protobuf_sgx_dh_msg3_t::set_has_msg3_body() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void protobuf_sgx_dh_msg3_t::clear_has_msg3_body() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void protobuf_sgx_dh_msg3_t::clear_msg3_body() {
-  if (msg3_body_ != NULL) msg3_body_->::protobuf_sgx_dh_msg3_body_t::Clear();
-  clear_has_msg3_body();
-}
-inline const ::protobuf_sgx_dh_msg3_body_t& protobuf_sgx_dh_msg3_t::msg3_body() const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg3_t.msg3_body)
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-  return msg3_body_ != NULL ? *msg3_body_ : *default_instance().msg3_body_;
-#else
-  return msg3_body_ != NULL ? *msg3_body_ : *default_instance_->msg3_body_;
-#endif
-}
-inline ::protobuf_sgx_dh_msg3_body_t* protobuf_sgx_dh_msg3_t::mutable_msg3_body() {
-  set_has_msg3_body();
-  if (msg3_body_ == NULL) msg3_body_ = new ::protobuf_sgx_dh_msg3_body_t;
-  // @@protoc_insertion_point(field_mutable:protobuf_sgx_dh_msg3_t.msg3_body)
-  return msg3_body_;
-}
-inline ::protobuf_sgx_dh_msg3_body_t* protobuf_sgx_dh_msg3_t::release_msg3_body() {
-  clear_has_msg3_body();
-  ::protobuf_sgx_dh_msg3_body_t* temp = msg3_body_;
-  msg3_body_ = NULL;
-  return temp;
-}
-inline void protobuf_sgx_dh_msg3_t::set_allocated_msg3_body(::protobuf_sgx_dh_msg3_body_t* msg3_body) {
-  delete msg3_body_;
-  msg3_body_ = msg3_body;
-  if (msg3_body) {
-    set_has_msg3_body();
-  } else {
-    clear_has_msg3_body();
-  }
-  // @@protoc_insertion_point(field_set_allocated:protobuf_sgx_dh_msg3_t.msg3_body)
-}
-
-// repeated uint32 cmac = 2 [packed = true];
-inline int protobuf_sgx_dh_msg3_t::cmac_size() const {
-  return cmac_.size();
-}
-inline void protobuf_sgx_dh_msg3_t::clear_cmac() {
-  cmac_.Clear();
-}
-inline ::google::protobuf::uint32 protobuf_sgx_dh_msg3_t::cmac(int index) const {
-  // @@protoc_insertion_point(field_get:protobuf_sgx_dh_msg3_t.cmac)
-  return cmac_.Get(index);
-}
-inline void protobuf_sgx_dh_msg3_t::set_cmac(int index, ::google::protobuf::uint32 value) {
-  cmac_.Set(index, value);
-  // @@protoc_insertion_point(field_set:protobuf_sgx_dh_msg3_t.cmac)
-}
-inline void protobuf_sgx_dh_msg3_t::add_cmac(::google::protobuf::uint32 value) {
-  cmac_.Add(value);
-  // @@protoc_insertion_point(field_add:protobuf_sgx_dh_msg3_t.cmac)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-protobuf_sgx_dh_msg3_t::cmac() const {
-  // @@protoc_insertion_point(field_list:protobuf_sgx_dh_msg3_t.cmac)
-  return cmac_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-protobuf_sgx_dh_msg3_t::mutable_cmac() {
-  // @@protoc_insertion_point(field_mutable_list:protobuf_sgx_dh_msg3_t.cmac)
-  return &cmac_;
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-// @@protoc_insertion_point(global_scope)
-
-#endif  // PROTOBUF_dhmsgs_2eproto__INCLUDED

+ 177 - 0
include/ProtobufLAMessages.pb.h

@@ -39,6 +39,7 @@ class protobuf_sgx_dh_msg1_t;
 class protobuf_sgx_dh_msg2_t;
 class protobuf_sgx_dh_msg3_body_t;
 class protobuf_sgx_dh_msg3_t;
+class protobuf_post_LA_encrypted_msg_t;
 
 // ===================================================================
 
@@ -1188,6 +1189,102 @@ class protobuf_sgx_dh_msg3_t : public ::google::protobuf::MessageLite {
   void InitAsDefaultInstance();
   static protobuf_sgx_dh_msg3_t* default_instance_;
 };
+// -------------------------------------------------------------------
+
+class protobuf_post_LA_encrypted_msg_t : public ::google::protobuf::MessageLite {
+ public:
+  protobuf_post_LA_encrypted_msg_t();
+  virtual ~protobuf_post_LA_encrypted_msg_t();
+
+  protobuf_post_LA_encrypted_msg_t(const protobuf_post_LA_encrypted_msg_t& from);
+
+  inline protobuf_post_LA_encrypted_msg_t& operator=(const protobuf_post_LA_encrypted_msg_t& from) {
+    CopyFrom(from);
+    return *this;
+  }
+
+  inline const ::std::string& unknown_fields() const {
+    return _unknown_fields_;
+  }
+
+  inline ::std::string* mutable_unknown_fields() {
+    return &_unknown_fields_;
+  }
+
+  static const protobuf_post_LA_encrypted_msg_t& default_instance();
+
+  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
+  // Returns the internal default instance pointer. This function can
+  // return NULL thus should not be used by the user. This is intended
+  // for Protobuf internal code. Please use default_instance() declared
+  // above instead.
+  static inline const protobuf_post_LA_encrypted_msg_t* internal_default_instance() {
+    return default_instance_;
+  }
+  #endif
+
+  void Swap(protobuf_post_LA_encrypted_msg_t* other);
+
+  // implements Message ----------------------------------------------
+
+  protobuf_post_LA_encrypted_msg_t* New() const;
+  void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
+  void CopyFrom(const protobuf_post_LA_encrypted_msg_t& from);
+  void MergeFrom(const protobuf_post_LA_encrypted_msg_t& from);
+  void Clear();
+  bool IsInitialized() const;
+
+  int ByteSize() const;
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input);
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const;
+  void DiscardUnknownFields();
+  int GetCachedSize() const { return _cached_size_; }
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const;
+  public:
+  ::std::string GetTypeName() const;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  // required bytes msg = 1;
+  inline bool has_msg() const;
+  inline void clear_msg();
+  static const int kMsgFieldNumber = 1;
+  inline const ::std::string& msg() const;
+  inline void set_msg(const ::std::string& value);
+  inline void set_msg(const char* value);
+  inline void set_msg(const void* value, size_t size);
+  inline ::std::string* mutable_msg();
+  inline ::std::string* release_msg();
+  inline void set_allocated_msg(::std::string* msg);
+
+  // @@protoc_insertion_point(class_scope:protobuf_post_LA_encrypted_msg_t)
+ private:
+  inline void set_has_msg();
+  inline void clear_has_msg();
+
+  ::std::string _unknown_fields_;
+
+  ::google::protobuf::uint32 _has_bits_[1];
+  mutable int _cached_size_;
+  ::std::string* msg_;
+  #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
+  friend void  protobuf_AddDesc_ProtobufLAMessages_2eproto_impl();
+  #else
+  friend void  protobuf_AddDesc_ProtobufLAMessages_2eproto();
+  #endif
+  friend void protobuf_AssignDesc_ProtobufLAMessages_2eproto();
+  friend void protobuf_ShutdownFile_ProtobufLAMessages_2eproto();
+
+  void InitAsDefaultInstance();
+  static protobuf_post_LA_encrypted_msg_t* default_instance_;
+};
 // ===================================================================
 
 
@@ -2316,6 +2413,86 @@ protobuf_sgx_dh_msg3_t::mutable_cmac() {
   return &cmac_;
 }
 
+// -------------------------------------------------------------------
+
+// protobuf_post_LA_encrypted_msg_t
+
+// required bytes msg = 1;
+inline bool protobuf_post_LA_encrypted_msg_t::has_msg() const {
+  return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void protobuf_post_LA_encrypted_msg_t::set_has_msg() {
+  _has_bits_[0] |= 0x00000001u;
+}
+inline void protobuf_post_LA_encrypted_msg_t::clear_has_msg() {
+  _has_bits_[0] &= ~0x00000001u;
+}
+inline void protobuf_post_LA_encrypted_msg_t::clear_msg() {
+  if (msg_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    msg_->clear();
+  }
+  clear_has_msg();
+}
+inline const ::std::string& protobuf_post_LA_encrypted_msg_t::msg() const {
+  // @@protoc_insertion_point(field_get:protobuf_post_LA_encrypted_msg_t.msg)
+  return *msg_;
+}
+inline void protobuf_post_LA_encrypted_msg_t::set_msg(const ::std::string& value) {
+  set_has_msg();
+  if (msg_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    msg_ = new ::std::string;
+  }
+  msg_->assign(value);
+  // @@protoc_insertion_point(field_set:protobuf_post_LA_encrypted_msg_t.msg)
+}
+inline void protobuf_post_LA_encrypted_msg_t::set_msg(const char* value) {
+  set_has_msg();
+  if (msg_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    msg_ = new ::std::string;
+  }
+  msg_->assign(value);
+  // @@protoc_insertion_point(field_set_char:protobuf_post_LA_encrypted_msg_t.msg)
+}
+inline void protobuf_post_LA_encrypted_msg_t::set_msg(const void* value, size_t size) {
+  set_has_msg();
+  if (msg_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    msg_ = new ::std::string;
+  }
+  msg_->assign(reinterpret_cast<const char*>(value), size);
+  // @@protoc_insertion_point(field_set_pointer:protobuf_post_LA_encrypted_msg_t.msg)
+}
+inline ::std::string* protobuf_post_LA_encrypted_msg_t::mutable_msg() {
+  set_has_msg();
+  if (msg_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    msg_ = new ::std::string;
+  }
+  // @@protoc_insertion_point(field_mutable:protobuf_post_LA_encrypted_msg_t.msg)
+  return msg_;
+}
+inline ::std::string* protobuf_post_LA_encrypted_msg_t::release_msg() {
+  clear_has_msg();
+  if (msg_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    return NULL;
+  } else {
+    ::std::string* temp = msg_;
+    msg_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+    return temp;
+  }
+}
+inline void protobuf_post_LA_encrypted_msg_t::set_allocated_msg(::std::string* msg) {
+  if (msg_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    delete msg_;
+  }
+  if (msg) {
+    set_has_msg();
+    msg_ = msg;
+  } else {
+    clear_has_msg();
+    msg_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  }
+  // @@protoc_insertion_point(field_set_allocated:protobuf_post_LA_encrypted_msg_t.msg)
+}
+
 
 // @@protoc_insertion_point(namespace_scope)
 

+ 1 - 2
include/SgxProtobufLAInitiator.h

@@ -1,5 +1,4 @@
 uint32_t process_protobuf_dh_msg1_generate_protobuf_dh_msg2(protobuf_sgx_dh_msg1_t& protobuf_msg1, protobuf_sgx_dh_msg2_t& protobuf_msg2, uint32_t* session_id);
 uint32_t process_protobuf_dh_msg3(protobuf_sgx_dh_msg3_t& protobuf_msg3, uint32_t* session_id);
-//uint32_t generate_encrypted_rsa_keypair_hash(uint8_t* hash, uint8_t* tag);
-uint32_t decrypt_wrapper(uint8_t* ciphertext, int ciphertext_len, uint8_t* op_plaintext, int* op_plaintext_len, uint8_t* ip_encrypted_tag);
+uint32_t aes_gcm_wrapper(int enc, unsigned char* ciphertext, int ciphertext_len, unsigned char* op_plaintext, int* op_plaintext_len, unsigned char* ip_encrypted_tag);
 

+ 2 - 1
include/crypto.h

@@ -1,2 +1,3 @@
-int aes_cipher(int enc, unsigned char *key, unsigned char *iv, unsigned char* plaintext, int plaintext_len, unsigned char *ciphertext,  int* op_ciphertext_len, unsigned char* tag); 
+int aes_gcm(int enc, unsigned char *key, unsigned char *iv, unsigned char* plaintext, int plaintext_len, unsigned char *ciphertext,  int* op_ciphertext_len, unsigned char* tag); 
 uint32_t base64_encoding_wrapper(unsigned char* src, unsigned char* dest, uint32_t length);
+uint32_t base64_decoding_wrapper(unsigned char* src, unsigned char* dest, uint32_t length);

BIN
localattestation_decryption.so


+ 41 - 7
systemMain.cpp

@@ -60,16 +60,12 @@ class Mitigator : public Php::Base
 		fflush(stdout);
 		local_attestation_successful=1; 
 		printf("length of string was %d\n", mitigator_pubkey_header.length()); fflush(stdout); 
-//		char* base64_encoding = (char*) malloc(); 
-//		char base64_encoding[229];
-//		for(count=0;count<229;count++)
-//			base64_encoding[count]=base64_encoded_mitigator_header[count];
 		mitigator_pubkey_header_value=std::string((char*)base64_encoded_mitigator_header_and_value,mitigator_pubkey_header.length()+216); 
 		}
 	}
 
 
-		Mitigator() = default; // mitigator_pubkey_header("Mitigator-Public-Key:");//, mitigator_pubkey_header_value("!") ;
+		Mitigator() = default; 
 		virtual ~Mitigator() = default;
 		// call this function in PHP async or call add_header here. 
 		static Php::Value get_mitigator_header() 
@@ -79,7 +75,45 @@ class Mitigator : public Php::Base
 		// call this func onRequest 
 		static Php::Value php_decrypt_wrapper(Php::Parameters &params   )
 		{
-			return params[0];//"miti"; 
+			int counter; 
+			unsigned char* plaintext_user_data; 
+			unsigned char* ciphertext_user_data;
+			unsigned char* base64_encoded_pub_key; 
+			Php::Value ciphertext_user_data_obj=params[1]; 
+			Php::Value base64_encoded_pub_key_obj=params[0];
+			uint32_t ciphertext_length;
+			uint32_t plaintext_length;
+
+			ciphertext_length = params[1].size();
+			plaintext_user_data = (unsigned char*) malloc(ciphertext_length); 
+			// TODO: The arrays returned by the const char* operator in PHP-CPP are highly likely to be null-terminated. 
+			ciphertext_user_data = (unsigned char*) static_cast<const char*>(ciphertext_user_data_obj);
+                        base64_encoded_pub_key = (unsigned char*) static_cast<const char*>(base64_encoded_pub_key_obj);
+
+			printf("Base64 encoded key:\n");
+			for(counter=0; counter < 88; counter++)
+				printf("%c ", base64_encoded_pub_key[counter]);
+			printf("\n"); fflush(stdout); 
+
+			printf("Ciphertext received:\n");
+			for(counter=0 ; counter < ciphertext_length; counter++ )
+				printf("0x%02x ", ciphertext_user_data[counter]);
+			printf("\n"); fflush(stdout); 
+
+			uint32_t ret_status=decrypt_client_data_through_decryptor(base64_encoded_pub_key, ciphertext_user_data, ciphertext_length, (unsigned char*) plaintext_user_data, &plaintext_length);
+			if(ret_status != 0)
+			{
+				printf("Received error code: 0x%02x\n", ret_status); fflush(stdout);
+			}
+
+			printf("Going to return this plaintext:\n");
+			for(counter=0;counter<plaintext_length;counter++)
+				printf("0x%02x ", plaintext_user_data[counter]);
+			fflush(stdout); 
+
+			std::string plaintext_user_data_str = std::string((char*) plaintext_user_data, plaintext_length); 
+			free(plaintext_user_data);
+			return plaintext_user_data_str; // "Miti";// plaintext_user_data_obj; // (ciphertext_user_data, ciphertext_length) ; 
 		}
 
 };
@@ -98,7 +132,7 @@ extern "C" {
 	mitigator.method<&Mitigator::get_mitigator_header>("get_mitigator_header");
 //        mitigator.property("mitigator_header", &Mitigator::get_mitigator_header);
 	mitigator.method<&Mitigator::local_attestation_initiator_wrapper>("local_attestation_initiator_wrapper"); 
-	mitigator.method<&Mitigator::php_decrypt_wrapper>("php_decrypt_wrapper", { Php::ByVal("string", Php::Type::String) }   ); 
+	mitigator.method<&Mitigator::php_decrypt_wrapper>("php_decrypt_wrapper", { Php::ByVal("string", Php::Type::String), Php::ByVal("string", Php::Type::String) }   ); 
         extension.onStartup(&Mitigator::local_attestation_initiator_wrapper);
 //	extension.onRequest(&Mitigator::php_decrypt_wrapper); 
         // return the extension module