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
086b9e9c
Commit
086b9e9c
authored
Oct 08, 2018
by
garciay
Browse files
STF545: Execute first EA tests
parent
a899b7f9
Changes
16
Show whitespace changes
Inline
Side-by-side
ccsrc/Ports/LibIts_ports/GN_ports/GeoNetworkingPort.cc
View file @
086b9e9c
ccsrc/Ports/LibIts_ports/GN_ports/GeoNetworkingPort.hh
View file @
086b9e9c
...
...
@@ -7,8 +7,7 @@
// You may modify this file. Add your attributes and prototypes of your
// member functions here.
#ifndef GeoNetworkingPort_HH
#define GeoNetworkingPort_HH
#pragma once
#include
"LibItsGeoNetworking_TestSystem.hh"
...
...
@@ -49,5 +48,3 @@ namespace LibItsGeoNetworking__TestSystem {
};
}
/* end of namespace */
#endif
ccsrc/Ports/LibIts_ports/Pki_ports/PkiPort.cc
View file @
086b9e9c
...
...
@@ -8,77 +8,113 @@
// add your member functions here.
#include
"PkiPort.hh"
#include
"pki_layer_factory.hh"
#include
"loggers.hh"
namespace
LibItsPki__TestSystem
{
PkiPort
::
PkiPort
(
const
char
*
par_port_name
)
:
PkiPort_BASE
(
par_port_name
)
{
PkiPort
::
PkiPort
(
const
char
*
par_port_name
)
:
PkiPort_BASE
(
par_port_name
)
,
_cfg_params
(),
_layer_params
(),
_layer
(
nullptr
),
_time_key
(
"PkiPort::outgoing_send"
)
{
// Nothing to do
}
PkiPort
::~
PkiPort
()
{
}
}
PkiPort
::~
PkiPort
()
{
loggers
::
get_instance
().
log
(
">>> PkiPort::~PkiPort"
);
void
PkiPort
::
set_parameter
(
const
char
*
/*parameter_name*/
,
const
char
*
/*parameter_value*/
)
{
if
(
_layer
!=
nullptr
)
{
delete
_layer
;
}
}
}
void
PkiPort
::
set_parameter
(
const
char
*
parameter_name
,
const
char
*
parameter_value
)
{
loggers
::
get_instance
().
log
(
"PkiPort::set_parameter: %s=%s"
,
parameter_name
,
parameter_value
);
_cfg_params
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
std
::
string
(
parameter_name
),
std
::
string
(
parameter_value
)));
}
/*void PkiPort::Handle_Fd_Event(int fd, boolean is_readable,
/*void PkiPort::Handle_Fd_Event(int fd, boolean is_readable,
boolean is_writable, boolean is_error) {}*/
void
PkiPort
::
Handle_Fd_Event_Error
(
int
/*fd*/
)
{
void
PkiPort
::
Handle_Fd_Event_Error
(
int
/*fd*/
)
{
}
void
PkiPort
::
Handle_Fd_Event_Writable
(
int
/*fd*/
)
{
}
}
void
PkiPort
::
Handle_Fd_Event_Writable
(
int
/*fd*/
)
{
void
PkiPort
::
Handle_Fd_Event_Readable
(
int
/*fd*/
)
{
}
}
void
PkiPort
::
Handle_Fd_Event_Readable
(
int
/*fd*/
)
{
/*void PkiPort::Handle_Timeout(double time_since_last_call) {}*/
}
void
PkiPort
::
user_map
(
const
char
*
/*system_port*/
)
{
/*void PkiPort::Handle_Timeout(double time_since_last_call) {}*/
void
PkiPort
::
user_map
(
const
char
*
system_port
)
{
loggers
::
get_instance
().
log
(
">>> PkiPort::user_map: %s"
,
system_port
);
// Build layer stack
params
::
iterator
it
=
_cfg_params
.
find
(
std
::
string
(
"params"
));
if
(
it
!=
_cfg_params
.
end
())
{
loggers
::
get_instance
().
log
(
"PkiPort::user_map: %s"
,
it
->
second
.
c_str
());
// Setup parameters
params
::
convert
(
_layer_params
,
it
->
second
);
// TODO This _layer_params seems to be useless
// Create layer
_layer
=
layer_stack_builder
::
get_instance
()
->
create_layer_stack
(
it
->
second
.
c_str
());
if
(
static_cast
<
pki_layer
*>
(
_layer
)
==
nullptr
)
{
loggers
::
get_instance
().
error
(
"PkiPort::user_map: Invalid stack configuration: %s"
,
it
->
second
.
c_str
());
}
static_cast
<
pki_layer
*>
(
_layer
)
->
add_upper_port
(
this
);
}
}
else
{
loggers
::
get_instance
().
error
(
"PkiPort::user_map: No layers defined in configuration file"
);
}
}
void
PkiPort
::
user_unmap
(
const
char
*
/*system_port*/
)
{
void
PkiPort
::
user_unmap
(
const
char
*
system_port
)
{
loggers
::
get_instance
().
log
(
">>> PkiPort::user_unmap: %s"
,
system_port
);
}
// Reset layers
if
(
_layer
!=
nullptr
)
{
delete
_layer
;
_layer
=
nullptr
;
}
}
void
PkiPort
::
user_start
()
{
void
PkiPort
::
user_start
()
{
loggers
::
get_instance
().
log
(
">>> PkiPort::user_start"
);
}
}
void
PkiPort
::
user_stop
()
{
void
PkiPort
::
user_stop
()
{
loggers
::
get_instance
().
log
(
">>> PkiPort::user_stop"
);
}
}
void
PkiPort
::
outgoing_send
(
const
EtsiTs102941TypesEnrolment
::
InnerEcRequest
&
send_par
)
{
void
PkiPort
::
outgoing_send
(
const
EtsiTs102941TypesEnrolment
::
InnerEcRequest
&
send_par
)
{
loggers
::
get_instance
().
log_msg
(
">>> PkiPort::outgoing_send: payload="
,
send_par
);
}
float
duration
;
loggers
::
get_instance
().
set_start_time
(
_time_key
);
params
params
;
static_cast
<
pki_layer
*>
(
_layer
)
->
sendMsg
(
send_par
,
params
);
loggers
::
get_instance
().
set_stop_time
(
_time_key
,
duration
);
}
void
PkiPort
::
outgoing_send
(
const
EtsiTs102941TypesEnrolment
::
InnerEcResponse
&
send_par
)
{
void
PkiPort
::
outgoing_send
(
const
EtsiTs102941TypesEnrolment
::
InnerEcResponse
&
send_par
)
{
}
}
void
PkiPort
::
receiveMsg
(
const
EtsiTs102941TypesEnrolment
::
InnerEcRequest
&
p_ind
,
const
params
&
p_params
)
{
void
PkiPort
::
receiveMsg
(
const
EtsiTs102941TypesEnrolment
::
InnerEcRequest
&
p_ind
,
const
params
&
p_params
)
{
loggers
::
get_instance
().
log_msg
(
">>> PkiPort::receive_msg: "
,
p_ind
);
// Sanity check
if
(
!
p_ind
.
is_bound
())
{
...
...
@@ -86,9 +122,9 @@ void PkiPort::receiveMsg (const EtsiTs102941TypesEnrolment::InnerEcRequest& p_in
}
incoming_message
(
p_ind
);
}
}
void
PkiPort
::
receiveMsg
(
const
EtsiTs102941TypesEnrolment
::
InnerEcResponse
&
p_ind
,
const
params
&
p_params
)
{
void
PkiPort
::
receiveMsg
(
const
EtsiTs102941TypesEnrolment
::
InnerEcResponse
&
p_ind
,
const
params
&
p_params
)
{
loggers
::
get_instance
().
log_msg
(
">>> PkiPort::receive_msg: "
,
p_ind
);
// Sanity check
if
(
!
p_ind
.
is_bound
())
{
...
...
@@ -96,7 +132,7 @@ void PkiPort::receiveMsg (const EtsiTs102941TypesEnrolment::InnerEcResponse& p_i
}
incoming_message
(
p_ind
);
}
}
}
/* end of namespace */
ccsrc/Ports/LibIts_ports/Pki_ports/PkiPort.hh
View file @
086b9e9c
...
...
@@ -7,14 +7,21 @@
// You may modify this file. Add your attributes and prototypes of your
// member functions here.
#ifndef PkiPort_HH
#define PkiPort_HH
#pragma once
#include
"LibItsPki_TestSystem.hh"
#include
"layer.hh"
#include
"params.hh"
namespace
LibItsPki__TestSystem
{
class
PkiPort
:
public
PkiPort_BASE
{
params
_cfg_params
;
params
_layer_params
;
layer
*
_layer
;
std
::
string
_time_key
;
public:
PkiPort
(
const
char
*
par_port_name
=
NULL
);
~
PkiPort
();
...
...
@@ -42,5 +49,3 @@ protected:
};
}
/* end of namespace */
#endif
ccsrc/Protocols/Pki/pki_layer.cc
View file @
086b9e9c
...
...
@@ -5,10 +5,12 @@
#include
"converter.hh"
#include
"security_services.hh"
using
namespace
std
;
// Required for isnan()
#include
"LibItsPki_TestSystem.hh"
pki_layer
::
pki_layer
(
const
std
::
string
&
p_type
,
const
std
::
string
&
param
)
:
t_layer
<
LibItsPki__TestSystem
::
Http
Port
>
(
p_type
),
_params
(),
_etsi_ts102941_types_enrolment_inner_request
(),
_etsi_ts102941_types_enrolment_inner_re
quest
(),
_codec
()
pki_layer
::
pki_layer
(
const
std
::
string
&
p_type
,
const
std
::
string
&
param
)
:
t_layer
<
LibItsPki__TestSystem
::
Pki
Port
>
(
p_type
),
_params
(),
_etsi_ts102941_types_enrolment_inner_request
(),
_etsi_ts102941_types_enrolment_inner_re
sponse
(),
_codec
()
{
loggers
::
get_instance
().
log
(
">>> pki_layer::pki_layer: %s, %s"
,
to_string
().
c_str
(),
param
.
c_str
());
...
...
@@ -23,31 +25,32 @@ pki_layer::pki_layer(const std::string & p_type, const std::string & param) : t_
if
(
it
==
_params
.
cend
())
{
_params
[
params
::
certificate
]
=
"CERT_IUT_A_EA"
;
}
_params
[
params
::
its_aid
]
=
"
0
"
;
_params
[
params
::
its_aid
]
=
"
2468
"
;
_params
[
params
::
payload_type
]
=
""
;
_params
[
params
::
signature
]
=
"NISTP-256"
;
_params
[
params
::
encrypted_mode
]
=
"1"
;
}
void
pki_layer
::
sendMsg
(
const
EtsiTs102941TypesEnrolment
::
InnerEcRequest
&
p_inner_ec_request
,
params
&
p_param
)
{
loggers
::
get_instance
().
log_msg
(
">>> pki_layer::sendMsg: "
,
p_
pki_message
);
loggers
::
get_instance
().
log_msg
(
">>> pki_layer::sendMsg: "
,
p_
inner_ec_request
);
OCTETSTRING
data
;
_etsi_ts102941_types_enrolment_inner_request
.
encode
(
p_
pki_message
,
data
);
_etsi_ts102941_types_enrolment_inner_request
.
encode
(
p_
inner_ec_request
,
data
);
// Add security
OCTETSTRING
secured_data
;
if
(
s
ecured
_payload
(
data
,
secured_data
)
==
0
)
{
if
(
s
ign_and_encrypt
_payload
(
data
,
secured_data
)
==
0
)
{
send_data
(
data
,
_params
);
}
}
void
pki_layer
::
sendMsg
(
const
EtsiTs102941TypesEnrolment
::
InnerEcResponse
&
p_inner_ec_re
quest
,
params
&
p_param
)
{
loggers
::
get_instance
().
log_msg
(
">>> pki_layer::sendMsg: "
,
p_
pki_messag
e
);
void
pki_layer
::
sendMsg
(
const
EtsiTs102941TypesEnrolment
::
InnerEcResponse
&
p_inner_ec_re
sponse
,
params
&
p_param
)
{
loggers
::
get_instance
().
log_msg
(
">>> pki_layer::sendMsg: "
,
p_
inner_ec_respons
e
);
OCTETSTRING
data
;
_etsi_ts102941_types_enrolment_inner_response
.
encode
(
p_
pki_messag
e
,
data
);
_etsi_ts102941_types_enrolment_inner_response
.
encode
(
p_
inner_ec_respons
e
,
data
);
// Add security
OCTETSTRING
secured_data
;
if
(
s
ecured
_payload
(
data
,
secured_data
)
==
0
)
{
if
(
s
ign_and_encrypt
_payload
(
data
,
secured_data
)
==
0
)
{
send_data
(
data
,
_params
);
}
}
...
...
@@ -62,44 +65,36 @@ void pki_layer::receive_data(OCTETSTRING& data, params& params)
{
loggers
::
get_instance
().
log_msg
(
">>> pki_layer::receive_data: "
,
data
);
// Decode HTTP message
LibItsPki__TypesAndValues
::
HttpMessage
pki_message
;
if
(
_codec
.
decode
(
data
,
pki_message
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"pki_layer::receive_data: Failed to decode data"
);
return
;
}
//
//
Decode HTTP message
//
LibItsPki__TypesAndValues::HttpMessage pki_message;
//
if (_codec.decode(data, pki_message) == -1) {
//
loggers::get_instance().warning("pki_layer::receive_data: Failed to decode data");
//
return;
//
}
// Pass it to the ports
to_all_upper_ports
(
pki_message
,
params
);
//
//
Pass it to the ports
//
to_all_upper_ports(pki_message, params);
}
int
pki_layer
::
sign_and_encrypt_payload
(
const
OCTETSTRING
&
p_data
,
OCTETSTRING
&
p_secured_data
)
{
loggers
::
get_instance
().
log_msg
(
">>> pki_layer::sign_and_encrypt_payload: "
,
p_data
);
if
(
p_binary_body
.
ischosen
(
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
::
ALT_innerEcRequest
))
{
params
p
;
// TODO To be refined
// 1. Signed the data
OCTETSTRING
signed_data
;
if
(
security_services
::
get_instance
().
sign_payload
(
p_data
,
signed_data
,
p
)
==
-
1
)
{
if
(
security_services
::
get_instance
().
sign_payload
(
p_data
,
signed_data
,
_params
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: Failed to sign data"
);
return
-
1
;
}
loggers
::
get_instance
().
log_msg
(
"pki_layer::sign_and_encrypt_payload: signed_data="
,
signed_data
);
//
3
. Encrypt the signed packet
if
(
security_services
::
get_instance
().
encrypt_gn_payload
(
signed_data
,
p_secured_data
,
p
)
==
-
1
)
{
//
2
. Encrypt the signed packet
if
(
security_services
::
get_instance
().
encrypt_gn_payload
(
signed_data
,
p_secured_data
,
_params
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: Failed to encrypt data"
);
return
-
1
;
}
loggers
::
get_instance
().
log_msg
(
"<<< http_etsi_ieee1609dot2_codec::encode: "
,
p_secured_data
);
return
0
;
}
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: No _codec found"
);
return
-
1
;
}
pki_layer_factory
pki_layer_factory
::
_f
;
ccsrc/Protocols/Pki/pki_layer.hh
View file @
086b9e9c
...
...
@@ -31,7 +31,7 @@ class OCTETSTRING; //! Forward declaration of TITAN class
class
pki_layer
:
public
t_layer
<
LibItsPki__TestSystem
::
PkiPort
>
{
params
_params
;
etsi_ts102941_types_enrolment_inner_request
_etsi_ts102941_types_enrolment_inner_request
;
etsi_ts102941_types_enrolment_inner_response
_etsi_ts102941_types_enrolment_inner_re
quest
;
etsi_ts102941_types_enrolment_inner_response
_etsi_ts102941_types_enrolment_inner_re
sponse
;
etsi_ts103097_data_codec
_codec
;
public:
//! \publicsection
...
...
@@ -41,7 +41,7 @@ public: //! \publicsection
* \param[in] p_type \todo
* \param[in] p_param \todo
*/
pki_layer
()
:
t_layer
(),
_params
(),
_etsi_ts102941_types_enrolment_inner_request
(),
_etsi_ts102941_types_enrolment_inner_re
quest
(),
_codec
()
{
};
pki_layer
()
:
t_layer
(),
_params
(),
_etsi_ts102941_types_enrolment_inner_request
(),
_etsi_ts102941_types_enrolment_inner_re
sponse
(),
_codec
()
{
};
/*!
* \brief Specialised constructor
* Create a new instance of the pki_layer class
...
...
ccsrc/Protocols/Pki/pki_layer_factory.hh
View file @
086b9e9c
...
...
@@ -28,7 +28,7 @@ public: //! \publicsection
*/
pki_layer_factory
()
{
// Register factory
layer_stack_builder
::
register_layer_factory
(
"
HTTP
"
,
this
);
layer_stack_builder
::
register_layer_factory
(
"
PKI
"
,
this
);
};
/*!
* \fn layer* create_layer(const std::string & type, const std::string & param);
...
...
ccsrc/Protocols/Security/certificates_loader.cc
View file @
086b9e9c
...
...
@@ -139,7 +139,7 @@ int certificates_loader::build_certificates_cache(std::set<std::experimental::fi
loggers
::
get_instance
().
log
(
"certificates_loader::build_certificates_cache: Caching certificate '%s'"
,
it
->
string
().
c_str
());
std
::
ifstream
is
(
it
->
string
(),
ios
::
in
|
ios
::
binary
);
if
(
!
is
.
is_open
())
{
loggers
::
get_instance
().
warning
(
"certificates_loader::build_certificates_cache:
f
ailed to open certificate file"
);
loggers
::
get_instance
().
warning
(
"certificates_loader::build_certificates_cache:
F
ailed to open certificate file"
);
return
-
1
;
}
OCTETSTRING
certificate
=
int2oct
(
0
,
std
::
experimental
::
filesystem
::
file_size
(
*
it
));
...
...
ccsrc/Protocols/Security/http_etsi_ieee1609dot2_codec.cc
View file @
086b9e9c
#include
"EtsiTs103097Module.hh"
#include
"http_etsi_ieee1609dot2_codec.hh"
#include
"etsi_ts102941_types_enrolment_inner_request.hh"
#include
"etsi_ts102941_types_enrolment_inner_response.hh"
#include
"etsi_ts103097_data_codec.hh"
#include
"http_etsi_ieee1609dot2_codec_factory.hh"
#include
"LibItsHttp_MessageBodyTypes.hh"
...
...
@@ -20,43 +12,18 @@ int http_etsi_ieee1609dot2_codec::encode (const LibItsHttp__BinaryMessageBodyTyp
{
loggers
::
get_instance
().
log_msg
(
">>> http_etsi_ieee1609dot2_codec::encode: "
,
p_binary_body
);
etsi_ts103097_data_codec
codec
;
if
(
p_binary_body
.
ischosen
(
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
::
ALT_innerEcRequest
))
{
params
p
;
// TODO To be refined
p
[
params
::
hash
]
=
"SHA-256"
;
p
[
params
::
its_aid
]
=
"0"
;
p
[
params
::
payload_type
]
=
""
;
p
[
params
::
signature
]
=
"NISTP-256"
;
p
[
params
::
certificate
]
=
"CERT_TS_A_AT"
;
p
[
params
::
encrypted_mode
]
=
"1"
;
p
[
params
::
cypher
]
=
"NISTP-256"
;
p
[
params
::
peer_certificate
]
=
"CERT_IUT_A_AT"
;
// 1. Encode the InnerEcRequest
OCTETSTRING
os
;
etsi_ts102941_types_enrolment_inner_request
c
;
if
(
c
.
encode
(
p_binary_body
.
innerEcRequest
(),
os
)
==
-
1
)
{
if
(
p_binary_body
.
ischosen
(
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
::
ALT_ieee1609dot2__data
))
{
// Encode the Ieee1609Dot2Data
if
(
_codec
.
encode
(
p_binary_body
.
ieee1609dot2__data
(),
p_data
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: Failed to encode InnerEcRequest"
);
return
-
1
;
}
// 2. Signed the packet
OCTETSTRING
signed_os
;
if
(
security_services
::
get_instance
().
sign_payload
(
os
,
signed_os
,
p
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: Failed to sign InnerEcRequest"
);
return
-
1
;
}
// 3. Encrypt the signed packet
if
(
security_services
::
get_instance
().
encrypt_gn_payload
(
signed_os
,
p_data
,
p
)
==
-
1
)
{
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: Failed to encrypt InnerEcRequest"
);
return
-
1
;
}
loggers
::
get_instance
().
log_msg
(
"<<< http_etsi_ieee1609dot2_codec::encode: "
,
p_data
);
return
0
;
}
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: No codec found"
);
loggers
::
get_instance
().
warning
(
"http_etsi_ieee1609dot2_codec::encode: No codec found"
);
return
-
1
;
}
...
...
@@ -64,7 +31,6 @@ int http_etsi_ieee1609dot2_codec::decode (const OCTETSTRING& p_data, LibItsHttp_
{
loggers
::
get_instance
().
log_msg
(
">>> http_etsi_ieee1609dot2_codec::decode: "
,
p_data
);
etsi_ts103097_data_codec
codec
;
/*if (p_binary_body.ischosen(LibItsHttp__BinaryMessageBodyTypes::BinaryBody::ALT_innerEcResponse)) {
return codec.decode(p_data, p_binary_body.innerEcResponse(), p_data);
...
...
ccsrc/Protocols/Security/http_etsi_ieee1609dot2_codec.hh
View file @
086b9e9c
#pragma once
#include
"codec.hh"
//#include "CodecOer.hh"
#include
"
etsi_ts103097_data_
codec.hh"
#include
"params.hh"
namespace
LibItsHttp__BinaryMessageBodyTypes
{
...
...
@@ -10,8 +10,9 @@ namespace LibItsHttp__BinaryMessageBodyTypes {
class
http_etsi_ieee1609dot2_codec
:
public
codec
<
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
,
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
>
{
etsi_ts103097_data_codec
_codec
;
public:
explicit
http_etsi_ieee1609dot2_codec
()
:
codec
<
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
,
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
>
()
{
};
explicit
http_etsi_ieee1609dot2_codec
()
:
codec
<
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
,
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
>
()
,
_codec
()
{
};
virtual
~
http_etsi_ieee1609dot2_codec
()
{
};
virtual
int
encode
(
const
LibItsHttp__BinaryMessageBodyTypes
::
BinaryBody
&
p_binary_body
,
OCTETSTRING
&
p_data
);
...
...
ccsrc/Protocols/Security/security_services.cc
View file @
086b9e9c
...
...
@@ -632,6 +632,10 @@ int security_services::encrypt_gn_payload(const OCTETSTRING& p_unsecured_gn_payl
int
security_services
::
sign_tbs_data
(
const
IEEE1609dot2
::
ToBeSignedData
&
p_tbs_data
,
const
IEEE1609dot2BaseTypes
::
HashAlgorithm
&
p_hashAlgorithm
,
IEEE1609dot2BaseTypes
::
Signature
&
p_signature
,
params
&
p_params
)
{
loggers
::
get_instance
().
log_msg
(
">>> security_services::sign_tbs_data: "
,
p_tbs_data
);
// Get certificate
loggers
::
get_instance
().
log
(
"security_services::sign_tbs_data: encoded params::certificate = '%s'"
,
p_params
[
params
::
certificate
].
c_str
());
// TODO Remove signature paramter, use certificate only, check if it is okay for GN with device_mode set and not setxs _security_db.get()->get_certificate(p_params[params::certificate]);
// Encode the ToBeSignedData
etsi_ts103097_tobesigned_data_codec
tbs_data_codec
;
OCTETSTRING
os
;
...
...
etc/AtsPki/AtsPki.cfg
View file @
086b9e9c
...
...
@@ -101,15 +101,18 @@ LogEventTypes:= Yes
# save_mode : 1 to save sent packet, 0 otherwise
# Single GeoNetworking component port
system.camPort.params := "CAM(next_header=btpB,header_type=tsb,header_sub_type=sh)/BTP/GN(ll_address=4C5E0C14D2EA,latitude=43551050,longitude=10298730,distanceA=1500,distanceB=1500,angle=0,device_mode=1,beaconing=!)/ETH(mac_src=080027500f9b)/PCAP(mac_src=080027500f9b,nic=eth2,filter=and ether proto 0x8947)"
system.httpPort.params := "HTTP(codecs=http_its:http_etsi_ieee1609dot2_codec)/TCP(debug=1,server=ptsv2.com,use_ssl=0)"
#system.camPort.params := "CAM(next_header=btpB,header_type=tsb,header_sub_type=sh)/BTP/GN(ll_address=4C5E0C14D2EA,latitude=43551050,longitude=10298730,distanceA=1500,distanceB=1500,angle=0,device_mode=1,beaconing=!)/ETH(mac_src=080027500f9b)/PCAP(mac_src=080027500f9b,nic=eth2,filter=and ether proto 0x8947)"
#system.httpPort.params := "HTTP(codecs=http_its:http_etsi_ieee1609dot2_codec)/TCP(debug=1,server=ptsv2.com,use_ssl=0)"
system.httpPort.params := "HTTP(codecs=http_its:http_etsi_ieee1609dot2_codec)/TCP(server=ptsv2.com)"
system.pkiPort.params := "PKI(certificate=CERT_TS_A_EA,peer_certificate=CERT_IUT_A_EA)/HTTP/TCP(server=ptsv2.com)"
# GeoNetworking UpperTester port based on UDP
system.utPort.params := "UT_CAM/UDP(dst_ip=172.23.0.1,dst_port=8000)"
[EXECUTE]
ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_01
#ItsPki_TestCases.TC_SEC_PKI_ITSS_ENR_BV_01
#ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_01
ItsPki_TestCases.TC_SEC_PKI_SND_EA_BV_02
[MAIN_CONTROLLER]
# The options herein control the behavior of MC.
...
...
scripts/update_its_project.bash
View file @
086b9e9c
...
...
@@ -235,6 +235,10 @@ do
cp
${
CC_SRC_PATH
}
/EncDec/LibItsPki_Encdec.cc
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/src
cp
${
CC_SRC_PATH
}
/EncDec/LibItsSecurity_Encdec.cc
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/src
cp
${
CC_SRC_PATH
}
/Externals/LibItsSecurity_externals.cc
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/src
cp
${
CC_SRC_PATH
}
/Ports/LibIts_ports/Pki_ports/
*
.cc
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/src
cp
${
CC_SRC_PATH
}
/Ports/LibIts_ports/Pki_ports/
*
.hh
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/include
cp
${
CC_SRC_PATH
}
/Ports/LibIts_ports/Pki_ports/
*
.partC
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/src
cp
${
CC_SRC_PATH
}
/Ports/LibIts_ports/Pki_ports/
*
.partH
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/include
elif
[
"
$i
"
==
"MapemSpatem"
]
then
cp
${
CC_SRC_PATH
}
/EncDec/LibItsMapemSpatem_Encdec.cc
${
TTCN_3_DST_PATH
}
/LibIts/
$i
/src
...
...
ttcn/AtsPki/ItsPki_Functions.ttcn
View file @
086b9e9c
...
...
@@ -42,10 +42,10 @@ module ItsPki_Functions {
* @param p_certificateId The certificate identifier the TA shall use in case of secured IUT
*/
function
f_cfUp
(
in
charstring
p_certificateId
:=
PX_
CERT_
FOR_TS
in
charstring
p_certificateId
:=
"
CERT_
TS_A_EA"
// TODO Use a constant
)
runs
on
ItsPki
/* TITAN TODO: system ItsPkiSystem */
{
map
(
self
:
pkiPort
,
system
:
pkiPort
pPort
);
map
(
self
:
pkiPort
,
system
:
pkiPort
);
f_connect4SelfOrClientSync
();
if
(
not
f_loadCertificates
(
PX_IUT_SEC_CONFIG_NAME
)
)
{
...
...
@@ -53,6 +53,8 @@ module ItsPki_Functions {
stop
;
}
f_prepareCertificates
(
p_certificateId
,
vc_aaCertificate
,
vc_atCertificate
);
f_readCertificate
(
p_certificateId
,
vc_eaCertificate
);
}
// End of function f_cfUp
/**
...
...
@@ -60,7 +62,7 @@ module ItsPki_Functions {
* @param p_certificateId The certificate identifier the TA shall use in case of secured IUT
*/
function
f_cfHttpUp
(
in
charstring
p_certificateId
:=
PX_
CERT_
FOR_TS
in
charstring
p_certificateId
:=
"
CERT_
TS_A_EA"
// TODO Use a constant
)
runs
on
ItsPkiHttp
/* TITAN TODO: system ItsPkiHttpSystem */
{
map
(
self
:
httpPort
,
system
:
httpPort
);
...
...
@@ -72,8 +74,7 @@ module ItsPki_Functions {
}
f_prepareCertificates
(
p_certificateId
,
vc_aaCertificate
,
vc_atCertificate
);
f_readCertificate
(
p_certificateId
,
vc_eaCertificate
);
}
// End of function f_cfHttpUp
/**
...
...
ttcn/AtsPki/ItsPki_TestCases.ttcn
View file @
086b9e9c
...
...
@@ -198,33 +198,70 @@ module ItsPki_TestCases {
*/
testcase
TC_SEC_PKI_SND_EA_BV_01
()
runs
on
ItsPki
system
ItsPkiSystem
{
// Local variables
var
EtsiTs103097Certificate
v_certificate
;
var
Oct32
v_private_key
;
var
Oct32
v_publicKeyX
;
var
Oct32
v_publicKeyY
;
var
Oct32
v_publicKeyCompressed
;
var
integer
v_compressedMode
;
var
template
(
value
)
EccP256CurvePoint
v_eccP256_curve_point
;
var
template
(
value
)
InnerEcRequest
v_inner_ec_request
;
// Test control
// Test component configuration
vc_hashedId8ToBeUsed
:=
"CERT_TS_B_AT"
;
ItsPki_Functions
.
f_cfUp
();
// Test adapter configuration
// Preamble
f_selfOrClientSyncAndVerdictPreamble
(
c_prDone
,
e_success
);
// Test Body
pkiPort
.
send
(
m_innerEcRequest
(
"TODO"
,
// Preamble
// f_generate_innerEcRequestSignedForPop(v_inner_ec_request)
// Generate keys for the certificate to be requested
if
(
f_generate_key_pair_nistp256
(
v_private_key
,
v_publicKeyX
,
v_publicKeyY
,
v_publicKeyCompressed
,
v_compressedMode
)
==
false
)
{
f_selfOrClientSyncAndVerdictPreamble
(
c_prDone
,
e_error
);
stop
;
}
log
(
"v_private_key = "
,
v_private_key
);
log
(
"v_public_key X= "
,
v_publicKeyX
);
log
(
"v_public_key Y= "
,
v_publicKeyY
);
log
(
"v_public_key compressed= "
,
v_publicKeyCompressed
,
v_compressedMode
);
if
(
v_compressedMode
==
0
)
{
v_eccP256_curve_point
:=
m_eccP256CurvePoint_compressed_y_0
(
v_publicKeyCompressed
);
}
else
{
v_eccP256_curve_point
:=
m_eccP256CurvePoint_compressed_y_1
(
v_publicKeyCompressed
);
}
// Build the Proof of Possession InnerEcRequestSignedForPop
v_inner_ec_request
:=
m_innerEcRequest
(
"CanonicalItsId"
,
m_publicKeys
(
v_certificate
.
toBeSigned