Commit 01a9c9e2 authored by Denis Filatov's avatar Denis Filatov
Browse files

Merge branch 'STF525' of https://forge.etsi.org/gitlab/ITS/ITS into STF525

parents e1f2572e 5a2f8d34
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ The ETSI ITS protocols project builds and tests regularly on the following platf

  - Linux (Ubuntu)

Note: The [OpenSSL](https://www.openssl.org) version > 1.x is also required.

### Using Vagrant

Pre-requisites on your host machine:
+7 −2
Original line number Diff line number Diff line
@@ -818,7 +818,7 @@ namespace LibItsSecurity__Functions
   * \see http://digital.csic.es/bitstream/10261/32671/1/V2-I2-P7-13.pdf
   */
  // TODO Use common function for both fx__encryptWithEciesxxx and fx__decryptWithEciesxxx function
  OCTETSTRING fx__decryptWithEciesNistp256WithSha256(const OCTETSTRING& p__encryptedSecuredMessage, const OCTETSTRING& p__privateEncKey, const OCTETSTRING& p__publicEphemeralKeyCompressed, const INTEGER& p__ephemeralCompressedMode, const OCTETSTRING& p__encrypted__sym__key, const OCTETSTRING& p__authentication__vector, const OCTETSTRING& p__nonce, const OCTETSTRING& p__salt) {
  OCTETSTRING fx__decryptWithEciesNistp256WithSha256(const OCTETSTRING& p__encryptedSecuredMessage, const OCTETSTRING& p__privateEncKey, const OCTETSTRING& p__publicEphemeralKeyCompressed, const INTEGER& p__ephemeralCompressedMode, const OCTETSTRING& p__encrypted__sym__key, const OCTETSTRING& p__authentication__vector, const OCTETSTRING& p__nonce, const OCTETSTRING& p__salt, OCTETSTRING& p__aes__sym__enc__key) {
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesNistp256WithSha256: p__toBeEncryptedSecuredMessage: ", p__encryptedSecuredMessage);
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesNistp256WithSha256: p__privateEncKey: ", p__privateEncKey);
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesNistp256WithSha256: p__publicEphemeralKeyCompressed: ", p__publicEphemeralKeyCompressed);
@@ -849,6 +849,8 @@ namespace LibItsSecurity__Functions
      return OCTETSTRING(0, nullptr);
    }
    loggers::get_instance().log_msg("fx__decryptWithEciesNistp256WithSha256: dec message: ", message);
    p__aes__sym__enc__key = ec.symmetric_encryption_key();
    loggers::get_instance().log_msg("fx__decryptWithEciesNistp256WithSha256: AES 128 encryption key: ", p__aes__sym__enc__key);
    
    return message;
  }
@@ -960,7 +962,7 @@ namespace LibItsSecurity__Functions
    return enc_message;
  }
  
  OCTETSTRING fx__decryptWithEciesBrainpoolp256WithSha256(const OCTETSTRING& p__encryptedSecuredMessage, const OCTETSTRING& p__privateEncKey, const OCTETSTRING& p__publicEphemeralKeyCompressed, const INTEGER& p__ephemeralCompressedMode, const OCTETSTRING& p__encrypted__sym__key, const OCTETSTRING& p__authentication__vector, const OCTETSTRING& p__nonce) {
  OCTETSTRING fx__decryptWithEciesBrainpoolp256WithSha256(const OCTETSTRING& p__encryptedSecuredMessage, const OCTETSTRING& p__privateEncKey, const OCTETSTRING& p__publicEphemeralKeyCompressed, const INTEGER& p__ephemeralCompressedMode, const OCTETSTRING& p__encrypted__sym__key, const OCTETSTRING& p__authentication__vector, const OCTETSTRING& p__nonce, const OCTETSTRING& p__salt, OCTETSTRING& p__aes__sym__enc__key) {
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesBrainpoolp256WithSha256: p__toBeEncryptedSecuredMessage: ", p__encryptedSecuredMessage);
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesBrainpoolp256WithSha256: p__privateEncKey: ", p__privateEncKey);
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesBrainpoolp256WithSha256: p__publicEphemeralKeyCompressed: ", p__publicEphemeralKeyCompressed);
@@ -968,6 +970,7 @@ namespace LibItsSecurity__Functions
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesBrainpoolp256WithSha256: p__nonce: ", p__nonce);
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesBrainpoolp256WithSha256: p__authentication__vector: ", p__authentication__vector);
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesBrainpoolp256WithSha256: p__encrypted__sym__key: ", p__encrypted__sym__key);
    loggers::get_instance().log_msg(">>> fx__decryptWithEciesBrainpoolp256WithSha256: p__salt", p__salt);

    // 1. Create security_ecc instance based on public ephemeral keys
    security_ecc ec(ec_elliptic_curves::brainpool_p_256_r1, p__privateEncKey);
@@ -990,6 +993,8 @@ namespace LibItsSecurity__Functions
      return OCTETSTRING(0, nullptr);
    }
    loggers::get_instance().log_msg("fx__decryptWithEciesBrainpoolp256WithSha256: dec message: ", message);
    p__aes__sym__enc__key = ec.symmetric_encryption_key();
    loggers::get_instance().log_msg("fx__decryptWithEciesBrainpoolp256WithSha256: AES 128 encryption key: ", p__aes__sym__enc__key);

    return message;
  }
