|
@@ -38,7 +38,7 @@ class Mitigator : public Php::Base
|
|
|
static void local_attestation_initiator_wrapper()
|
|
|
{
|
|
|
printf("Hello.\n"); fflush(stdout);
|
|
|
-
|
|
|
+
|
|
|
setbuf(stdout,NULL); uint32_t count;
|
|
|
uint32_t return_sgx;
|
|
|
unsigned char* base64_encoded_mitigator_header_and_value = (unsigned char*) malloc(mitigator_pubkey_header.length()+1+216);
|
|
@@ -61,10 +61,8 @@ class Mitigator : public Php::Base
|
|
|
printf("\nSuccessful LA with port %d.\n", DECRYPTOR_PORT);
|
|
|
fflush(stdout);
|
|
|
local_attestation_successful=1;
|
|
|
- printf("length of string was %d\n", mitigator_pubkey_header.length()); fflush(stdout);
|
|
|
mitigator_pubkey_header_value=std::string((char*)base64_encoded_mitigator_header_and_value,mitigator_pubkey_header.length()+216);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -78,7 +76,7 @@ class Mitigator : public Php::Base
|
|
|
|
|
|
static Php::Value php_decrypt_wrapper(Php::Parameters ¶ms )
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
int counter;
|
|
|
unsigned char* plaintext_user_data;
|
|
|
unsigned char* ciphertext_user_data;
|
|
@@ -96,12 +94,12 @@ class Mitigator : public Php::Base
|
|
|
|
|
|
printf("Base64 encoded key:\n");
|
|
|
for(counter=0; counter < 88; counter++)
|
|
|
- printf("%c ", base64_encoded_pub_key[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("%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);
|
|
@@ -117,8 +115,9 @@ class Mitigator : public Php::Base
|
|
|
|
|
|
std::string plaintext_user_data_str = std::string((char*) plaintext_user_data, plaintext_length);
|
|
|
|
|
|
- */
|
|
|
- return "Miti";
|
|
|
+
|
|
|
+ return plaintext_user_data_str;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
};
|
|
@@ -135,11 +134,9 @@ extern "C" {
|
|
|
|
|
|
Php::Class<Mitigator> mitigator("Mitigator");
|
|
|
mitigator.method<&Mitigator::get_mitigator_header>("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), Php::ByVal("string", Php::Type::String) } );
|
|
|
extension.onStartup(&Mitigator::local_attestation_initiator_wrapper);
|
|
|
-
|
|
|
|
|
|
extension.add(mitigator);
|
|
|
return extension.module();
|