Commit 32015341 authored by garciay's avatar garciay
Browse files

Enhance AtsRSUSimulator to validate Test System & ATSs

parent a8ab9652
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -26,8 +26,9 @@ int GeoNetworkingCodec::encode (const LibItsGeoNetworking__TypesAndValues::GeoNe
    data = replace(data, _ec.length_position, rpl.lengthof(), rpl);
    loggers::get_instance().log_msg("GeoNetworkingCodec::encode: after replace: ", data);
  }
  loggers::get_instance().log_msg("GeoNetworkingCodec::decode: After encoding: ", data);

  loggers::get_instance().log_msg("<<< GeoNetworkingCodec::encode: data=", data);
  loggers::get_instance().log("<<< GeoNetworkingCodec::encode");
  return 0;
}

@@ -48,8 +49,9 @@ int GeoNetworkingCodec::encode (const LibItsGeoNetworking__TypesAndValues::GnNon
    data = replace(data, _ec.length_position, rpl.lengthof(), rpl);
    loggers::get_instance().log_msg("GeoNetworkingCodec::encode: after replace: ", data);
  }
  loggers::get_instance().log_msg("GeoNetworkingCodec::decode: After encoding: ", data);

  loggers::get_instance().log_msg("<<< GeoNetworkingCodec::encode: data=", data);
  loggers::get_instance().log("<<< GeoNetworkingCodec::encode");
  return 0;
}

