Commit c6a28be1 authored by YannGarcia's avatar YannGarcia
Browse files

Bug fixed in eencvalue/decvalue for PullRequest

parent b857bcd1
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@

namespace LibCise__Functions {

  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");
  BITSTRING 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");

    LibHttp__XmlMessageBodyTypes::XmlBody msg;
    msg.msg().pull__request() = p;
@@ -26,18 +26,18 @@ namespace LibCise__Functions {
    xml_codec c;
    OCTETSTRING os;
    int result = c.encode(msg, os);
    loggers::get_instance().log_msg("fx__enc__PullRequest__1: os: ", os);
    loggers::get_instance().log_msg("fx__enc__PullRequest: os: ", os);

    // Remove XML header added by the XML codec.
    OCTETSTRING h = char2oct("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n");
    os = OCTETSTRING(os.lengthof() - h.lengthof(), static_cast<const unsigned char*>(os) + h.lengthof());
    loggers::get_instance().log_msg("fx__enc__PullRequest__1: os: ", os);
    loggers::get_instance().log_msg("fx__enc__PullRequest: os: ", os);

    return os;
    return oct2bit(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");
    loggers::get_instance().log(">>> fx__dec__PullRequest");

    LibHttp__XmlMessageBodyTypes::XmlBody msg;
    xml_codec c;
@@ -45,7 +45,7 @@ namespace LibCise__Functions {
    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");
      loggers::get_instance().warning("fx__dec__PullRequest: -1 result code was returned");
      return -1;
    }

+0 −6
Original line number Diff line number Diff line
@@ -6,12 +6,6 @@
		{
			"path": "../../frameworks/xmlsec"
		},
		{
			"path": "../../tmp/xer_decoding_issue"
		},
		{
			"path": "../../tmp/ttcn_cisetp-main/ttcn_cisetp-main"
		},
		{
			"path": "../../frameworks/cise-sim"
		}
Original line number Diff line number Diff line
Subproject commit 05b0d9241eb21b3d98839812d29e4c5cc1360649
Subproject commit 0a28ff34d9ca15d6ed481dad98485210e4d6e179
+6 −6
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ module AtsCise_TestCases {
      // var charstring v_date_time := "2023-02-15T09:47:23+0100"; // For debug purpose with Mockoon
      // var charstring v_message_id := "c57dc1e1-9473-c1fa-40c4-88a4fc32"; // For debug purpose with Mockoon
      // var charstring v_correlation_id := "19789ef3-2e5f-393d-9011-407be7d5"; // For debug purpose with Mockoon
      var PullRequest v_pull_request;
      var PullRequest_1 v_pull_request;
      var octetstring v_pull_request_signed;
      var charstring v_pull_request_canonicalized;
      var charstring v_pull_request_signed_str;
@@ -146,9 +146,9 @@ module AtsCise_TestCases {
                            )))))) -> value v_response {
          tc_ac.stop;

          var bitstring v_enc := oct2bit(v_pull_request_signed);
          fx_dec_PullRequest_1(v_enc, v_pull_request);
          f_verify_sign_pull_request(valueof(m_xml_body_pull_request(v_pull_request, v_pull_request_signed_str)), v_pull_request_signed_str);
          // var bitstring v_enc := oct2bit(v_pull_request_signed);
          // fx_dec_PullRequest_1(v_enc, v_pull_request);
          // f_verify_sign_pull_request(valueof(m_xml_body_pull_request(v_pull_request, v_pull_request_signed_str)), v_pull_request_signed_str);

          log("*** " & testcasename() & ": PASS: IUT successfully received Acknowledgment ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success); // TODO Repeat and wait for the PullResponse ???
@@ -205,7 +205,7 @@ module AtsCise_TestCases {
      // var charstring v_date_time := "2023-02-15T09:47:23+0100"; // For debug purpose with Mockoon
      // var charstring v_message_id := "c57dc1e1-9473-c1fa-40c4-88a4fc32"; // For debug purpose with Mockoon
      // var charstring v_correlation_id := "19789ef3-2e5f-393d-9011-407be7d5"; // For debug purpose with Mockoon
      var PullRequest v_pull_request;
      var PullRequest_1 v_pull_request;
      var octetstring v_pull_request_signed;
      var charstring v_pull_request_canonicalized;
      var charstring v_pull_request_signed_str;
@@ -385,7 +385,7 @@ module AtsCise_TestCases {
                                                                                                                              mw_pull_request
                                  ))))) -> value v_request {
            var Headers v_headers;
            var PullRequest v_pull_request := v_request.request.body.xml_body.msg.pull_request;
            var PullRequest_1 v_pull_request := v_request.request.body.xml_body.msg.pull_request;

            tc_ac.stop;

+12 −17
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@ module LibCise_Functions {

  group cise_externals {

    external function fx_enc_PullRequest_1(in PullRequest p) return octetstring;
    external function fx_enc_PullRequest_1(in PullRequest_1 p) return bitstring with {extension "prototype(convert) encode(XML)"};

    external function fx_dec_PullRequest_1(inout bitstring b, out PullRequest p) return integer;
    external function fx_dec_PullRequest_1(inout bitstring b, out PullRequest p) return integer with {extension "prototype(sliding) decode(XML)"};

  } // End of group cise_externals

@@ -57,7 +57,7 @@ module LibCise_Functions {
  group cise_functions {

    function f_sign_pull_request(
                                 in PullRequest p_pull_request, 
                                 in PullRequest_1 p_pull_request, 
                                 in HashAlgorithm p_hash_algorithm, 
                                 in charstring p_certificate_name, 
                                 in charstring p_private_key_name, 
@@ -74,17 +74,14 @@ module LibCise_Functions {
      var octetstring v_h := char2oct("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n");

      // Encode the pull request
      //v_encoded_pull_request := bit2oct(encvalue(p_pull_request));
      v_encoded_pull_request := fx_enc_PullRequest_1(p_pull_request); // Use encvalue decoration
      //external function fx_enc_PullRequest_1(in PullRequest p_pull_request) return bitstring with {extension "prototype(convert) encode(XML)"}
      //external function fx_dec_PullRequest_1(inout bitstring b, out PullRequest p_pull_request)return integer with {extension "prototype(sliding) decode(XML)"}
      v_encoded_pull_request := bit2oct(encvalue(p_pull_request)); // FIXME Why encvalue does not call fx_enc_PullRequest
      //v_encoded_pull_request := bit2oct(fx_enc_PullRequest(p_pull_request));
      log("f_sign_pull_request: v_encoded_pull_request: ", v_encoded_pull_request);

      // Encode empty signature
      log("f_sign_pull_request: m_to_be_signed: ", m_to_be_signed);
      v_empty_signature := fx_enc_xmldsig_signed_info(valueof(m_to_be_signed)); // Use encvalue decoration
      //external function fx_enc_PullRequest_1(in PullRequest p_pull_request) return bitstring with {extension "prototype(convert) encode(XML)"}
      //external function fx_dec_PullRequest_1(inout bitstring b, out PullRequest p_pull_request)return integer with {extension "prototype(sliding) decode(XML)"}
      v_empty_signature := bit2oct(encvalue(valueof(m_to_be_signed)));
      //v_empty_signature := fx_enc_xmldsig_signed_info(valueof(m_to_be_signed));
      log("f_sign_pull_request: Empty signature: ", v_empty_signature);

      // Sign the XML document (envelopped signature)
@@ -121,9 +118,8 @@ module LibCise_Functions {

      // Encode empty signature
      log("f_verify_sign_pull_request: m_to_be_signed: ", m_to_be_signed);
      v_empty_signature := fx_enc_xmldsig_signed_info(valueof(m_to_be_signed)); // Use encvalue decoration
      //external function fx_enc_PullRequest_1(in PullRequest p_pull_request) return bitstring with {extension "prototype(convert) encode(XML)"}
      //external function fx_dec_PullRequest_1(inout bitstring b, out PullRequest p_pull_request)return integer with {extension "prototype(sliding) decode(XML)"}
      v_empty_signature := bit2oct(encvalue(valueof(m_to_be_signed)));
      //v_empty_signature := fx_enc_xmldsig_signed_info(valueof(m_to_be_signed));
      log("f_verify_sign_pull_request: Empty signature: ", v_empty_signature);

      // Remove XML header
@@ -162,7 +158,7 @@ module LibCise_Functions {
      //v_signature := "<Signature xmlns='http://www.w3.org/2000/09/xmldsig#'><SignedInfo><CanonicalizationMethod Algorithm='http://www.w3.org/2001/10/xml-exc-c14n#'/><SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/><Reference URI=''><Transforms><Transform Algorithm='http://www.w3.org/TR/1999/REC-xslt-19991116'>&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:s=&quot;http://www.w3.org/2000/09/xmldsig#&quot;&gt;&lt;xsl:strip-space elements=&quot;*&quot;/&gt;&lt;xsl:output indent=&quot;false&quot; method=&quot;xml&quot; omit-xml-declaration=&quot;yes&quot;/&gt;&lt;xsl:template match=&quot;*[not(self::s:Signature)]&quot;&gt;&lt;xsl:element name=&quot;{local-name()}&quot;&gt;&lt;xsl:apply-templates select=&quot;*|text()&quot;/&gt;&lt;/xsl:element&gt;&lt;/xsl:template&gt;&lt;xsl:template match=&quot;s:Signature&quot;/&gt;&lt;/xsl:stylesheet&gt;</Transform></Transforms><DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/><DigestValue>/BJYqCxysmoxc+om/lia7dYNtls=</DigestValue></Reference></SignedInfo><SignatureValue>VT4rwGff9QkVLwDDcd7bvi7EfoLBTfPkvTX2PCpRHiGdnGPeofqBCHK2ehv3jg+zMZA4CU55r7yYYITS553RkdqpA1qhE0PeiWJ1QvkNyc1HS05HySTJZtolOen8xUVvvWbbaye6bT/Y/I3jgoICHOU20Ln53tqr3P3NJ4CroH6OoNhO618AXKQMr/B1fSyML43xT1qgCrodQ9F5XRIORjIV9d/OOjHZnKyFr9eb33jz3vH7ZO9YVwoayWTGHHRH86aQmIuQTiVGjUPQbyfrrV7XiEKCwaT+ff7giAOVsf5tcH4juOawD9TwYMJV5EYMVw3HuyjJ7hPqkj29UqcvYA==</SignatureValue><KeyInfo><X509Data><X509SubjectName>/C=fr/DC=eucise/O=sim1-node01.node01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Fyb290LWNhLmV1Y2lzZS5mcoICEAAwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBCwUAA4IBAQAXcg1cv7whV2DFC/hKsQeGw7gx5cMrYM0H3v6huyeJy1mqdSY6rFus1mV4PmwrfzKORoQAGHrRGcGWCanjUqc0vmfKZFh8p4IDoF+9BkKBmJT/QvtulPPyrS9cRaW3qK7y1XIDAADKU3l8TpTei4XpFwJCN4Waqp9U+PPqhLao6YvSj/5HdI7OKsPbAdvRfPAwz9L6GLheK++E2GGZyxmgOPGlVg7dyOjtbuJNCRyQvXrNrIT0s+F47EpJYcEQD8gxzXzCFGm9Rf5kqRfWv1Sa7KItjCMdl3wOMMKzAOLTEfqIEHqilreOjGyV8gtAGDAdlBub291m0ftocEztgRqH</X509Certificate></X509Data></KeyInfo></Signature>";
      var bitstring v_dec := oct2bit(unichar2oct(v_signature));
      var Signature v_sign; 
      var integer v_result := fx_dec_xmldsig(v_dec, v_sign);
      var integer v_result := decvalue/*fx_dec_xmldsig*/(v_dec, v_sign);
      log("f_verify_sign_pull_request: v_result: ", v_result);
      if (v_result != 0) {
        log("security_services::do_sign_verify: failed to decode Signature");
@@ -219,9 +215,8 @@ module LibCise_Functions {
      log("f_xml_build_envolopped_signature: v_xml_signature: ", v_xml_signature);

      // Encode signature
      v_signature := fx_enc_xmldsig(v_xml_signature); // Use encvalue decoration
      //external function fx_enc_PullRequest_1(in PullRequest p_pull_request) return bitstring with {extension "prototype(convert) encode(XML)"}
      //external function fx_dec_PullRequest_1(inout bitstring b, out PullRequest p_pull_request)return integer with {extension "prototype(sliding) decode(XML)"}
      v_signature := bit2oct(encvalue(v_xml_signature));
      //v_signature := fx_enc_xmldsig(v_xml_signature);
      log("f_xml_build_envolopped_signature: v_signature (1): ", v_signature);
      // Remove latest \n
      for (i := lengthof(v_signature) - 1; i > 0 and v_signature[i] == '0A'O; i := i - 1) {};