Commit 14f7e3ae authored by Yann Garcia's avatar Yann Garcia
Browse files

Bug fixed in Ats Security

parent ab98e7bf
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ class TTCN_EncDec;

int geonetworking_codec::encode (const LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu& msg, OCTETSTRING& data)
{
  loggers::get_instance().log_msg(">>> geonetworking_codec::encode: ", (const Base_Type&)msg);
  loggers::get_instance().log_msg(">>> geonetworking_codec::encode (1): ", (const Base_Type&)msg);
  
  TTCN_EncDec::clear_error();
  TTCN_Buffer encoding_buffer;
@@ -39,7 +39,7 @@ int geonetworking_codec::encode (const LibItsGeoNetworking__TypesAndValues::GeoN

int geonetworking_codec::encode (const LibItsGeoNetworking__TypesAndValues::GnNonSecuredPacket& p_gnNonSecuredPacket, OCTETSTRING& data)
{
  loggers::get_instance().log_msg(">>> geonetworking_codec::encode: ", (const Base_Type&)p_gnNonSecuredPacket);
  loggers::get_instance().log_msg(">>> geonetworking_codec::encode (2): ", (const Base_Type&)p_gnNonSecuredPacket);

  TTCN_EncDec::clear_error();
  TTCN_Buffer encoding_buffer;
+7 −2
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ void geonetworking_layer::send_data(OCTETSTRING& data, params& params) {
      return;
    }
  }
  if (_secured_mode) { // Add signature support
  if (_secured_mode) { // Add Security support
    if (build_secured_pdu(data, params) != 0) {
      return;
    }
@@ -493,7 +493,7 @@ void geonetworking_layer::send_beacon() {
  _beacon->encode(*(_beacon->get_descriptor()), encoding_buffer, TTCN_EncDec::CT_RAW);
  OCTETSTRING data(encoding_buffer.get_len(), encoding_buffer.get_data());
  params params(_params);
  if (_secured_mode) { // Apply signature
  if (_secured_mode) { // Apply Security
    if (build_secured_pdu(data, _params) != 0) {
      return;
    }
@@ -1016,6 +1016,11 @@ int geonetworking_layer::build_secured_pdu(OCTETSTRING& data, params& params) {
  
  LibItsGeoNetworking__TypesAndValues::BasicHeader basic_header;
  decode_basic_header(data, basic_header);
  if (basic_header.nextHeader() == BasicNextHeader::e__securedPacket) { // Already secured (ATS Security test suite/f_sendSecuredGn/Cam/Denm TTCN-3 functions
    // Leave data unchanged
    loggers::get_instance().log_msg("<<< geonetworking_layer::build_secured_pdu: Leave data unchanged: ", data);
    return 0;
  }
  // Update security mode
  unsigned int basic_header_len = 4;// FIXME How to retrive the BasicHeader length basic_header.get_descriptor()->raw->fieldlength / 8;
  loggers::get_instance().log("geonetworking_layer::build_secured_pdu: basic_header_len = %d", basic_header_len);
+2 −0
Original line number Diff line number Diff line
@@ -516,6 +516,7 @@ int security_services::sign_payload(const OCTETSTRING& p_unsecured_gn_payload, O
  std::string certificate_id = p_params[params::certificate];
  loggers::get_instance().log("security_services::sign_payload: certificate_id = %s", certificate_id.c_str());
  if ((unsigned int)(ms - _last_generation_time) >= 1000 * 0.95) { // Need to add certificate
    loggers::get_instance().log("security_services::sign_payload: Need to add certificate");
    IEEE1609dot2::CertificateBase cert;
    if (_security_db->get_certificate(certificate_id, cert) != 0) {
      loggers::get_instance().warning("security_services:sign_payload: Failed to secure payload");
@@ -527,6 +528,7 @@ int security_services::sign_payload(const OCTETSTRING& p_unsecured_gn_payload, O
    // Reset send certificate timer
    _last_generation_time = ms;
  } else {
    loggers::get_instance().log("security_services::sign_payload: Add digest");
    OCTETSTRING digest;
    if (_security_db->get_hashed_id(certificate_id, digest) != 0) {
      loggers::get_instance().warning("security_services::sign_payload: Failed to secure payload");
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ udp_layer::udp_layer(const std::string & p_type, const std::string & param) : la
  // Initialize the socket
  _saddr.sin_family = AF_INET;
  _saddr.sin_addr.s_addr = INADDR_ANY;
  _saddr.sin_port = htons(std::atoi(_params["src_port"].c_str()));
  _saddr.sin_port = htons(std::atoi(_params["dst_port"].c_str()));
  // Create socket
  _fd = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if (_fd == -1) {
+3 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ LibItsSecurity_Pixits.PX_CERTIFICATE_POOL_PATH := "/home/vagrant/tmp"
# Configuration sub-directory to access certificate stored in files
LibItsSecurity_Pixits.PX_IUT_SEC_CONFIG_NAME := "asn1c_cert"

LibItsPki_Pics.PICS_IUT_COMBINED_EA_AA_ROLE := true

[LOGGING]
# In this section you can specify the name of the log file and the classes of events
@@ -131,7 +132,7 @@ system.utPort.params := "UT_PKI/UDP(dst_ip=172.23.0.1,dst_port=8000)"
[EXECUTE]
#ItsPki_TestCases.TC_SEC_PKI_ITSS_ENR_BV_01
#ItsPki_TestCases.TC_SEC_PKI_ITSS_ENR_BV_02
ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_01
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_01
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_02
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_03
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_04
@@ -143,7 +144,7 @@ ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_01
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_10
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_11
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_12
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_AA_BV_01
ItsPki_TestCases.TC_SEC_PKI_SND_EA_AA_BV_01
#ItsPki_TestCases.TC_SEC_PKI_SND_AA_BV_01

[MAIN_CONTROLLER]
Loading