Commit b857bcd1 authored by YannGarcia's avatar YannGarcia
Browse files

Bug fixed in signature check

parent c5d74d0e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ defines += LINUX
libs += -lpcap -lrt -lpthread
endif

libs += -lssl -lcrypto -lxml2
libs += -lssl -lcrypto -lxml2 -lxslt

$(eval $(call IncludeModule, $(TOPDIR)/ttcn/$(ATS)))

+5 −5
Original line number Diff line number Diff line
@@ -22,7 +22,11 @@ int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& body, OCTETST
    TTCN_Buffer encoding_buffer;

    const LibHttp__XmlMessageBodyTypes::XmlBodyMsg& msg = body.msg();
    if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_pull__request)) {
    if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_raw)) { // If raw message is provided, msg is not encoded
      data = char2oct(msg.raw());
      loggers::get_instance().log_msg("xml_codec::encode: Process Raw: ", data);
      return 0;
    } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_pull__request)) {
      const http__www__cise__eu__servicemodel__v1__message::PullRequest& pull_request = msg.pull__request();
      loggers::get_instance().log_msg("xml_codec::encode: Process PullRequest: ", (const Base_Type&)pull_request);
      pull_request.encode(http__www__cise__eu__servicemodel__v1__message::PullRequest_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
@@ -30,10 +34,6 @@ int xml_codec::encode(const LibHttp__XmlMessageBodyTypes::XmlBody& body, OCTETST
      const http__www__cise__eu__servicemodel__v1__message::PullResponse& pull_response = msg.pull__response();
      loggers::get_instance().log_msg("xml_codec::encode: Process PullResponse: ", (const Base_Type&)pull_response);
      pull_response.encode(http__www__cise__eu__servicemodel__v1__message::PullResponse_descr_, encoding_buffer, TTCN_EncDec::CT_XER, XER_EXTENDED);
    } else if (msg.ischosen(LibHttp__XmlMessageBodyTypes::XmlBodyMsg::ALT_raw)) {
      data = char2oct(msg.raw());
      loggers::get_instance().log_msg("xml_codec::encode: Process Raw: ", data);
      return 0;
    } else {
      loggers::get_instance().warning("xml_codec::encode: Unsupported variant");
      return -1;
+19 −56
Original line number Diff line number Diff line
@@ -17,62 +17,7 @@

namespace LibCise__Functions {

  static unsigned char random_char() {
    std::random_device rd;
    std::mt19937 gen(rd()); 
    std::uniform_int_distribution<> dis(0, 255);
    return static_cast<unsigned char>(dis(gen));
  }

  static std::string generate_hex(const unsigned int len) {
    std::stringstream ss;
    for(auto i = 0; i < len; i++) {
      auto rc = random_char();
      std::stringstream hexstream;
      hexstream << std::hex << int(rc);
      auto hex = hexstream.str(); 
      ss << (hex.length() < 2 ? '0' + hex : hex);
    }    
    return ss.str();
  }

  /**
   * @brief Generate a new UUID
   * @return The UUID in string format on success, a null string otherwise 
   */
  CHARSTRING fx__generate__uuid() { // ddb848c4-f7fd-445f-bdc8-033d15d7c528
    loggers::get_instance().log(">>> fx__generate__uuid");

    std::stringstream ss;
    ss << generate_hex(4) << "-";
    ss << generate_hex(2) << "-";
    ss << generate_hex(2) << "-";
    ss << generate_hex(2) << "-";
    ss << generate_hex(4);

    CHARSTRING uuid(ss.str().c_str());
    loggers::get_instance().log_msg("fx__generate__uuid: ", uuid);
    return uuid;
  }

  /**
   * @brief Retrieve the current local date/time formatted as yyyy-mm-ddThh:mm:ss.lll+nn:00
   * @return The the current date/time on success, a null string otherwise 
   */
  CHARSTRING fx__get__current__date__time() { //2018-01-18T13:19:35.367+01:00
    loggers::get_instance().log(">>> fx__get__current__date__time");

    time_t t = std::time(nullptr);
    auto tm = *std::localtime(&t);
    std::ostringstream oss;
    oss << std::put_time(&tm, "%FT%T");//%FT%T%Z

    CHARSTRING dt(oss.str().c_str());
    loggers::get_instance().log_msg("fx__get__current__date__time: ", dt);
    return dt;
  }

  OCTETSTRING fx__enc__PullRequest__1(const http__www__cise__eu__servicemodel__v1__message::PullRequest& p) {
  OCTETSTRING fx__enc__PullRequest__1(const http__www__cise__eu__servicemodel__v1__message::PullRequest& p) { // FIXME Use enc/dec TITAN function external function f_enc_value(in Value x) return bitstring with { extension "prototype(convert) encode(abc)" }
    loggers::get_instance().log(">>> fx__enc__PullRequest__1");

    LibHttp__XmlMessageBodyTypes::XmlBody msg;
@@ -91,4 +36,22 @@ namespace LibCise__Functions {
    return os;
  }

  INTEGER fx__dec__PullRequest__1(BITSTRING &b, http__www__cise__eu__servicemodel__v1__message::PullRequest& p) { // FIXME Use enc/dec TITAN function external function f_enc_value(in Value x) return bitstring with { extension "prototype(convert) encode(abc)" }
    loggers::get_instance().log(">>> fx__dec__PullRequest__1");

    LibHttp__XmlMessageBodyTypes::XmlBody msg;
    xml_codec c;
    OCTETSTRING is = bit2oct(b);
    params parms;
    parms["decode_str"] = std::string(static_cast<const unsigned char *>(is), is.lengthof() + static_cast<const unsigned char *>(is));
    if (c.decode(is, msg, &parms) == -1) {
      loggers::get_instance().warning("fx__dec__PullRequest__1: -1 result code was returned");
      return -1;
    }

    p = msg.msg().pull__request();

    return 0;
  }

} // End of namespace LibCise__Functions
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@
		"java.compile.nullAnalysis.mode": "automatic",
		"java.project.sourcePaths": [
			""
		]
		],
		"java.configuration.updateBuildConfiguration": "interactive"
	}
}
 No newline at end of file
+4 −4
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
# This section shall contain the values of all parameters that are defined in your TTCN-3 modules.

# IUT roles
LibCise_Pics.PICS_IUT_NODE    := true
LibCise_Pics.PICS_IUT_CDM_NODE := true
LibCise_Pics.PICS_IUT_ADAPTOR  := true

# LibCise
@@ -71,8 +71,8 @@ system.httpPort_notif.params := "HTTP(codecs=xml:xml_codec;json:json_codec)/TCP(
# In this section you can specify what parts of your test suite you want to execute.
#AtsCise_TestControl.control

# Check that the IUT responds with an HTPP 200 OK Acknowledgment response when receiving a PullRequest from a known peer with a list of vessels in specified basin - no Acknowledgment required
AtsCise_TestCases.TC_CDM_NODE_PULL_REQUEST_BV_01
# Check that the IUT responds with an HTPP 200 OK Acknowledgment response when receiving a PullRequest for vessels with discovery based on sea basin - no Acknowledgment required
AtsCise_TestCases.TC_CDM_NODE_PULL_REQUEST_BV_01_01

[GROUPS]
# In this section you can specify groups of hosts. These groups can be used inside the
Loading