|
@@ -77,13 +77,12 @@ class Mitigator : public Php::Base
|
|
|
|
|
|
// gettimeofday(&tv1, NULL);
|
|
// gettimeofday(&tv1, NULL);
|
|
|
|
|
|
- uint32_t ret_status, counter, field_size;
|
|
|
|
- std::vector<std::string> binary_ciphertext_client_fields, plaintext_client_fields;
|
|
|
|
|
|
+ uint32_t ret_status, field_size;
|
|
|
|
+ std::vector<std::string> base64_fields, binary_ciphertext_client_fields, plaintext_client_fields;
|
|
unsigned char *binary_ciphertext_client_field;
|
|
unsigned char *binary_ciphertext_client_field;
|
|
- Php::Object ret_object;
|
|
|
|
- Php::Array php_plaintext_client_fields;
|
|
|
|
const char* temp_ptr;
|
|
const char* temp_ptr;
|
|
- std::string temp_str;
|
|
|
|
|
|
+ Php::Object ret_object;
|
|
|
|
+ Php::Value input_base64_array;
|
|
|
|
|
|
ret_object["success"]="false";
|
|
ret_object["success"]="false";
|
|
|
|
|
|
@@ -93,19 +92,20 @@ class Mitigator : public Php::Base
|
|
return ret_object;
|
|
return ret_object;
|
|
}
|
|
}
|
|
|
|
|
|
- binary_ciphertext_client_fields.push_back(params[0]);
|
|
|
|
|
|
+ input_base64_array = params;
|
|
|
|
+ base64_fields = Php::array_values(input_base64_array);
|
|
|
|
|
|
- for (unsigned int i = 0; i < params.size(); i++)
|
|
|
|
|
|
+ for (auto &base64_field : base64_fields)
|
|
{
|
|
{
|
|
- field_size=params[i].size();
|
|
|
|
- temp_ptr = params[i];
|
|
|
|
|
|
+ field_size= base64_field.size();
|
|
|
|
+ temp_ptr = base64_field.c_str();
|
|
// upper limit - the binary data will always be smaller than this (base64 length ~= 4/3 * binary length)
|
|
// upper limit - the binary data will always be smaller than this (base64 length ~= 4/3 * binary length)
|
|
binary_ciphertext_client_field = (unsigned char*) malloc(field_size);
|
|
binary_ciphertext_client_field = (unsigned char*) malloc(field_size);
|
|
ret_status = base64_decoding_wrapper(binary_ciphertext_client_field, temp_ptr, field_size);
|
|
ret_status = base64_decoding_wrapper(binary_ciphertext_client_field, temp_ptr, field_size);
|
|
if(ret_status <= 0)
|
|
if(ret_status <= 0)
|
|
{
|
|
{
|
|
free(binary_ciphertext_client_field);
|
|
free(binary_ciphertext_client_field);
|
|
- ret_object["error"]="Could not perform base64 decoding correctly for the " + std::to_string(i) + "th argument.";
|
|
|
|
|
|
+ ret_object["error"]="Could not perform base64 decoding correctly for this field: " + base64_field;
|
|
return ret_object;
|
|
return ret_object;
|
|
}
|
|
}
|
|
binary_ciphertext_client_fields.push_back(std::string(reinterpret_cast<const char*> (binary_ciphertext_client_field), ret_status));
|
|
binary_ciphertext_client_fields.push_back(std::string(reinterpret_cast<const char*> (binary_ciphertext_client_field), ret_status));
|
|
@@ -119,9 +119,7 @@ class Mitigator : public Php::Base
|
|
}
|
|
}
|
|
|
|
|
|
ret_object["success"]="true";
|
|
ret_object["success"]="true";
|
|
- for(counter=0;counter<plaintext_client_fields.size();counter++)
|
|
|
|
- php_plaintext_client_fields[counter]=plaintext_client_fields[counter];
|
|
|
|
- ret_object["fields"]=php_plaintext_client_fields;
|
|
|
|
|
|
+ ret_object["fields"]=Php::Array(plaintext_client_fields);
|
|
|
|
|
|
/*gettimeofday(&tv2, NULL);
|
|
/*gettimeofday(&tv2, NULL);
|
|
new_time=tv2.tv_usec + tv2.tv_sec * 1000000;
|
|
new_time=tv2.tv_usec + tv2.tv_sec * 1000000;
|