Browse Source

Added in ECDHE key generation code - does not work with 2 implementations on JS side

dettanym 5 years ago
parent
commit
6e1febba9c

+ 1 - 2
App/App.cpp

@@ -237,6 +237,7 @@ int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[])
         return 0xFFFFFFFF;
     }
 
+	// Does decryption too - should probs rename it 
     ret_status=local_attestation_initiator(3825, e2_enclave_id);
     if(ret_status!=0)
     {
@@ -245,8 +246,6 @@ int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[])
     }
 
 
-
-
 /*    // LA with the apache - currently set to return failure - should change it to success when the code to send the mrsigner from the verifier to the decryptor is added- TODO: <--- that 
     ret_status=local_attestation_initiator(3826, e2_enclave_id); // TODO: Change port or sth
     if(ret_status!=0)

+ 30 - 17
App/ProtobufLAMessages.pb.cpp

@@ -3020,6 +3020,7 @@ protobuf_post_LA_encrypted_msg_t::protobuf_post_LA_encrypted_msg_t(const protobu
 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_));
 }
 
@@ -3029,6 +3030,9 @@ protobuf_post_LA_encrypted_msg_t::~protobuf_post_LA_encrypted_msg_t() {
 }
 
 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
@@ -3058,7 +3062,11 @@ protobuf_post_LA_encrypted_msg_t* protobuf_post_LA_encrypted_msg_t::New() const
 }
 
 void protobuf_post_LA_encrypted_msg_t::Clear() {
-  msg_.Clear();
+  if (has_msg()) {
+    if (msg_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+      msg_->clear();
+    }
+  }
   ::memset(_has_bits_, 0, sizeof(_has_bits_));
   mutable_unknown_fields()->clear();
 }
@@ -3077,16 +3085,14 @@ bool protobuf_post_LA_encrypted_msg_t::MergePartialFromCodedStream(
     tag = p.first;
     if (!p.second) goto handle_unusual;
     switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // repeated bytes msg = 1;
+      // required bytes msg = 1;
       case 1: {
         if (tag == 10) {
-         parse_msg:
           DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
-                input, this->add_msg()));
+                input, this->mutable_msg()));
         } else {
           goto handle_unusual;
         }
-        if (input->ExpectTag(10)) goto parse_msg;
         if (input->ExpectAtEnd()) goto success;
         break;
       }
@@ -3116,10 +3122,10 @@ failure:
 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)
-  // repeated bytes msg = 1;
-  for (int i = 0; i < this->msg_size(); i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteBytes(
-      1, this->msg(i), output);
+  // required bytes msg = 1;
+  if (has_msg()) {
+    ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
+      1, this->msg(), output);
   }
 
   output->WriteRaw(unknown_fields().data(),
@@ -3130,13 +3136,15 @@ void protobuf_post_LA_encrypted_msg_t::SerializeWithCachedSizes(
 int protobuf_post_LA_encrypted_msg_t::ByteSize() const {
   int total_size = 0;
 
-  // repeated bytes msg = 1;
-  total_size += 1 * this->msg_size();
-  for (int i = 0; i < this->msg_size(); i++) {
-    total_size += ::google::protobuf::internal::WireFormatLite::BytesSize(
-      this->msg(i));
-  }
+  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();
@@ -3152,7 +3160,11 @@ void protobuf_post_LA_encrypted_msg_t::CheckTypeAndMergeFrom(
 
 void protobuf_post_LA_encrypted_msg_t::MergeFrom(const protobuf_post_LA_encrypted_msg_t& from) {
   GOOGLE_CHECK_NE(&from, this);
-  msg_.MergeFrom(from.msg_);
+  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+    if (from.has_msg()) {
+      set_msg(from.msg());
+    }
+  }
   mutable_unknown_fields()->append(from.unknown_fields());
 }
 
@@ -3163,13 +3175,14 @@ void protobuf_post_LA_encrypted_msg_t::CopyFrom(const protobuf_post_LA_encrypted
 }
 
 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) {
-    msg_.Swap(&other->msg_);
+    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_);

+ 1 - 1
App/protobufLAInitiator.cpp

@@ -3,7 +3,7 @@
 #include "sgx_urts.h"
 #define __STDC_FORMAT_MACROS
 #include <inttypes.h>
-#include "dhmsgs.pb.h"
+#include "ProtobufLAMessages.pb.h"
 #include "protobufSgxLATransformsInitiator.h"
 #include <stdio.h>
 

+ 139 - 9
App/systemLA.cpp

@@ -7,14 +7,20 @@
 #include <errno.h>
 #include<unistd.h>
 #include <stdio.h>
-#include "dhmsgs.pb.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;
 #include "protobufLAInitiator.h"
 #include "../Decryptor/Decryptor_u.h"
 #include "sgx_tcrypto.h"
+#include <iostream>
+
 // TODO: Make these private functions
+int apache_fd;
+int decrypt_client_data_wrapper(unsigned char* op_plaintext , uint32_t own_enclave_id);
+
+
 int read_protobuf_msg_from_fd(int accept_fd, google::protobuf::MessageLite& message)
 {
   ZeroCopyInputStream* raw_input;
@@ -39,6 +45,8 @@ int read_protobuf_msg_from_fd(int accept_fd, google::protobuf::MessageLite& mess
     return -1;
   }
   coded_input->PopLimit(limit);
+  delete raw_input;
+  delete coded_input; 
   return 0;
 }
 
@@ -105,6 +113,7 @@ int local_attestation_initiator(int port, uint32_t own_enclave_id)
   protobuf_sgx_dh_msg1_t protobuf_msg1;
   protobuf_sgx_dh_msg2_t protobuf_msg2;
   protobuf_sgx_dh_msg3_t protobuf_msg3;
+  protobuf_post_LA_encrypted_msg_t protobuf_encrypted_msg; 
   uint32_t protobuf_sgx_ret; uint32_t sgx_ret;
 
   // For socket to listen to the Apache enclave.
@@ -176,22 +185,24 @@ Decryptor_decrypt_verifiers_message_set_apache_mrsigner(own_enclave_id, &sgx_ret
 	printf("Error in decryption: 0x%x\n", sgx_ret); fflush(stdout); return sgx_ret; 
 	  }
 	  printf("Successful decryption\n"); fflush(stdout); 
-//Decryptor_aes_gcm_internal_call(own_enclave_id, &sgx_ret, NULL, 0, NULL, NULL, NULL, NULL); 
+	
 
   }
   else 
   {
+	
+	apache_fd=accept_fd;
 	uint8_t encrypted_sign_data_and_sign_and_tag[176];
 	memset(encrypted_sign_data_and_sign_and_tag,0x0,176);
 	uint8_t plaintext_sign_data_and_sign[160];
 	uint8_t plaintext_priv_key[32];	
-//uint32_t create_and_encrypt_mitigator_header_value(uint8_t* plaintext_sign_data_and_sign, uint8_t* encrypted_sign_data_and_sign, uint8_t* tag);
 	sgx_ec256_signature_t sig2;
 	Decryptor_create_and_encrypt_mitigator_header_value(own_enclave_id, &sgx_ret, plaintext_sign_data_and_sign, encrypted_sign_data_and_sign_and_tag , encrypted_sign_data_and_sign_and_tag+160, plaintext_priv_key,&sig2);
 	if(sgx_ret!=0)
 	{
 		printf("Error in generating encrypted mitigator header:0x%x\n", sgx_ret); fflush(stdout); return 0xf3;
-	}uint32_t count; 
+	}
+	uint32_t count; 
 	for(count=0;count<160;count++)
 	{
 		printf("0x%02x ", encrypted_sign_data_and_sign_and_tag[count]);
@@ -206,7 +217,6 @@ Decryptor_decrypt_verifiers_message_set_apache_mrsigner(own_enclave_id, &sgx_ret
 	printf("\n"); fflush(stdout);
 	
 	printf("Plaintext signature: \n"); fflush(stdout); 
-//        printf("Signature data:\n"); fflush(stdout); 
         for(count=0;count<32;count++)
         {
                 printf("%02x", plaintext_sign_data_and_sign[count+96]);
@@ -235,13 +245,17 @@ Decryptor_decrypt_verifiers_message_set_apache_mrsigner(own_enclave_id, &sgx_ret
         }
         printf("\n"); fflush(stdout);
         
-	// TODO: code to write signature data first	
-	bytes_written_post_la=write(accept_fd, encrypted_sign_data_and_sign_and_tag, 176);
-	  if(bytes_written_post_la!=176)
+	protobuf_encrypted_msg.set_msg((void*)encrypted_sign_data_and_sign_and_tag, 176); 
+	if(write_protobuf_msg_to_fd(apache_fd, protobuf_encrypted_msg) != 0)
          {
         printf("Not all of the decryptor's signature was written to the Apache.\n"); fflush(stdout); return 0xfe;
          }
-
+	unsigned char op_plaintext[160];
+	do {
+//	sleep(100);
+	decrypt_client_data_wrapper(op_plaintext, own_enclave_id); 
+//	sleep(100); 
+	} while(true); 
 
 
   }
@@ -251,3 +265,119 @@ Decryptor_decrypt_verifiers_message_set_apache_mrsigner(own_enclave_id, &sgx_ret
         return 0;
       
 }
+
+
+// decrypt_client_data function that does a read-then-write loop 
+// say msg length amount of bytes are read
+////// TODO: first need to decrypt all data received with the aes-gcm apache_iv 
+////// Decryptor.cpp function gets the first 64 bytes as first arg and the rest of ciphertext as 2nd arg. 
+// then need to call the sgx's compute_shared_key fn for ECDH key - on first 64 bytes. 
+// print this key
+// call sha256 on it
+// TODO: decrypt rest of msglength - 64 bytes using this key. (set IV in crypto function)
+////// TODO: then encrypt all user data with apache's key 
+////// return here
+/// write data.
+int decrypt_client_data_wrapper(unsigned char* op_plaintext , uint32_t own_enclave_id)
+{
+        protobuf_post_LA_encrypted_msg_t protobuf_encrypted_msg; uint32_t sgx_ret_status;
+
+        printf("Reading msg from apache"); fflush(stdout); 
+        if(read_protobuf_msg_from_fd(apache_fd, protobuf_encrypted_msg)!=0)
+        {
+                printf("Not all of the Apache's message was read\n"); fflush(stdout); return 0xfe; 
+        }
+   
+        std::string protobuf_encrypted_msg_string(protobuf_encrypted_msg.msg());
+//	printf("%s\n", protobuf_encrypted_msg_string.c_str()); fflush(stdout);
+	const char* temp_array = protobuf_encrypted_msg_string.c_str();
+	int counter;
+	for(counter=0;counter<protobuf_encrypted_msg_string.length();counter++)
+		printf("%d ",temp_array[counter]);
+	printf("\n"); fflush(stdout); 
+
+        unsigned char client_data_from_apache[160+64]; //protobuf_encrypted_msg_string.size());      // set a large limit for "size" for third argument - client data - of 160 - so 160+64
+	memset(client_data_from_apache, 0, 160+64); 
+	unsigned char* protobuf_string = (unsigned char*) protobuf_encrypted_msg_string.c_str(); 
+//        client_data_from_apache = (unsigned char*) protobuf_encrypted_msg_string.c_str(); //temp_array;//(unsigned char*)&(std::vector<char> (protobuf_encrypted_msg_string.begin(), protobuf_encrypted_msg_string.end()))[0]; // This shit eats up 8 starting bytes - sets them to 0s
+	for(counter=0;counter<protobuf_encrypted_msg_string.length();counter++)
+		client_data_from_apache[counter]=*(protobuf_string+counter);
+
+	uint32_t ciphertext_length = protobuf_encrypted_msg_string.length()-64; // we hope it's greater than 0 
+
+	unsigned char pub_key[64];
+        printf("Key in big endian form:\n"); fflush(stdout); 
+        for(counter=0; counter<64; counter++)
+                printf("0x%02x ", *(client_data_from_apache + counter)); 
+        printf("\n"); fflush(stdout); 
+
+	for(counter=0; counter<32; counter++)
+	{
+		*(pub_key + counter) = *(client_data_from_apache + 31 - counter); 
+		*(pub_key + 32 + counter) = *(client_data_from_apache + 63 - counter); 
+	}
+
+	printf("Key in lil endian form:\n"); fflush(stdout); 
+	for(counter=0; counter<64; counter++)
+		printf("0x%02x ", *(pub_key + counter)); 
+	printf("\n"); fflush(stdout); 
+	unsigned char client_data_to_apache[160+64]; //ciphertext_length); 
+	for(counter=0;counter<ciphertext_length;counter++)
+		client_data_to_apache[counter]=client_data_from_apache[counter+64];
+	Decryptor_decrypt_client_data(own_enclave_id, &sgx_ret_status, pub_key, ciphertext_length, client_data_from_apache + 64, client_data_to_apache); 
+	if(sgx_ret_status != 0)
+	{
+		printf("decrypt_client_data returned :0x%x\n", sgx_ret_status); fflush(stdout); //return sgx_ret_status; 
+	}
+
+	// TODO: REMOVE THIS -
+//	for(counter=0;counter<ciphertext_length;counter++)
+//		client_data_to_apache[counter]=0x46;//client_data_from_apache[counter+64];
+	// TODO: Print the bytesize of the message. should be ciphertext_length=4 + more bytes for protobuf packing. 
+	printf("About to write the following bytes to the apache\n"); fflush(stdout);
+	for(counter=0;counter<ciphertext_length;counter++)
+		printf("0x%02x ", client_data_to_apache[counter]);
+	printf("\n"); fflush(stdout);
+        protobuf_encrypted_msg.set_msg((void*)  client_data_to_apache, ciphertext_length);// Is this message set tho?
+	if(write_protobuf_msg_to_fd(apache_fd, protobuf_encrypted_msg)!=0)
+	{
+		printf("Not all of the protobuf message was written to Apache.\n"); fflush(stdout); return 0xfe;
+	}
+	printf("Wrote data to Apache of length %d \n", protobuf_encrypted_msg.ByteSize());fflush(stdout);
+	return 0; 
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 

+ 69 - 3
Decryptor/Decryptor.cpp

@@ -70,6 +70,7 @@ uint32_t unseal_and_restore_sealed_signing_key_pair(__attribute__((unused)) sgx_
 
 uint32_t decrypt_verifiers_message_set_apache_mrsigner(uint8_t* ciphertext, uint8_t* tag);
 uint32_t create_and_encrypt_mitigator_header_value(uint8_t* plaintext_sign_data_and_sign, uint8_t* encrypted_sign_data_and_sign, uint8_t* tag, uint8_t* signing_private_key, __attribute__((unused)) sgx_ec256_signature_t* sig2);
+static void reverse_byte_array(uint8_t *array, size_t size);
 
 
 uint32_t one_la_done=0; 
@@ -92,9 +93,6 @@ extern "C" uint32_t verify_peer_enclave_trust(__attribute__((unused))  sgx_dh_se
 //		return 0x55;
 		//sgx_measurement_t local_mr_enclave;
 		verifier_mr_enclave = peer_enclave_identity->mr_enclave;
-//		memset(&(verifier_mr_enclave.m),0x0, SGX_HASH_SIZE) ; 
-//                for(count=0; count<SGX_HASH_SIZE; count++)
-//			(&verifier_mr_enclave)->m[count]=0x55;//peer_enclave_identity->mr_enclave.m[count]; 
 		memset(&(apache_mr_signer.m),0x0,SGX_HASH_SIZE); // "initialization" 
 		one_la_done=1;
 
@@ -301,6 +299,10 @@ uint32_t create_mitigator_header_value(__attribute__((unused)) uint8_t* signatur
 	// serialize public key, append mr_enclave 
 //	uint8_t* public_key_string = (uint8_t*) malloc(3*SGX_ECP256_KEY_SIZE); // for .edl file - size parameter for serialize is 96 and this fits coz we need to append the mr_enclave to the pub key 
 	serialize_key_pair_to_string(&short_term_pub_key, NULL, signature_data);
+	reverse_byte_array(signature_data, 32);
+	reverse_byte_array(signature_data+32, 32);
+
+
 	for(counter=32*2; counter<32*3; counter++) // appending mr_enclave
 		*(signature_data+counter)=0x55;//verifier_mr_enclave.m[counter]; // TODO: uncomment verifier_mrenclave
 //	for(counter=0;counter<32*3;counter++) // TODO: REmove - for checking against js library only
@@ -439,5 +441,69 @@ void memcpy_equivalent_copy(uint8_t* dest, uint8_t* src, uint32_t length)
 		*(dest + counter) = *(src + counter); 
 }
 
+uint32_t decrypt_client_data(__attribute__((unused)) unsigned char* ip_client_pub_key, uint32_t ciphertext_length, unsigned char* ip_user_data, unsigned char* op_client_data_to_apache)
+{
+	int counter;
+	for(counter=0;counter<ciphertext_length;counter++)
+		op_client_data_to_apache[counter]=ip_user_data[counter]; 
+//	return 0;
+	sgx_ecc_state_handle_t ecc_handle;
+	unsigned char local_ip_client_pub_key[64]; uint32_t ret_status; int valid_point; 
+	memcpy_equivalent_copy(local_ip_client_pub_key, ip_client_pub_key, 64);	
+	sgx_ec256_public_t client_pub_key; 
+	for(counter=0; counter<32; counter++)
+	{
+		client_pub_key.gx[counter] = *(local_ip_client_pub_key + counter); 
+		client_pub_key.gy[counter] = *(local_ip_client_pub_key + 32 + counter); 
+	}
+
+/*	sgx_ec256_public_t temp_client_pub_key; 
+	sgx_ec256_private_t temp_client_priv_key; 
+	ret_status=create_ec_key_pair(&temp_client_pub_key, &temp_client_priv_key); 
+	if(ret_status == SGX_SUCCESS) 
+		return ret_status; 
+*/
+//	return ret_status;
+        ret_status = sgx_ecc256_open_context(&ecc_handle); 
+        if(ret_status != SGX_SUCCESS) 
+                return ret_status; 
+
+	memset(&client_pub_key, 0, sizeof(client_pub_key));
+
+//	reverse_byte_array(client_pub_key.gx, sizeof(client_pub_key.gx));
+//	reverse_byte_array(client_pub_key.gy, sizeof(client_pub_key.gy));
+
+        ret_status = sgx_ecc256_check_point(&client_pub_key, ecc_handle, &valid_point); 
+	if(valid_point == 0 && ret_status == SGX_SUCCESS)
+	{
+		return 0x55;
+	}
+
+
+	sgx_ec256_private_t local_short_term_priv_key;
+        for(counter=0; counter<SGX_ECP256_KEY_SIZE; counter++) 
+                local_short_term_priv_key.r[counter] = short_term_priv_key.r[counter];  
+
+	sgx_ec256_dh_shared_t dh_key; 
+	ret_status=sgx_ecc256_compute_shared_dhkey(&local_short_term_priv_key, &client_pub_key, &dh_key, ecc_handle); 
+	if(ret_status != 0)
+		return ret_status; 
+
+//	memcpy_equivalent_copy(op_client_data_to_apache, dh_key.s, 32); 
+	
+	ret_status = sgx_ecc256_close_context(ecc_handle); 
+	return ret_status; 
 