@@ -111,7 +113,7 @@ int GeoNetworkingCodec::encode_ (const Base_Type& type, const TTCN_Typedescripto
    type.encode(field_descriptor, encoding_buffer, TTCN_EncDec::CT_RAW);
  }
  
  loggers::get_instance().log_to_hexa("<<<GeoNetworkingCodec::encode_: encoding_buffer=", encoding_buffer);
  loggers::get_instance().log_to_hexa("<<<GeoNetworkingCodec::encode_: ", encoding_buffer);
  return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ int certificates_loader::build_path(const std::string& p_root_directory) {
  // Build full path
  if (!p_root_directory.empty()) {
    _full_path = p_root_directory;
    if (!std::experimental::filesystem::exists(_full_path) || !std::experimental::filesystem::is_directory(_full_path)) {
    if (!std::experimental::filesystem::exists(_full_path) || !std::experimental::filesystem::is_directory(_full_path)) { // FIXME Coredump when app hasn't the rights to create the directory!!!!
      // Create directory
      if (!std::experimental::filesystem::create_directory(_full_path)) {
        _full_path = "./";
+38 −18
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

#include "EtsiTs103097Codec_ToBeSignedData.hh"
#include "EtsiTs103097Codec_Data.hh"
#include "EtsiTs103097Codec_Certificate.hh"

#include "sha256.hh"
#include "sha384.hh"
@@ -87,7 +88,7 @@ int security_services::process_ieee_1609_dot2_content(const IEEE1609dot2::Ieee16
    return -1;
  } else if (p_ieee_1609_dot2_content.ischosen(IEEE1609dot2::Ieee1609Dot2Content::ALT_signedCertificateRequest)) {
    // Reset certificate timer
    loggers::get_instance().error("security_services::process_ieee_1609_dot2_content: TODO Set Certificate re-transmission flag and reset timer");
    loggers::get_instance().log("security_services::process_ieee_1609_dot2_content: Set Certificate re-transmission flag and reset timer");
    _last_generation_time = 0;
    return 0;
  } else { // Shall never be reached
@@ -168,7 +169,7 @@ int security_services::process_ieee_1609_dot2_signed_data(const IEEE1609dot2::Si
        loggers::get_instance().log_to_hexa("security_services::process_ieee_1609_dot2_signed_data: HashedId3: ", _unknown_certificate.data(), _unknown_certificate.size());
      }
      // Reset certificate timer
      loggers::get_instance().log("security_services::process_ieee_1609_dot2_signed_data: Reset certificate generation timer");
      loggers::get_instance().log("security_services::process_ieee_1609_dot2_signed_data: Set Certificate re-transmission flag and reset timer");
      _last_generation_time = 0;
    }
  } else if (p_signed_data.signer().ischosen(IEEE1609dot2::SignerIdentifier::ALT_certificate) && (p_signed_data.signer().certificate().size_of() != 0)) {
@@ -224,8 +225,7 @@ int security_services::process_ieee_1609_dot2_signed_data(const IEEE1609dot2::Si
            loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert);
            const std::vector<unsigned char> v(static_cast<const unsigned char*>(cert.issuer().sha256AndDigest()), static_cast<const unsigned char*>(cert.issuer().sha256AndDigest()) + cert.issuer().sha256AndDigest().lengthof());
            certificate_id = converter::get_instance().bytes_to_hexa(v);
            // TODO Add it into the cache
            loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert);
            // Add it into the cache
            OCTETSTRING public_key_x, public_key_y;
            if (cert.toBeSigned().verifyKeyIndicator().verificationKey().ischosen(IEEE1609dot2BaseTypes::PublicVerificationKey::ALT_ecdsaNistP256)) {
              public_key_x = cert.toBeSigned().verifyKeyIndicator().verificationKey().ecdsaNistP256().uncompressedP256().x();
@@ -237,14 +237,20 @@ int security_services::process_ieee_1609_dot2_signed_data(const IEEE1609dot2::Si
              loggers::get_instance().error("security_services::process_ieee_1609_dot2_signed_data: Unsupported VerificationKey");
              return -1;
            }
            OCTETSTRING os;
            // Encode certificate
            EtsiTs103097Codec_Certificate codec;
            OCTETSTRING enc_cert;
            codec.encode(cert, enc_cert);
            OCTETSTRING hash_cert;
            hash_sha256(enc_cert, hash_cert);
            // And store it into the cache
            _security_cache.get()->store_certificate(
                                                     CHARSTRING(certificate_id.c_str()),
                                                     os,
                                                     os,
                                                     enc_cert,
                                                     int2oct(0, 32), // No way to get the private key here
                                                     public_key_x,
                                                     public_key_y,
                                                     os, //const OCTETSTRING& p_hashid8,
                                                     hash_cert,
                                                     cert.issuer().sha256AndDigest()
                                                     );
          }
@@ -256,17 +262,31 @@ int security_services::process_ieee_1609_dot2_signed_data(const IEEE1609dot2::Si
            loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert);
            const std::vector<unsigned char> v(static_cast<const unsigned char*>(cert.issuer().sha384AndDigest()), static_cast<const unsigned char*>(cert.issuer().sha384AndDigest()) + cert.issuer().sha384AndDigest().lengthof());
            certificate_id = converter::get_instance().bytes_to_hexa(v);
            // TODO Add it into the cache
            /*loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert);
            // Add it into the cache
            OCTETSTRING public_key_x, public_key_y;
            if (cert.toBeSigned().verifyKeyIndicator().verificationKey().ischosen(IEEE1609dot2BaseTypes::PublicVerificationKey::ALT_ecdsaBrainpoolP384r1)) {
              public_key_x = cert.toBeSigned().verifyKeyIndicator().verificationKey().ecdsaBrainpoolP384r1().uncompressedP384().x();
              public_key_y = cert.toBeSigned().verifyKeyIndicator().verificationKey().ecdsaBrainpoolP384r1().uncompressedP384().y();
            } else {
              loggers::get_instance().error("security_services::process_ieee_1609_dot2_signed_data: Unsupported VerificationKey");
              return -1;
            }
            // Encode certificate
            EtsiTs103097Codec_Certificate codec;
            OCTETSTRING enc_cert;
            codec.encode(cert, enc_cert);
            OCTETSTRING hash_cert;
            hash_sha384(enc_cert, hash_cert);
            // And store it into the cache
            _security_cache.get()->store_certificate(
                                                     const CHARSTRING& p_cert_id,
                                                     const OCTETSTRING& p_cert,
                                                     int2oct(0, 32),
                                                     const OCTETSTRING& p_public_key_x,
                                                     const OCTETSTRING& p_public_key_y,
                                                     const OCTETSTRING& p_hashid8,
                                                     const OCTETSTRING& p_issuer
                                                     );*/
                                                     CHARSTRING(certificate_id.c_str()),
                                                     enc_cert,
                                                     int2oct(0, 48), // No way to get the private key here
                                                     public_key_x,
                                                     public_key_y,
                                                     hash_cert,
                                                     cert.issuer().sha384AndDigest()
                                                     );
          }
        }
      } else {