Loading ccsrc/Protocols/GeoNetworking/GeoNetworkingCodec.cc +5 −3 Changes for ccsrc/Protocols/GeoNetworking/GeoNetworkingCodec.cc: 5 added lines, 3 removed lines. Original line number Original line Diff line number Diff line Loading @@ -26,8 +26,9 @@ int GeoNetworkingCodec::encode (const LibItsGeoNetworking__TypesAndValues::GeoNe data = replace(data, _ec.length_position, rpl.lengthof(), rpl); 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::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; return 0; } } Loading @@ -48,8 +49,9 @@ int GeoNetworkingCodec::encode (const LibItsGeoNetworking__TypesAndValues::GnNon data = replace(data, _ec.length_position, rpl.lengthof(), rpl); 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::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; return 0; } } Loading Loading @@ -111,7 +113,7 @@ int GeoNetworkingCodec::encode_ (const Base_Type& type, const TTCN_Typedescripto type.encode(field_descriptor, encoding_buffer, TTCN_EncDec::CT_RAW); 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; return 0; } } Loading ccsrc/Protocols/Security/certificates_loader.cc +1 −1 Changes for ccsrc/Protocols/Security/certificates_loader.cc: 1 added line, 1 removed line. Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ int certificates_loader::build_path(const std::string& p_root_directory) { // Build full path // Build full path if (!p_root_directory.empty()) { if (!p_root_directory.empty()) { _full_path = p_root_directory; _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 // Create directory if (!std::experimental::filesystem::create_directory(_full_path)) { if (!std::experimental::filesystem::create_directory(_full_path)) { _full_path = "./"; _full_path = "./"; Loading ccsrc/Protocols/Security/security_services.cc +38 −18 Changes for ccsrc/Protocols/Security/security_services.cc: 38 added lines, 18 removed lines. Original line number Original line Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "EtsiTs103097Codec_ToBeSignedData.hh" #include "EtsiTs103097Codec_ToBeSignedData.hh" #include "EtsiTs103097Codec_Data.hh" #include "EtsiTs103097Codec_Data.hh" #include "EtsiTs103097Codec_Certificate.hh" #include "sha256.hh" #include "sha256.hh" #include "sha384.hh" #include "sha384.hh" Loading Loading @@ -87,7 +88,7 @@ int security_services::process_ieee_1609_dot2_content(const IEEE1609dot2::Ieee16 return -1; return -1; } else if (p_ieee_1609_dot2_content.ischosen(IEEE1609dot2::Ieee1609Dot2Content::ALT_signedCertificateRequest)) { } else if (p_ieee_1609_dot2_content.ischosen(IEEE1609dot2::Ieee1609Dot2Content::ALT_signedCertificateRequest)) { // Reset certificate timer // 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; _last_generation_time = 0; return 0; return 0; } else { // Shall never be reached } else { // Shall never be reached Loading Loading @@ -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()); loggers::get_instance().log_to_hexa("security_services::process_ieee_1609_dot2_signed_data: HashedId3: ", _unknown_certificate.data(), _unknown_certificate.size()); } } // Reset certificate timer // 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; _last_generation_time = 0; } } } else if (p_signed_data.signer().ischosen(IEEE1609dot2::SignerIdentifier::ALT_certificate) && (p_signed_data.signer().certificate().size_of() != 0)) { } else if (p_signed_data.signer().ischosen(IEEE1609dot2::SignerIdentifier::ALT_certificate) && (p_signed_data.signer().certificate().size_of() != 0)) { Loading Loading @@ -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); 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()); 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); certificate_id = converter::get_instance().bytes_to_hexa(v); // TODO Add it into the cache // Add it into the cache loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert); OCTETSTRING public_key_x, public_key_y; OCTETSTRING public_key_x, public_key_y; if (cert.toBeSigned().verifyKeyIndicator().verificationKey().ischosen(IEEE1609dot2BaseTypes::PublicVerificationKey::ALT_ecdsaNistP256)) { if (cert.toBeSigned().verifyKeyIndicator().verificationKey().ischosen(IEEE1609dot2BaseTypes::PublicVerificationKey::ALT_ecdsaNistP256)) { public_key_x = cert.toBeSigned().verifyKeyIndicator().verificationKey().ecdsaNistP256().uncompressedP256().x(); public_key_x = cert.toBeSigned().verifyKeyIndicator().verificationKey().ecdsaNistP256().uncompressedP256().x(); Loading @@ -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"); loggers::get_instance().error("security_services::process_ieee_1609_dot2_signed_data: Unsupported VerificationKey"); return -1; 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( _security_cache.get()->store_certificate( CHARSTRING(certificate_id.c_str()), CHARSTRING(certificate_id.c_str()), os, enc_cert, os, int2oct(0, 32), // No way to get the private key here public_key_x, public_key_x, public_key_y, public_key_y, os, //const OCTETSTRING& p_hashid8, hash_cert, cert.issuer().sha256AndDigest() cert.issuer().sha256AndDigest() ); ); } } Loading @@ -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); 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()); 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); certificate_id = converter::get_instance().bytes_to_hexa(v); // TODO Add it into the cache // Add it into the cache /*loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert); 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( _security_cache.get()->store_certificate( const CHARSTRING& p_cert_id, CHARSTRING(certificate_id.c_str()), const OCTETSTRING& p_cert, enc_cert, int2oct(0, 32), int2oct(0, 48), // No way to get the private key here const OCTETSTRING& p_public_key_x, public_key_x, const OCTETSTRING& p_public_key_y, public_key_y, const OCTETSTRING& p_hashid8, hash_cert, const OCTETSTRING& p_issuer cert.issuer().sha384AndDigest() );*/ ); } } } } } else { } else { Loading Loading
ccsrc/Protocols/GeoNetworking/GeoNetworkingCodec.cc +5 −3 Changes for ccsrc/Protocols/GeoNetworking/GeoNetworkingCodec.cc: 5 added lines, 3 removed lines. Original line number Original line Diff line number Diff line Loading @@ -26,8 +26,9 @@ int GeoNetworkingCodec::encode (const LibItsGeoNetworking__TypesAndValues::GeoNe data = replace(data, _ec.length_position, rpl.lengthof(), rpl); 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::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; return 0; } } Loading @@ -48,8 +49,9 @@ int GeoNetworkingCodec::encode (const LibItsGeoNetworking__TypesAndValues::GnNon data = replace(data, _ec.length_position, rpl.lengthof(), rpl); 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::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; return 0; } } Loading Loading @@ -111,7 +113,7 @@ int GeoNetworkingCodec::encode_ (const Base_Type& type, const TTCN_Typedescripto type.encode(field_descriptor, encoding_buffer, TTCN_EncDec::CT_RAW); 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; return 0; } } Loading
ccsrc/Protocols/Security/certificates_loader.cc +1 −1 Changes for ccsrc/Protocols/Security/certificates_loader.cc: 1 added line, 1 removed line. Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,7 @@ int certificates_loader::build_path(const std::string& p_root_directory) { // Build full path // Build full path if (!p_root_directory.empty()) { if (!p_root_directory.empty()) { _full_path = p_root_directory; _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 // Create directory if (!std::experimental::filesystem::create_directory(_full_path)) { if (!std::experimental::filesystem::create_directory(_full_path)) { _full_path = "./"; _full_path = "./"; Loading
ccsrc/Protocols/Security/security_services.cc +38 −18 Changes for ccsrc/Protocols/Security/security_services.cc: 38 added lines, 18 removed lines. Original line number Original line Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include "EtsiTs103097Codec_ToBeSignedData.hh" #include "EtsiTs103097Codec_ToBeSignedData.hh" #include "EtsiTs103097Codec_Data.hh" #include "EtsiTs103097Codec_Data.hh" #include "EtsiTs103097Codec_Certificate.hh" #include "sha256.hh" #include "sha256.hh" #include "sha384.hh" #include "sha384.hh" Loading Loading @@ -87,7 +88,7 @@ int security_services::process_ieee_1609_dot2_content(const IEEE1609dot2::Ieee16 return -1; return -1; } else if (p_ieee_1609_dot2_content.ischosen(IEEE1609dot2::Ieee1609Dot2Content::ALT_signedCertificateRequest)) { } else if (p_ieee_1609_dot2_content.ischosen(IEEE1609dot2::Ieee1609Dot2Content::ALT_signedCertificateRequest)) { // Reset certificate timer // 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; _last_generation_time = 0; return 0; return 0; } else { // Shall never be reached } else { // Shall never be reached Loading Loading @@ -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()); loggers::get_instance().log_to_hexa("security_services::process_ieee_1609_dot2_signed_data: HashedId3: ", _unknown_certificate.data(), _unknown_certificate.size()); } } // Reset certificate timer // 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; _last_generation_time = 0; } } } else if (p_signed_data.signer().ischosen(IEEE1609dot2::SignerIdentifier::ALT_certificate) && (p_signed_data.signer().certificate().size_of() != 0)) { } else if (p_signed_data.signer().ischosen(IEEE1609dot2::SignerIdentifier::ALT_certificate) && (p_signed_data.signer().certificate().size_of() != 0)) { Loading Loading @@ -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); 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()); 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); certificate_id = converter::get_instance().bytes_to_hexa(v); // TODO Add it into the cache // Add it into the cache loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert); OCTETSTRING public_key_x, public_key_y; OCTETSTRING public_key_x, public_key_y; if (cert.toBeSigned().verifyKeyIndicator().verificationKey().ischosen(IEEE1609dot2BaseTypes::PublicVerificationKey::ALT_ecdsaNistP256)) { if (cert.toBeSigned().verifyKeyIndicator().verificationKey().ischosen(IEEE1609dot2BaseTypes::PublicVerificationKey::ALT_ecdsaNistP256)) { public_key_x = cert.toBeSigned().verifyKeyIndicator().verificationKey().ecdsaNistP256().uncompressedP256().x(); public_key_x = cert.toBeSigned().verifyKeyIndicator().verificationKey().ecdsaNistP256().uncompressedP256().x(); Loading @@ -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"); loggers::get_instance().error("security_services::process_ieee_1609_dot2_signed_data: Unsupported VerificationKey"); return -1; 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( _security_cache.get()->store_certificate( CHARSTRING(certificate_id.c_str()), CHARSTRING(certificate_id.c_str()), os, enc_cert, os, int2oct(0, 32), // No way to get the private key here public_key_x, public_key_x, public_key_y, public_key_y, os, //const OCTETSTRING& p_hashid8, hash_cert, cert.issuer().sha256AndDigest() cert.issuer().sha256AndDigest() ); ); } } Loading @@ -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); 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()); 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); certificate_id = converter::get_instance().bytes_to_hexa(v); // TODO Add it into the cache // Add it into the cache /*loggers::get_instance().log_msg("security_services::process_ieee_1609_dot2_signed_data: Store new certificate in cache: ", cert); 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( _security_cache.get()->store_certificate( const CHARSTRING& p_cert_id, CHARSTRING(certificate_id.c_str()), const OCTETSTRING& p_cert, enc_cert, int2oct(0, 32), int2oct(0, 48), // No way to get the private key here const OCTETSTRING& p_public_key_x, public_key_x, const OCTETSTRING& p_public_key_y, public_key_y, const OCTETSTRING& p_hashid8, hash_cert, const OCTETSTRING& p_issuer cert.issuer().sha384AndDigest() );*/ ); } } } } } else { } else { Loading