+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ const std::string& params::uri = std::string("uri");
const std::string& params::host = std::string("host");
const std::string& params::content_type = std::string("content_type");

//const std::string& params::sip_url = std::string("sip_url");
//const std::string& params::sip_version = std::string("sip_version");
//const std::string& params::payload = std::string("payload");

const std::string& params::codecs = std::string("codecs");

void params::convert(params& p_param, const std::string p_parameters) {
+33 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ void ConfigRsuSimulatorLayer::sendMsg(const LibItsPki__TypesAndValues::UtPkiResu
    encoding_buffer.put_c(0x01/*static_cast<const unsigned char>(uppertester_pki_codec::c_utPkiInitializeResult)*/);
    encoding_buffer.put_c((unsigned char)static_cast<const boolean>(send_par.utPkiInitializeResult()));
  } else if (send_par.ischosen(LibItsPki__TypesAndValues::UtPkiResults::ALT_utPkiTriggerResult)) {
    encoding_buffer.put_c(0x11/*static_cast<const unsigned char>(uppertester_pki_codec::c_utPkiTriggerResult)*/);
    encoding_buffer.put_c(0xBC/*static_cast<const unsigned char>(uppertester_pki_codec::c_utPkiTriggerResult)*/);
    encoding_buffer.put_c((unsigned char)static_cast<const boolean>(send_par.utPkiTriggerResult()));
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::sendMsg: Unsupported UtPkiResults variant");
@@ -135,6 +135,8 @@ void ConfigRsuSimulatorLayer::receive_data(OCTETSTRING& data, params& params)
    process_ut_cam_changeheading_data(data, params);
  } else if ((id >= 0x50) && (id <= 0x54)) { // Receive an UtGnTrigger
    process_ut_geonetworking_trigger(data, params);
  } else if ((id >= 0xBB) && (id <= 0xBF)) { // Receive an UtPkiTrigger
    process_ut_pki_trigger(data, params);
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::receive_data: Unsupported tag %02x", id);
  }
@@ -165,6 +167,11 @@ int ConfigRsuSimulatorLayer::process_utinitialize_data(const OCTETSTRING& data,
    LibItsDenm__TypesAndValues::UtDenmInitialize p(hashedId);
    // Pass it to the ports if any
    to_all_upper_ports(p, params);
  } else if (_params[std::string("ut")].compare("pki") == 0) {
    OCTETSTRING hashedId(data.lengthof() - 1,  1 + static_cast<const unsigned char*>(data));
    LibItsPki__TypesAndValues::UtPkiInitialize p(hashedId);
    // Pass it to the ports if any
    to_all_upper_ports(p, params);
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_utinitialize_data: Unsupported protocol");
    return -1;
@@ -281,4 +288,29 @@ int ConfigRsuSimulatorLayer::process_ut_geonetworking_trigger(const OCTETSTRING&
  return 0;
}

int ConfigRsuSimulatorLayer::process_ut_pki_trigger(const OCTETSTRING& data, params& params) {
  loggers::get_instance().log(">>> ConfigRsuSimulatorLayer::process_ut_pki_trigger");

  params::const_iterator it = _params.find("ut");
  if (it == _params.cend()) {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_ut_pki_trigger: CF layer's ut parameter is missing");
    return -1;
  }

  if (_params[std::string("ut")].compare("pki") == 0) {
    LibItsPki__TypesAndValues::UtPkiTrigger p;
    p.triggerEnrolmentRequest().cannonicalId() = OCTETSTRING(0, nullptr); // No parameter used
    p.triggerEnrolmentRequest().encAlgorithm() = OCTETSTRING(0, nullptr); // No parameter used
    p.triggerEnrolmentRequest().privateKey() = OCTETSTRING(0, nullptr); // No parameter used
    p.triggerEnrolmentRequest().compressedPublickey() = OCTETSTRING(0, nullptr); // No parameter used
    // Pass it to the ports if any
    to_all_upper_ports(p, params);
  } else {
    loggers::get_instance().warning("ConfigRsuSimulatorLayer::process_ut_pki_trigger: Unsupported protocol");
    return -1;
  }

  return 0;
}

ConfigRsuSimulatorLayerFactory ConfigRsuSimulatorLayerFactory::_f;
+1 −0
Original line number Diff line number Diff line
@@ -48,5 +48,6 @@ private:
  int process_ut_cam_changecurvature_data(const OCTETSTRING& data, params& params);
  int process_ut_cam_changeheading_data(const OCTETSTRING& data, params& params);
  int process_ut_geonetworking_trigger(const OCTETSTRING& data, params& params);
  int process_ut_pki_trigger(const OCTETSTRING& data, params& params);

}; // End of class ConfigRsuSimulatorLayer
Loading