Commit cacaaca8 authored by vagrant's avatar vagrant
Browse files

Add PKI support to RSU simumlator

parent 0631e247
......@@ -23,13 +23,13 @@ ItsRSUsSimulator_Pixits.PX_RSU_ID := 8;
# UC7 (CAM only): PX_ETSI_USE_CASE_ID := 7
# UC8 (EVCSN only): PX_ETSI_USE_CASE_ID := 8
# UC9 (CAM only): PX_ETSI_USE_CASE_ID := 9
ItsRSUsSimulator_Pixits.PX_ETSI_USE_CASE_ID := 1
ItsRSUsSimulator_Pixits.PX_ETSI_USE_CASE_ID := 6
# Indicate which zone to simulate
ItsRSUsSimulator_Pixits.PX_ETSI_ZONE_ID := 1
ItsRSUsSimulator_Pics.PICS_GENERATE_BEACON := false
ItsRSUsSimulator_Pics.PICS_GENERATE_CAM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_DENM := true
ItsRSUsSimulator_Pics.PICS_GENERATE_CAM := true
ItsRSUsSimulator_Pics.PICS_GENERATE_DENM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_IVIM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_MAPEM := false
ItsRSUsSimulator_Pics.PICS_GENERATE_SPATEM := false
......@@ -128,7 +128,7 @@ LogEventTypes:= Yes
system.geoNetworkingPort.params := "GN(ll_address=4C5E0C14D2EB,latitude=43551050,longitude=10298730,its_aid=37,secured_mode=1,encrypted_mode=0,certificate=CERT_IUT_A_AT,peer_certificate=CERT_TS_A_AT,sec_db_path=/home/vagrant/tmp/asn1c_cert)/ETH(mac_src=080027500f9b)/PCAP(mac_src=080027500f9b,nic=eth1,filter=and ether proto 0x8947)"
# Config port based on UDP
system.cfPort.params := "CF(ut=cam)/UDP(dst_ip=192.168.0.4)"
system.cfPort.params := "CF(ut=pki)/UDP(dst_ip=192.168.0.4)"
[EXECUTE]
ItsRSUsSimulator_TestCases.TC_RSUSIMU_BV_01
......
......@@ -20,6 +20,11 @@ module ItsRSUsSimulator_Functions {
import from DSRC language "ASN.1:1997" all;
import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
import from IEEE1609dot2 language "ASN.1:1997" all;
import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
import from EtsiTs102941TypesAuthorization language "ASN.1:1997" all;
import from EtsiTs102941TypesAuthorizationValidation language "ASN.1:1997" all;
import from EtsiTs102941MessagesCa language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
// LibItsCommon
......@@ -56,10 +61,22 @@ module ItsRSUsSimulator_Functions {
// LibItsSecurity
import from LibItsSecurity_TypesAndValues all;
import from LibItsSecurity_Functions all;
import from LibItsSecurity_Templates all;
// LibItsHttp
import from LibItsHttp_TypesAndValues all;
import from LibItsHttp_Templates all;
import from LibItsHttp_BinaryTemplates all;
import from LibItsHttp_Functions all;
import from LibItsHttp_TestSystem all;
// LibItsPki
import from LibItsPki_TypesAndValues all;
import from LibItsPki_Templates all;
import from LibItsPki_Functions all;
import from LibItsPki_TestSystem all;
import from LibItsPki_Pics all;
import from LibItsPki_Pixits all;
// AtsRSUsSimulator
import from ItsRSUsSimulator_TypesAndValues all;
......@@ -1057,7 +1074,8 @@ module ItsRSUsSimulator_Functions {
repeat;
}
[vc_pki == true] cfPort.receive(UtPkiTrigger:?) -> value v_utPkiTrigger {
cfPort.send(UtPkiResults: { utPkiInitializeResult := true } );
cfPort.send(UtPkiResults: { utPkiTriggerResult := true } );
f_trigger_enrolment_request_await_response();
repeat;
}
[] cfPort.receive {
......@@ -1067,4 +1085,79 @@ module ItsRSUsSimulator_Functions {
}
} // End of 'altstep' statement
function f_trigger_enrolment_request_await_response() runs on ItsRSUsSimulator {
// Local variables
var Oct32 v_private_key;
var Oct32 v_compressed_public_key;
var integer v_compressed_mode;
var Oct32 v_request_hash;
var Oct16 v_encrypted_sym_key;
var Oct16 v_aes_sym_key;
var Oct16 v_authentication_vector;
var Oct12 v_nonce;
var octetstring v_salt;
var Ieee1609Dot2Data v_ieee1609dot2_signed_and_encrypted_data;
var HeaderLines v_headers;
var HttpMessage v_response;
var EtsiTs102941Data v_etsi_ts_102941_data;
timer v_t := 5.0;
log(">>> f_trigger_enrolment_request_await_response");
f_http_build_inner_ec_request(v_private_key, v_compressed_public_key, v_compressed_mode, v_aes_sym_key, v_encrypted_sym_key, v_authentication_vector, v_nonce, v_salt, v_ieee1609dot2_signed_and_encrypted_data, v_request_hash);
f_init_default_headers_list(-, "inner_ec_request", v_headers);
httpPort.send(
m_http_request(
m_http_request_post(
PICS_HTTP_POST_URI,
v_headers,
m_http_message_body_binary(
m_binary_body_ieee1609dot2_data(
v_ieee1609dot2_signed_and_encrypted_data
)))));
// Wait for the resposne
v_t.start;
alt {
[] httpPort.receive(
mw_http_response(
mw_http_response_ok(
mw_http_message_body_binary(
mw_binary_body_ieee1609dot2_data(
mw_enrolmentResponseMessage(
mw_encryptedData(
-,
mw_SymmetricCiphertext_aes128ccm
))))))) -> value v_response {
v_t.stop;
log("f_trigger_enrolment_request_await_response: receive ", v_response);
if (f_verify_pki_message(v_private_key, v_aes_sym_key, v_authentication_vector, vc_eaWholeHash, vc_eaCertificate, v_response.response.body.binary_body.ieee1609dot2_data, false, v_etsi_ts_102941_data) == false) {
log("f_trigger_enrolment_request_await_response: Failed to verify PKI message ***");
} else {
log("f_trigger_enrolment_request_await_response: Receive ", v_etsi_ts_102941_data, " ***");
// Verify the received EC certificate
log("f_trigger_enrolment_request_await_response: match ", match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_request_hash, 0, 16), mw_etsiTs103097Certificate(-, mw_toBeSignedCertificate_ec, -)))), " ***"); // TODO In TITAN, this is the only way to get the unmatching in log
if (match(v_etsi_ts_102941_data.content, mw_enrolmentResponse(mw_innerEcResponse_ok(substr(v_request_hash, 0, 16), mw_etsiTs103097Certificate(-, mw_toBeSignedCertificate_ec, -))))) {
var InnerEcResponse v_inner_ec_response := v_etsi_ts_102941_data.content.enrolmentResponse;
if (f_verify_ec_certificate(v_etsi_ts_102941_data.content.enrolmentResponse.certificate, vc_eaCertificate, v_compressed_public_key, v_compressed_mode)) {
log("f_trigger_enrolment_request_await_response: Well-secured EA certificate received ***");
log("p_inner_ec_response= ", v_inner_ec_response);
vc_reenrolment := true;
// Store the new certificate
vc_ec_certificates[vc_ec_certificates_counter] := v_inner_ec_response.certificate;
vc_ec_certificates_counter := vc_ec_certificates_counter + 1;
} else {
log("f_trigger_enrolment_request_await_response: Cannot verify EC certificate signature ***");
}
} else {
log("f_trigger_enrolment_request_await_response: Unexpected message received ***");
}
}
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
}
} // End of 'alt' statement
}
} // End of module ItsRSUsSimulator_Functions
......@@ -3,6 +3,8 @@ module ItsRSUsSimulator_TestSystem {
// LibIts
import from ITS_Container language "ASN.1:1997" all;
import from DSRC language "ASN.1:1997" all;
import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
import from IEEE1609dot2 language "ASN.1:1997" all;
// LibItsGeoNetworking
import from LibItsGeoNetworking_TestSystem all;
......@@ -21,7 +23,7 @@ module ItsRSUsSimulator_TestSystem {
import from LibItsHttp_TypesAndValues all;
// LibItsPki
import from LibItsHttp_TestSystem all;
import from LibItsPki_TestSystem all;
import from LibItsPki_TypesAndValues all;
// AtsRSUsSimulator
......@@ -32,8 +34,7 @@ module ItsRSUsSimulator_TestSystem {
/**
* @desc Test component for ITS Network and Transport layer
*/
type component ItsRSUsSimulator extends ItsGeoNetworking {
port HttpPort httpPort;
type component ItsRSUsSimulator extends ItsGeoNetworking, ItsPkiHttp {
/**
* @desc RSUsimulator configuration port
*/
......@@ -115,15 +116,19 @@ module ItsRSUsSimulator_TestSystem {
timer tc_spatem := PICS_SPATEM_FREQUENCY;
timer tc_ivim := PICS_IVIM_FREQUENCY;
//timer tc_evcsn := PICS_EVCSN_FREQUENCY;
var boolean vc_reenrolment := false;
var integer vc_ec_certificates_counter := 0;
var SequenceOfCertificate vc_ec_certificates;
var integer vc_at_certificates_counter := 0;
var SequenceOfCertificate vc_at_certificates;
} // End of component ItsRSUsSimulator
/**
* @desc Test system component for ITS Network and Transport layer
*/
type component ItsRSUsSimulatorSystem extends ItsGeoNetworkingSystem {
port ConfigRsuSimulatorPort cfPort;
port HttpPort httPort;
type component ItsRSUsSimulatorSystem extends ItsGeoNetworkingSystem, HttpTestAdapter {
port ConfigRsuSimulatorPort cfPort;
}
type record of record {
......
Subproject commit 447a5fff71873728964cd73a7b44b4a2185482df
Subproject commit c04d5a663f14b5094fde2c0788b530650cf6440b
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