+}
+
+static void reverse_byte_array(uint8_t *array, size_t size)
+{
+    size_t i = 0;
+    for(i = 0; i < size / 2; i++)
+    {
+        uint8_t temp = array[i];
+        array[i] = array[size - i - 1];
+        array[size - i - 1] = temp;
+    }
+}
 

+ 1 - 0
Decryptor/Decryptor.edl

@@ -45,6 +45,7 @@ enclave {
         public uint32_t calculate_sealed_data_size(uint32_t input_size); 
 public uint32_t decrypt_verifiers_message_set_apache_mrsigner([in, size=32] uint8_t* ciphertext, [in, size=16] uint8_t* tag);
 public uint32_t create_and_encrypt_mitigator_header_value([out, size=160] uint8_t* plaintext_sign_data_and_sign, [out, size=160] uint8_t* encrypted_sign_data_and_sign, [out, size=16] uint8_t* tag, [out, size=32] uint8_t* signing_private_key, [out] sgx_ec256_signature_t* sig2);
+public uint32_t decrypt_client_data([in, size=64] unsigned char* client_pub_key, uint32_t ciphertext_length, [in, size=160] unsigned char* user_data, [out, size=160] unsigned char* client_data_to_apache);
 
 
 

+ 73 - 53
Include/ProtobufLAMessages.pb.h

@@ -1252,30 +1252,28 @@ class protobuf_post_LA_encrypted_msg_t : public ::google::protobuf::MessageLite
 
   // accessors -------------------------------------------------------
 
-  // repeated bytes msg = 1;
-  inline int msg_size() const;
+  // required bytes msg = 1;
+  inline bool has_msg() const;
   inline void clear_msg();
   static const int kMsgFieldNumber = 1;
-  inline const ::std::string& msg(int index) const;
-  inline ::std::string* mutable_msg(int index);
-  inline void set_msg(int index, const ::std::string& value);
-  inline void set_msg(int index, const char* value);
-  inline void set_msg(int index, const void* value, size_t size);
-  inline ::std::string* add_msg();
-  inline void add_msg(const ::std::string& value);
-  inline void add_msg(const char* value);
-  inline void add_msg(const void* value, size_t size);
-  inline const ::google::protobuf::RepeatedPtrField< ::std::string>& msg() const;
-  inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_msg();
+  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_;
-  ::google::protobuf::RepeatedPtrField< ::std::string> msg_;
+  ::std::string* msg_;
   #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
   friend void  protobuf_AddDesc_ProtobufLAMessages_2eproto_impl();
   #else
@@ -2419,58 +2417,80 @@ protobuf_sgx_dh_msg3_t::mutable_cmac() {
 
 // protobuf_post_LA_encrypted_msg_t
 
-// repeated bytes msg = 1;
-inline int protobuf_post_LA_encrypted_msg_t::msg_size() const {
-  return msg_.size();
+// 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() {
-  msg_.Clear();
+  if (msg_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
+    msg_->clear();
+  }
+  clear_has_msg();
 }
-inline const ::std::string& protobuf_post_LA_encrypted_msg_t::msg(int index) const {
+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_.Get(index);
+  return *msg_;
 }
-inline ::std::string* protobuf_post_LA_encrypted_msg_t::mutable_msg(int index) {
-  // @@protoc_insertion_point(field_mutable:protobuf_post_LA_encrypted_msg_t.msg)
-  return msg_.Mutable(index);
-}
-inline void protobuf_post_LA_encrypted_msg_t::set_msg(int index, const ::std::string& value) {
+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)
-  msg_.Mutable(index)->assign(value);
 }
-inline void protobuf_post_LA_encrypted_msg_t::set_msg(int index, const char* value) {
-  msg_.Mutable(index)->assign(value);
+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(int index, const void* value, size_t size) {
-  msg_.Mutable(index)->assign(
-    reinterpret_cast<const char*>(value), size);
+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::add_msg() {
-  return msg_.Add();
-}
-inline void protobuf_post_LA_encrypted_msg_t::add_msg(const ::std::string& value) {
-  msg_.Add()->assign(value);
-  // @@protoc_insertion_point(field_add:protobuf_post_LA_encrypted_msg_t.msg)
-}
-inline void protobuf_post_LA_encrypted_msg_t::add_msg(const char* value) {
-  msg_.Add()->assign(value);
-  // @@protoc_insertion_point(field_add_char:protobuf_post_LA_encrypted_msg_t.msg)
-}
-inline void protobuf_post_LA_encrypted_msg_t::add_msg(const void* value, size_t size) {
-  msg_.Add()->assign(reinterpret_cast<const char*>(value), size);
-  // @@protoc_insertion_point(field_add_pointer:protobuf_post_LA_encrypted_msg_t.msg)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-protobuf_post_LA_encrypted_msg_t::msg() const {
-  // @@protoc_insertion_point(field_list: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 ::google::protobuf::RepeatedPtrField< ::std::string>*
-protobuf_post_LA_encrypted_msg_t::mutable_msg() {
-  // @@protoc_insertion_point(field_mutable_list: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)
 }
 
 

+ 1 - 1
Makefile

@@ -122,7 +122,7 @@ else
 	App_Link_Flags += -lsgx_uae_service
 endif
 
-App_Cpp_Objects := App/App.o App/systemLA.o App/protobufLAInitiator.o App/protobufSgxLATransformsInitiator.o App/dhmsgs.pb.o #$(App_Cpp_Files:.cpp=.o)
+App_Cpp_Objects := App/App.o App/systemLA.o App/protobufLAInitiator.o App/protobufSgxLATransformsInitiator.o App/ProtobufLAMessages.pb.o #$(App_Cpp_Files:.cpp=.o)
 App_Name := app
 
 ######## Enclave Settings ########