Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ITS - Intelligent Transport Systems
ITS
Commits
53a1d335
Commit
53a1d335
authored
Feb 21, 2019
by
Yann Garcia
Browse files
Security uses TAI not UTC: Need to add 4 Leap seconds
parent
2ef207bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
ccsrc/Framework/base_time.hh
View file @
53a1d335
...
...
@@ -19,9 +19,11 @@
class
base_time
{
const
unsigned
long
long
its_base_time_ms
=
1072915200000L
;
//! Base time 01/01/2004 12:00am in millseconds
unsigned
long
long
leap_delay
;
static
base_time
*
_instance
;
private:
base_time
()
{
};
//! Can not be created manually
base_time
()
:
leap_delay
{
0
}
{
};
//! Can not be created manually
public:
static
inline
base_time
&
get_instance
();
...
...
@@ -33,6 +35,8 @@ public:
inline
const
unsigned
long
long
get_its_current_time_ms
()
const
;
inline
const
unsigned
long
long
get_its_current_time_us
()
const
;
inline
const
unsigned
long
long
get_its_current_time_mod_ms
()
const
;
inline
void
set_leap_delay_us
(
const
unsigned
long
long
p_leap_delay
);
inline
const
unsigned
long
long
get_leap_delay_us
()
const
;
};
// End of class base_time
// static functions
...
...
@@ -41,7 +45,7 @@ base_time& base_time::get_instance() {
}
const
unsigned
long
long
base_time
::
get_current_time_ms
()
const
{
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
return
(
leap_delay
/
1000
)
+
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
}
const
unsigned
long
long
base_time
::
get_its_base_time_ms
()
const
{
...
...
@@ -49,14 +53,21 @@ const unsigned long long base_time::get_its_base_time_ms() const {
}
const
unsigned
long
long
base_time
::
get_its_current_time_ms
()
const
{
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
()
-
base_time
::
its_base_time_ms
;
return
(
leap_delay
/
1000
)
+
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
()
-
base_time
::
its_base_time_ms
;
}
const
unsigned
long
long
base_time
::
get_its_current_time_us
()
const
{
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
()
-
base_time
::
its_base_time_ms
*
1000
;
return
leap_delay
+
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
()
-
base_time
::
its_base_time_ms
*
1000
;
}
const
unsigned
long
long
base_time
::
get_its_current_time_mod_ms
()
const
{
return
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
()
-
base_time
::
its_base_time_ms
)
%
65536
;
return
((
leap_delay
/
1000
)
+
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
()
-
base_time
::
its_base_time_ms
)
%
65536
;
}
void
base_time
::
set_leap_delay_us
(
const
unsigned
long
long
p_leap_delay
)
{
leap_delay
=
p_leap_delay
;
}
inline
const
unsigned
long
long
base_time
::
get_leap_delay_us
()
const
{
return
leap_delay
;
}
ccsrc/Protocols/GeoNetworking/geonetworking_layer.cc
View file @
53a1d335
...
...
@@ -152,6 +152,9 @@ void geonetworking_layer::init(const std::string & p_type, const std::string & p
// Register this object for AdapterControlPort
loggers
::
get_instance
().
log
(
"geonetworking_layer::geonetworking_layer: Register %s/%p"
,
p_type
.
c_str
(),
this
);
registration
<
geonetworking_layer
>::
get_instance
().
add_item
(
p_type
,
this
);
// Add 4 leap seconds to convert to TAI (as Feb 2019)
base_time
::
get_instance
().
set_leap_delay_us
(
4
*
1000000
);
// TODO Set it as parameter
}
// End of init_params
void
geonetworking_layer
::
sendMsg
(
const
LibItsGeoNetworking__TestSystem
::
GeoNetworkingReq
&
p
,
params
&
params
)
{
...
...
ttcn/TestCodec/TestCodec_Pki.ttcn
View file @
53a1d335
...
...
@@ -54,6 +54,7 @@ module TestCodec_Pki {
import
from
LibItsPki_Templates
all
;
import
from
LibItsPki_Functions
all
;
import
from
LibItsPki_TestSystem
all
;
import
from
LibItsPki_Pixits
all
;
// TestCodec
import
from
TestCodec_TestAndSystem
all
;
...
...
@@ -182,7 +183,7 @@ module TestCodec_Pki {
// Secure InnerEcRequestSignedForPoP message
v_inner_ec_request_signed_for_pop_msg
:=
encvalue
(
m_etsiTs102941Data_inner_ec_request_signed_for_pop
(
v_inner_ec_request_signed_for_pop
));
if
(
f_build_pki_secured_request_message_signed_with_pop
(
v_private_key
,
valueof
(
m_signerIdentifier_self
),
int2oct
(
0
,
8
),
v_publicKeyCompressed
,
v_compressedMode
,
''
O
,
bit2oct
(
v_inner_ec_request_signed_for_pop_msg
),
v_ieee1609dot2_signed_and_encrypted_data
,
v_aes_sym_key
,
v_encrypted_sym_key
,
v_authentication_vector
,
v_nonce
,
v_request_hash
)
==
false
)
{
if
(
f_build_pki_secured_request_message_signed_with_pop
(
v_private_key
,
valueof
(
m_signerIdentifier_self
),
int2oct
(
0
,
8
),
v_publicKeyCompressed
,
v_compressedMode
,
''
O
,
bit2oct
(
v_inner_ec_request_signed_for_pop_msg
),
PX_EC_ALG_FOR_EC
,
v_ieee1609dot2_signed_and_encrypted_data
,
v_aes_sym_key
,
v_encrypted_sym_key
,
v_authentication_vector
,
v_nonce
,
v_request_hash
)
==
false
)
{
setverdict
(
fail
,
"Failed to secure InnerEcRequest message"
);
stop
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment