Commit d19b442a authored by Yann Garcia's avatar Yann Garcia
Browse files

Rename variables & parameters

parent baa1c1f4
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<listItem>./bin</listItem> <listItem>./bin</listItem>
<listItem>./src/bin</listItem> <listItem>./src/bin</listItem>
<listItem>./src/bin/asn1</listItem> <listItem>./src/bin/asn1</listItem>
<listItem>C:\OpenSSL-Win64\include</listItem> <listItem>C:\ProgramFiles\OpenSSL-Win64\include</listItem>
<listItem>C:\npcap-sdk-0.1\Include</listItem> <listItem>C:\npcap-sdk-0.1\Include</listItem>
<listItem>/Users/yann/Documents/wireshark/cygwin64/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++</listItem> <listItem>/Users/yann/Documents/wireshark/cygwin64/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/include/c++</listItem>
</preprocessorIncludes> </preprocessorIncludes>
......
...@@ -5,3 +5,4 @@ data/certificates/ ...@@ -5,3 +5,4 @@ data/certificates/
data/v3/certificates/ data/v3/certificates/
data/v3/temp/ data/v3/temp/
data/v3/xer/ data/v3/xer/
/bin/
...@@ -1149,7 +1149,7 @@ namespace LibItsSecurity__Functions ...@@ -1149,7 +1149,7 @@ namespace LibItsSecurity__Functions
/** /**
* \brief Read the specified certificate * \brief Read the specified certificate
* \param p_certificateId the certificate identifier * \param p_certificate_id the certificate identifier
* \param p_certificate the expected certificate * \param p_certificate the expected certificate
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
...@@ -1181,7 +1181,7 @@ namespace LibItsSecurity__Functions ...@@ -1181,7 +1181,7 @@ namespace LibItsSecurity__Functions
/** /**
* \brief Read the specified certificate digest * \brief Read the specified certificate digest
* \param p_certificateId the certificate identifier * \param p_certificate_id the certificate identifier
* \param p_digest the expected certificate * \param p_digest the expected certificate
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
...@@ -1200,7 +1200,7 @@ namespace LibItsSecurity__Functions ...@@ -1200,7 +1200,7 @@ namespace LibItsSecurity__Functions
/** /**
* \brief Read the whole-hash of the certificate * \brief Read the whole-hash of the certificate
* \param p_certificateId the certificate identifier * \param p_certificate_id the certificate identifier
* \param p_hash the expected certificate * \param p_hash the expected certificate
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
...@@ -1219,7 +1219,7 @@ namespace LibItsSecurity__Functions ...@@ -1219,7 +1219,7 @@ namespace LibItsSecurity__Functions
/** /**
* \brief Read the private keys for the specified certificate * \brief Read the private keys for the specified certificate
* \param p_certificateId the keys identifier * \param p_certificate_id the keys identifier
* \param p_signingPrivateKey the signing private key * \param p_signingPrivateKey the signing private key
* \return true on success, false otherwise * \return true on success, false otherwise
*/ */
......
...@@ -338,6 +338,22 @@ public: ...@@ -338,6 +338,22 @@ public:
*/ */
std::string trim(const std::string& p_value, const std::string& p_trim_chars = " \t"); std::string trim(const std::string& p_value, const std::string& p_trim_chars = " \t");
/*!
* \brief Convert the provided string into a list of arguments
* \param[in] p_value The string value
* \param[in] p_separator The separator sequence to use for the spliting process
* \return The item list
* \code{.cc}
* std::string str = "This is a test for spliting a string with a white spave";
* std::vector<std::string> tokens = converter::get_instance().split(str, " ");
* std::clog << "Tokens: " << std::endl;
* for (auto it = tokens.begin(); it != tokens.end(); ++it) {
* std::clog << " " << *it << std::endl;
* }
* \endcode
*/
std::vector<std::string> split(const std::string & p_value, const std::string& p_separator);
/*! /*!
* \brief Convert the provided string into a list of arguments * \brief Convert the provided string into a list of arguments
* \param[in] p_value The string value * \param[in] p_value The string value
...@@ -352,6 +368,6 @@ public: ...@@ -352,6 +368,6 @@ public:
* \endcode * \endcode
*/ */
std::vector<std::string> split_arguments_line(const std::string & p_value); std::vector<std::string> split_arguments_line(const std::string & p_value);
static const std::string lut; static const std::string lut;
}; // End of class converter }; // End of class converter
...@@ -97,7 +97,21 @@ std::string converter::trim(const std::string& str, const std::string& whitespac ...@@ -97,7 +97,21 @@ std::string converter::trim(const std::string& str, const std::string& whitespac
return str.substr(strBegin, strRange); return str.substr(strBegin, strRange);
} }
std::vector<std::string> converter::split(const std::string & p_value, const std::string& p_separator) {
std::vector<std::string> output;
std::size_t current, previous = 0;
current = p_value.find(p_separator);
while (current != std::string::npos) {
output.push_back(p_value.substr(previous, current - previous));
previous = current + 1;
current = p_value.find(p_separator, previous);
}
output.push_back(p_value.substr(previous, current - previous));
return output;
}
std::vector<std::string> converter::split_arguments_line(const std::string & p_value) { std::vector<std::string> converter::split_arguments_line(const std::string & p_value) {
std::vector<std::string> output; std::vector<std::string> output;
std::string line = trim(p_value); std::string line = trim(p_value);
......
...@@ -71,6 +71,8 @@ const std::string& params::interface_id = std::string("interface_id"); ...@@ -71,6 +71,8 @@ const std::string& params::interface_id = std::string("interface_id");
const std::string& params::server = std::string("server"); const std::string& params::server = std::string("server");
const std::string& params::port = std::string("port"); const std::string& params::port = std::string("port");
const std::string& params::server_mode = std::string("server_mode");
const std::string& params::local_port = std::string("local_port");
const std::string& params::use_ssl = std::string("use_ssl"); const std::string& params::use_ssl = std::string("use_ssl");
const std::string& params::method = std::string("method"); const std::string& params::method = std::string("method");
const std::string& params::uri = std::string("uri"); const std::string& params::uri = std::string("uri");
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#include "LibItsHttp_MessageBodyTypes.hh" #include "LibItsHttp_MessageBodyTypes.hh"
#include "LibItsHttp_XmlMessageBodyTypes.hh" #include "LibItsHttp_XmlMessageBodyTypes.hh"
#include "http_etsi_ieee1609dot2_codec.hh" // FIXME Work-around, to be removed
int http_codec::encode (const LibItsHttp__TypesAndValues::HttpMessage& msg, OCTETSTRING& data) int http_codec::encode (const LibItsHttp__TypesAndValues::HttpMessage& msg, OCTETSTRING& data)
{ {
loggers::get_instance().log_msg(">>> http_codec::encode: ", (const Base_Type&)msg); loggers::get_instance().log_msg(">>> http_codec::encode: ", (const Base_Type&)msg);
...@@ -367,7 +365,12 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue ...@@ -367,7 +365,12 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue
// Save the the body length // Save the the body length
loggers::get_instance().log("http_codec::decode_header: decoded Content-Length %s", m[2].str().c_str()); loggers::get_instance().log("http_codec::decode_header: decoded Content-Length %s", m[2].str().c_str());
_dc.length = std::stoi(m[2].str()); _dc.length = std::stoi(m[2].str());
} else if (m[1].str().compare("Transfer-Encoding") == 0) {
if (m[2].str().find("chunked") != std::string::npos) {
_dc.chunked = true;
}
} }
return 0; return 0;
} }
catch(const std::logic_error& e) { catch(const std::logic_error& e) {
...@@ -377,7 +380,6 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue ...@@ -377,7 +380,6 @@ int http_codec::decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValue
int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody& p_message_body, OCTETSTRING& p_encoding_buffer, const std::string& p_content_type) { int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody& p_message_body, OCTETSTRING& p_encoding_buffer, const std::string& p_content_type) {
loggers::get_instance().log_msg(">>> http_codec::encode_body: ", (const Base_Type&)p_message_body); loggers::get_instance().log_msg(">>> http_codec::encode_body: ", (const Base_Type&)p_message_body);
loggers::get_instance().log("http_codec::encode_body: # of codecs=%d - %p", _codecs.size(), this);
// Sanity check // Sanity check
if (p_content_type.empty()) { if (p_content_type.empty()) {
...@@ -509,8 +511,29 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod ...@@ -509,8 +511,29 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
counter += 1; counter += 1;
} }
} }
loggers::get_instance().log("http_codec::decode_body: Counter=%d", counter); loggers::get_instance().log("http_codec::decode_body: counter=%d", counter);
body = OCTETSTRING(body.lengthof() - counter, static_cast<const unsigned char*>(body)); body = OCTETSTRING(body.lengthof() - counter, static_cast<const unsigned char*>(body));
if (_dc.chunked) {
// Extract the size of the chunk <chunk size>\r[\n]
counter = 0;
while (counter < body.lengthof()) {
if ((body[counter].get_octet() == '\r') || (body[counter].get_octet() == '\n')) {
break;
}
counter += 1;
} // End of 'while' statement
loggers::get_instance().log("http_codec::decode_body: Chunked: counter=%d", counter);
if (counter < body.lengthof()) { // Skip additional \n
OCTETSTRING os(counter - 1, static_cast<const unsigned char*>(body));
loggers::get_instance().log_msg("http_codec::decode_body: os: ", os);
int len = oct2int(os);
loggers::get_instance().log("http_codec::decode_body: Chunk len: %d", len);
if (body[counter].get_octet() == '\n') {
counter += 1;
}
body = OCTETSTRING(len, counter + static_cast<const unsigned char*>(body));
}
}
loggers::get_instance().log_msg("http_codec::decode_body: Finalised body=", body); loggers::get_instance().log_msg("http_codec::decode_body: Finalised body=", body);
// Check if HTTP message body contains binary characters // Check if HTTP message body contains binary characters
for (int i = 0; i < body.lengthof(); i++) { for (int i = 0; i < body.lengthof(); i++) {
...@@ -561,12 +584,13 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod ...@@ -561,12 +584,13 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
// Convert into string // Convert into string
params p; params p;
p["decode_str"] = std::string(static_cast<const unsigned char*>(body), body.lengthof() + static_cast<const unsigned char*>(body)); p["decode_str"] = std::string(static_cast<const unsigned char*>(body), body.lengthof() + static_cast<const unsigned char*>(body));
loggers::get_instance().log("http_codec::decode_body: decode_str: %s", p["decode_str"].c_str());
// Try to identify xml // Try to identify xml
if (p["decode_str"].find("<?xml version=") != std::string::npos) { if (p["decode_str"].find("<?xml version=") != std::string::npos) {
loggers::get_instance().log("http_codec::decode_body: Find xml message"); loggers::get_instance().log("http_codec::decode_body: Find xml message");
LibItsHttp__XmlMessageBodyTypes::XmlBody xml_body; LibItsHttp__XmlMessageBodyTypes::XmlBody xml_body;
// TODO To be refined adding a string identifier to check which codec to use. E.g. held_code.id() returns "xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">" // TODO To be refined adding a string identifier to check which codec to use. E.g. held_code.id() returns "xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">"
if (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">") != std::string::npos) { if (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:geopriv:held\"") != std::string::npos) {
loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:geopriv:held'"); loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:geopriv:held'");
if (_codecs["held"].get() != nullptr) { if (_codecs["held"].get() != nullptr) {
loggers::get_instance().log("http_codec::decode_body: Call 'held_codec'"); loggers::get_instance().log("http_codec::decode_body: Call 'held_codec'");
...@@ -582,8 +606,8 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod ...@@ -582,8 +606,8 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body)); xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body));
} }
message_body.xml__body() = xml_body; message_body.xml__body() = xml_body;
} else if (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:lost1\">") != std::string::npos) { } else if (p["decode_str"].find("xmlns=\"urn:ietf:params:xml:ns:lost1\"") != std::string::npos) {
loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:loat1'"); loggers::get_instance().log("http_codec::decode_body: Find 'urn:ietf:params:xml:ns:lost1'");
if (_codecs["lost"].get() != nullptr) { if (_codecs["lost"].get() != nullptr) {
loggers::get_instance().log("http_codec::decode_body: Call 'lost_codec'"); loggers::get_instance().log("http_codec::decode_body: Call 'lost_codec'");
if (_codecs["lost"]->decode(body, (Record_Type&)xml_body, &p) == -1) { if (_codecs["lost"]->decode(body, (Record_Type&)xml_body, &p) == -1) {
...@@ -598,7 +622,11 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod ...@@ -598,7 +622,11 @@ int http_codec::decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBod
xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body)); xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body));
} }
message_body.xml__body() = xml_body; message_body.xml__body() = xml_body;
} } else {
loggers::get_instance().warning("http_codec::decode_body: No XML codec found");
xml_body.raw() = CHARSTRING(body.lengthof(), (char*)static_cast<const unsigned char*>(body));
message_body.xml__body() = xml_body;
}
} else if (p["decode_str"].find("<html>") != std::string::npos) { // Try to identify HTML } else if (p["decode_str"].find("<html>") != std::string::npos) { // Try to identify HTML
loggers::get_instance().log("http_codec::decode_body: Find html message"); loggers::get_instance().log("http_codec::decode_body: Find html message");
LibItsHttp__MessageBodyTypes::HtmlBody html_body; LibItsHttp__MessageBodyTypes::HtmlBody html_body;
......
...@@ -32,9 +32,10 @@ struct encoding_context { ...@@ -32,9 +32,10 @@ struct encoding_context {
struct decoding_context { struct decoding_context {
unsigned int length; unsigned int length;
unsigned char is_binary; unsigned char is_binary;
bool chunked;
decoding_context() { reset(); }; decoding_context() { reset(); };
void reset() { length = -1; is_binary = 0x00; }; void reset() { length = -1; is_binary = 0x00; chunked = false; };
}; };
class http_codec: public codec < class http_codec: public codec <
...@@ -46,7 +47,7 @@ LibItsHttp__TypesAndValues::HttpMessage> ...@@ -46,7 +47,7 @@ LibItsHttp__TypesAndValues::HttpMessage>
std::map<std::string, std::unique_ptr<codec<Record_Type, Record_Type> > > _codecs; std::map<std::string, std::unique_ptr<codec<Record_Type, Record_Type> > > _codecs;
public: public:
explicit http_codec() : codec<LibItsHttp__TypesAndValues::HttpMessage, LibItsHttp__TypesAndValues::HttpMessage>(), _ec(), _dc(), _codecs() { }; explicit http_codec() : codec<LibItsHttp__TypesAndValues::HttpMessage, LibItsHttp__TypesAndValues::HttpMessage>(), _ec(), _dc(), _codecs() { };
virtual ~http_codec() { _codecs.clear(); }; virtual ~http_codec() { };
virtual int encode (const LibItsHttp__TypesAndValues::HttpMessage&, OCTETSTRING& data); virtual int encode (const LibItsHttp__TypesAndValues::HttpMessage&, OCTETSTRING& data);
virtual int decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::HttpMessage&, params* params = NULL); virtual int decode (const OCTETSTRING& data, LibItsHttp__TypesAndValues::HttpMessage&, params* params = NULL);
...@@ -60,7 +61,7 @@ private: ...@@ -60,7 +61,7 @@ private:
int decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAndValues::HeaderLines& headers); int decode_headers(TTCN_Buffer& decoding_buffer, LibItsHttp__TypesAndValues::HeaderLines& headers);
int decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValues::HeaderLine& header); int decode_header(CHARSTRING& header_line, LibItsHttp__TypesAndValues::HeaderLine& header);
int decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body, const std::string& p_content_type); int decode_body(TTCN_Buffer& decoding_buffer, LibItsHttp__MessageBodyTypes::HttpMessageBody& message_body);
int get_line(TTCN_Buffer& buffer, CHARSTRING& to, const bool concatenate_header_lines = false); int get_line(TTCN_Buffer& buffer, CHARSTRING& to, const bool concatenate_header_lines = false);
}; // End of class http_codec }; // End of class http_codec
...@@ -23,7 +23,7 @@ class http_layer_factory : public layer_factory { ...@@ -23,7 +23,7 @@ class http_layer_factory : public layer_factory {
public: //! \publicsection public: //! \publicsection
/*! /*!
* \brief Default constructor * \brief Default constructor
* Create a new instance of the udp_layer_factory class * Create a new instance of the http_layer_factory class
* \remark The HTTP layer identifier is HTTP * \remark The HTTP layer identifier is HTTP
*/ */
http_layer_factory() { http_layer_factory() {
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ module ItsPki_TestControl { ...@@ -12,7 +12,7 @@ module ItsPki_TestControl {
execute(TC_SEC_PKI_ITSS_ENR_BV_01()); execute(TC_SEC_PKI_ITSS_ENR_BV_01());
} }
if (PICS_IUT_EA_ROLE) { if (PICS_IUT_EA_ROLE or PICS_IUT_COMBINED_EA_AA_ROLE) {
execute(TC_SEC_PKI_SND_EA_BV_01()); execute(TC_SEC_PKI_SND_EA_BV_01());
execute(TC_SEC_PKI_SND_EA_BV_02()); execute(TC_SEC_PKI_SND_EA_BV_02());
execute(TC_SEC_PKI_SND_EA_BV_03()); execute(TC_SEC_PKI_SND_EA_BV_03());
...@@ -23,12 +23,17 @@ module ItsPki_TestControl { ...@@ -23,12 +23,17 @@ module ItsPki_TestControl {
execute(TC_SEC_PKI_SND_EA_BV_08()); execute(TC_SEC_PKI_SND_EA_BV_08());
execute(TC_SEC_PKI_SND_EA_BV_09()); execute(TC_SEC_PKI_SND_EA_BV_09());
execute(TC_SEC_PKI_SND_EA_BV_10()); execute(TC_SEC_PKI_SND_EA_BV_10());
execute(TC_SEC_PKI_SND_EA_BV_11());
execute(TC_SEC_PKI_SND_EA_BV_12());
} }
if (PICS_IUT_AA_ROLE) { if (PICS_IUT_COMBINED_EA_AA_ROLE) {
execute(TC_SEC_PKI_SND_AA_BV_01()); execute(TC_SEC_PKI_SND_EA_AA_BV_01());
execute(TC_SEC_PKI_SND_AA_BV_02()); }
execute(TC_SEC_PKI_SND_AA_BV_03()); if (PICS_IUT_AA_ROLE) {
execute(TC_SEC_PKI_SND_AA_BV_01());
execute(TC_SEC_PKI_SND_AA_BV_02());
execute(TC_SEC_PKI_SND_AA_BV_03());
} }
} // End of 'control' statement } // End of 'control' statement
......
Subproject commit b745c0b23fc463ff118fc60c06831711651b77ec Subproject commit b1e9bdd7e3007035abfa808cf21ea00c772aa127
...@@ -641,7 +641,7 @@ module TestCodec_Pki { ...@@ -641,7 +641,7 @@ module TestCodec_Pki {
setverdict(fail, "f_generate_ec_certificate"); setverdict(fail, "f_generate_ec_certificate");
stop; stop;
} }
v_ret := false;//f_generate_inner_at_request(v_cert_iut_a_ea, v_hashed_id8_cert_iut_a_ea, v_ec_certificate, v_private_key, v_public_key_x, v_public_key_y, p_compressedMode, p_private_enc_key, v_publicEncKeyCompressed, v_compressedMode, v_inner_at_request); v_ret := false;//f_generate_inner_at_request(v_cert_iut_a_ea, v_hashed_id8_cert_iut_a_ea, v_ec_certificate, v_private_key, v_public_key_x, v_public_key_y, p_compressed_mode, p_private_enc_key, v_publicEncKeyCompressed, v_compressedMode, v_inner_at_request);
if (v_ret == true) { if (v_ret == true) {
setverdict(pass); setverdict(pass);
} else { } else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment