Commit 717f6fa7 authored by Yann Garcia's avatar Yann Garcia
Browse files

Review date/time

parent daca0d7c
......@@ -159,9 +159,9 @@ int security_services::process_ieee_1609_dot2_signed_data(const IEEE1609dot2::Si
const OPTIONAL<INTEGER>& v = dynamic_cast<const OPTIONAL<INTEGER>& >(header_info.generationTime()); // in millisecond
unsigned long long gt = ((INTEGER&)(*v.get_opt_value())).get_long_long_val();
// Get current time timestamp
unsigned long long ms = base_time::get_instance().get_its_current_time_us(); // in millisecond
loggers::get_instance().log("security_services::process_ieee_1609_dot2_signed_data: generation time check %ld / %ld", header_info.generationTime(), ms);
if (abs((double)gt - (double)ms) >= 5.0) { // TODO Use a params for generation_time_epsilon
unsigned long long us = base_time::get_instance().get_its_current_time_us(); // in millisecond
loggers::get_instance().log("security_services::process_ieee_1609_dot2_signed_data: generation time check %ld / %ld, delta = %f", header_info.generationTime(), us, abs((double)gt - (double)us));
if (abs((double)gt - (double)us) >= 5.0) { // TODO Use a params for generation_time_epsilon
loggers::get_instance().warning("security_services::process_ieee_1609_dot2_signed_data: Invalid generation time, discard it");
if (p_verify) {
return -1;
......@@ -486,10 +486,12 @@ int security_services::sign_payload(const OCTETSTRING& p_unsecured_gn_payload, O
loggers::get_instance().log("security_services::sign_payload: Payload type not set");
// Noting to do
}
unsigned long long ms = base_time::get_instance().get_its_current_time_us();
unsigned long long us = base_time::get_instance().get_its_current_time_us();
loggers::get_instance().log("security_services::sign_payload: HeaderInfo timestamp: %ld", us);
INTEGER i;
i.set_long_long_val((unsigned int)ms);
i.set_long_long_val(us);
header_info.generationTime() = OPTIONAL<INTEGER>(i);
loggers::get_instance().log("security_services::sign_payload: Finame HeaderInfo timestamp: %ld", us);
// Check if a certificate shall be requested
if (_unknown_certificate.lengthof() == 3) { // HashedId3
IEEE1609dot2BaseTypes::SequenceOfHashedId3 s;
......@@ -512,10 +514,10 @@ int security_services::sign_payload(const OCTETSTRING& p_unsecured_gn_payload, O
return -1;
}
IEEE1609dot2::SignerIdentifier signer;
loggers::get_instance().log("security_services::sign_payload: ms = %d - _last_generation_time = %d - ms - _last_generation_time = %d", (unsigned int)ms, _last_generation_time, (unsigned int)(ms - _last_generation_time));
loggers::get_instance().log("security_services::sign_payload: us = %d - _last_generation_time = %ld - us - _last_generation_time = %ld", us, _last_generation_time, us - _last_generation_time);
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
if ((unsigned int)(us - _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) {
......@@ -526,7 +528,7 @@ int security_services::sign_payload(const OCTETSTRING& p_unsecured_gn_payload, O
sequenceOfCertificate[0] = cert;
signer.certificate() = sequenceOfCertificate;
// Reset send certificate timer
_last_generation_time = ms;
_last_generation_time = us;
} else {
loggers::get_instance().log("security_services::sign_payload: Add digest");
OCTETSTRING digest;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment