Newer
Older
YannGarcia
committed
v_itss.start(f_TC_SECPKI_ITSS_CTL_05_BV_itss());
v_dc.start(f_TC_SECPKI_ITSS_CTL_05_BV_pki());
YannGarcia
committed
// Synchronization
f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
YannGarcia
committed
// Cleanup
f_cfMtcDown04(v_itss, v_dc);
YannGarcia
committed
} // End of testcase TC_SECPKI_ITSS_CTL_05_BV
YannGarcia
committed
group f_TC_SECPKI_ITSS_CTL_05_BV {
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTL_05_BV_itss() runs on ItsPkiItss system ItsPkiItssSystem {
// Local variables
var GeoNetworkingPdu v_securedGnPdu;
var integer i;
YannGarcia
committed
// Test component configuration
f_cfUp_itss();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
geoNetworkingPort.clear;
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwSecPdu(
mw_etsiTs103097Data_signed(
mw_signedData
)))) {
tc_ac.stop;
YannGarcia
committed
f_sendUtTriggerRequestForRcaCtl(""); // FIXME Create PIXIT for RCA DC
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
log("*** " & testcasename() & ": PASS: Trigger was sent ***");
f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
YannGarcia
committed
// Postamble
f_cfDown_itss();
} // End of function f_TC_SECPKI_ITSS_CTL_05_BV_itss
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTL_05_BV_pki() runs on ItsPkiHttp system ItsPkiItssSystem {
// Local variable
var HttpMessage v_response;
var Headers v_headers;
var float v_t1 := 30.0; // nextUpdate expiry in second
// := (f_getCurrentTime()/* - 1072915200000*/) / 1000; // nextUpdate expiry in second
// Test component configuration
f_cfHttpUp_ca();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
tc_ac.start;
alt {
[] a_await_dc_http_request_from_iut(
mw_http_request(
mw_http_request_get(
YannGarcia
committed
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
)),
v_response
) {
var HashedId8 v_aa_hashed_id8; // Used for signature
var Oct32 v_aa_private_key;
var EtsiTs103097Certificate v_aa_new; // The CERT_AA_NEW
var bitstring v_enc_msg;
var ToBeSignedData v_tbs;
var bitstring v_tbs_enc;
var Oct32 v_tbs_signed;
var Signature v_signature;
var Ieee1609Dot2Data v_ieee1609dot2_signed_data;
tc_ac.stop;
// Read certificates
f_getCertificateHash("CERT_IUT_AA", v_aa_hashed_id8);
f_readSigningKey("CERT_IUT_AA", v_aa_private_key);
f_readCertificate(cc_ectl_aa_new, v_aa_new);
// Build the ToBeSignedRcaCtl data structure
v_enc_msg := encvalue(
valueof(
m_to_be_signed_rca_full_ctl(
f_getCurrentTime() / 1000 + 30,
10,
{
m_ctrl_command_add(
m_ctl_entry_aa(
m_aa_entry(
v_aa_new,
"" // FIXME PICS_AA_ENTRY_URL
)))
}
)));
v_tbs := valueof(
m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(bit2oct(v_enc_msg))
),
m_headerInfo_inner_pki_request(-, (f_getCurrentTime() * 1000)/*us*/)
));
v_tbs_enc := encvalue(v_tbs);
// Sign the certificate
v_tbs_signed := f_signWithEcdsa(bit2oct(v_tbs_enc), v_aa_hashed_id8, v_aa_private_key);
v_signature := valueof(
m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
substr(v_tbs_signed, 0, 32)
),
substr(v_tbs_signed, 32, 32)
)));
log(testcasename() & ": v_signature= ", v_signature);
v_ieee1609dot2_signed_data := valueof(
m_etsiTs103097Data_signed(
m_signedData(
sha256,
v_tbs,
m_signerIdentifier_digest(v_aa_hashed_id8),
v_signature
)));
// Send response with CERT_AA_NEW
f_init_default_headers_list(-, "ca_request", v_headers);
f_http_send(
v_headers,
m_http_response(
m_http_response_ok(
m_http_message_body_binary(
m_binary_body_ieee1609dot2_data(
v_ieee1609dot2_signed_data
)),
v_headers
)));
YannGarcia
committed
log("*** " & testcasename() & ": INFO: CERT_RCA_NEW was sent to the IUT ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
tc_wait.start(v_t1);
alt {
[] a_await_cpoc_http_request_from_iut(
mw_http_request(
mw_http_request_get(
YannGarcia
committed
)),
v_response
) {
tc_wait.stop;
YannGarcia
committed
// TODO Send an error response (400 Bad request?)
log("*** " & testcasename() & ": FAIL: ITSS RCA DC request received before the tiemer expiry ***");
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_error);
}
[] tc_wait.timeout {
log("*** " & testcasename() & ": PASS: No RCA DC done before the timer expiry ***");
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
}
} // End of 'alt' statement
// TODO Wait for the request after timer expiry
YannGarcia
committed
// Postamble
f_cfHttpDown_ca();
YannGarcia
committed
} // End of testcase TC_SECPKI_ITSS_CTL_05_BV
YannGarcia
committed
} // End of group f_TC_SECPKI_ITSS_CTL_05_BV
YannGarcia
committed
function f_sendSecuredCam(in charstring p_certificate_id) runs on ItsPkiItss return GeoNetworkingPdu {
// Local variables
var GeoNetworkingPdu v_securedGnPdu;
YannGarcia
committed
v_securedGnPdu := f_prepareSecuredCam(p_certificate_id, valueof(m_headerInfo_cam(-, (f_getCurrentTime() * 1000)/*us*/)), valueof(m_signerIdentifier_digest), f_getTsStationId());
log("f_sendSecuredCam: v_securedGnPdu= ", v_securedGnPdu);
geoNetworkingPort.send(valueof(m_geoNwReq_linkLayerBroadcast(v_securedGnPdu)));
return v_securedGnPdu;
}
YannGarcia
committed
function f_prepareSecuredCam(
in charstring p_configId,
in HeaderInfo p_headerInfo,
in SignerIdentifier p_signerIdentifier,
in template (value) StationId p_station_id := f_getTsStationId()
YannGarcia
committed
) runs on ItsPkiItss return GeoNetworkingPdu {
// Local variables
var GnNonSecuredPacket v_gnNonSecuredPacket;
var octetstring v_gnPayload;
var EtsiTs103097Data v_securedMessage;
var LongPosVector v_longPosVector := valueof(m_dummyLongPosVector);
YannGarcia
committed
log(">>> f_prepareSecuredCam");
YannGarcia
committed
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
// Build signed Ieee1609Dot2Data
v_longPosVector.latitude := f_getTsLatitude();
v_longPosVector.longitude := f_getTsLongitude();
v_longPosVector.gnAddr := f_getTsGnLocalAddress(c_compNodeB);
v_gnNonSecuredPacket := valueof(m_geoNwShbPacket(
v_longPosVector
));
// Encode CAM payload
v_gnPayload := valueof(
bit2oct(
encvalue(
m_camMsg_vehicle_HF_BV(
valueof(p_station_id),
f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
m_tsPosition
))));
// Add BTP/CAM payload
v_gnNonSecuredPacket.payload := int2oct(2001, 2) & int2oct(0, 2) & v_gnPayload;
// Encode it
log("f_prepareSecuredCam: v_gnNonSecuredPacket= ", v_gnNonSecuredPacket);
v_gnPayload := bit2oct(
encvalue(
v_gnNonSecuredPacket
)
);
log("f_prepareSecuredCam: v_gnPayload= ", v_gnPayload);
f_buildGnSecuredCam(
v_securedMessage,
valueof(m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(
v_gnPayload
)),
p_headerInfo
)),
p_signerIdentifier,
p_configId
);
// Return secured Gn packet
return valueof(m_geoNwSecPdu(v_gnNonSecuredPacket, v_securedMessage));
} // End of function f_prepareSecuredCam
YannGarcia
committed
} // End of group f_TC_SECPKI_ITSS_CTL_xx
YannGarcia
committed
} // End of group itss_ctl_handling
YannGarcia
committed
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
group itss_ctl_distribution {
/**
* @desc Check that the IUT retransmits the newly received Delta CTL
* <pre>
* Pics Selection: PICS_UC_SEC_05_2
* Initial conditions: {
* the IUT is configured to redistribute the Delta CTL
* and the IUT doesn’t contain an CTL information
* }
* Expected behaviour:
* ensure that {
* when {
* the IUT has received the Delta CTL
* }
* then {
* the IUT is started to broadcast the received Delta CTL
* }
* }
* </pre>
*
* @see ETSI TS 103 525-2 TP SECPKI_ITSS_CTLDIST_01_BV
* @reference ETSI TS 103 601, clause 4.2.1.4
*/
testcase TC_SECPKI_ITSS_CTLDIST_01_BV() runs on ItsMtc system ItsPkiItssSystem {
// Local variables
var ItsPkiItss v_itss;
var ItsPkiHttp v_cpoc;
YannGarcia
committed
// Test control
if (not PICS_IUT_ITS_S_ROLE or not PICS_UC_SEC_05_2) {
log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_UC_SEC_05_2 required for executing the TC ***");
setverdict(inconc);
stop;
}
YannGarcia
committed
// Test component configuration
f_cfMtcUp03(v_itss, v_cpoc);
// Start components
v_itss.start(f_TC_SECPKI_ITSS_CTLDIST_01_BV_itss());
v_cpoc.start(f_TC_SECPKI_ITSS_CTLDIST_01_BV_pki());
YannGarcia
committed
// Synchronization
f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
YannGarcia
committed
// Cleanup
f_cfMtcDown03(v_itss, v_cpoc);
YannGarcia
committed
} // End of testcase TC_SECPKI_ITSS_CTLDIST_01_BV
YannGarcia
committed
group f_TC_SECPKI_ITSS_CTLDIST_01_BV {
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTLDIST_01_BV_itss() runs on ItsPkiItss system ItsPkiItssSystem {
// Local variables
var GeoNetworkingInd v_geonetworking_message;
YannGarcia
committed
// Test component configuration
f_cfUp_itss();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
geoNetworkingPort.clear;
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwSecPdu(
mw_etsiTs103097Data_signed(
mw_signedData
)))) {
tc_ac.stop;
YannGarcia
committed
f_sendUtTriggerUpdateEctl(""); // FIXME Create PIXIT for ETCL URI
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
geoNetworkingPort.clear;
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwSecPdu(
mw_etsiTs103097Data_signed(
mw_signedData
)))) -> value v_geonetworking_message {
tc_ac.stop;
YannGarcia
committed
if (f_verify_broadcasted_delta_ctl(v_geonetworking_message.msgIn) == false) {
log("*** " & testcasename() & ": FAIL: Delta CTL was not successfully broadcasted ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
} else {
log("*** " & testcasename() & ": PASS: Delta CTL was successfully broadcasted ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_success);
}
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Postamble
f_cfDown_itss();
YannGarcia
committed
} // End of function TC_SECPKI_ITSS_CTLDIST_01_BV_itss
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTLDIST_01_BV_pki() runs on ItsPkiHttp system ItsPkiItssSystem {
// Local variable
var HttpMessage v_response;
var Headers v_headers;
// Test component configuration
f_cfHttpUp_tlm();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
tc_ac.start;
alt {
[] a_await_cpoc_http_request_from_iut(
mw_http_request(
mw_http_request_get(
YannGarcia
committed
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
)),
v_response
) {
var HashedId8 v_rca_hashed_id8; // Used for signature
var Oct32 v_rca_private_key;
var EtsiTs103097Certificate v_rca_new; // The CERT_RCA_NEW
var bitstring v_enc_msg;
var ToBeSignedData v_tbs;
var bitstring v_tbs_enc;
var Oct32 v_tbs_signed;
var Signature v_signature;
var Ieee1609Dot2Data v_ieee1609dot2_signed_data;
tc_ac.stop;
// Read certificates
f_getCertificateHash(PICS_IUT_CA_CERTIFICATE_ID, v_rca_hashed_id8);
f_readSigningKey(PICS_IUT_CA_CERTIFICATE_ID, v_rca_private_key);
f_readCertificate(cc_ectl_rca_new, v_rca_new);
// Build the ToBeSignedTlmCtl data structure
v_enc_msg := encvalue(
valueof(
m_to_be_signed_tlm_full_ctl(
f_getCurrentTime() / 1000 + 3600,
10,
{
m_ctrl_command_add(
m_ctl_entry_rca(
m_root_ca_entry(
v_rca_new
)))
}
)));
v_tbs := valueof(
m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(bit2oct(v_enc_msg))
),
m_headerInfo_inner_pki_request(-, (f_getCurrentTime() * 1000)/*us*/)
));
v_tbs_enc := encvalue(v_tbs);
// Sign the certificate
v_tbs_signed := f_signWithEcdsa(bit2oct(v_tbs_enc), v_rca_hashed_id8, v_rca_private_key);
v_signature := valueof(
m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
substr(v_tbs_signed, 0, 32)
),
substr(v_tbs_signed, 32, 32)
)));
log(testcasename() & ": v_signature= ", v_signature);
v_ieee1609dot2_signed_data := valueof(
m_etsiTs103097Data_signed(
m_signedData(
sha256,
v_tbs,
m_signerIdentifier_digest(v_rca_hashed_id8),
v_signature
)));
// Send response with CERT_RCA_NEW
f_init_default_headers_list(-, "tlm_ectl", v_headers);
f_http_send(
v_headers,
m_http_response(
m_http_response_ok(
m_http_message_body_binary(
m_binary_body_ieee1609dot2_data(
v_ieee1609dot2_signed_data
)),
v_headers
)));
YannGarcia
committed
log("*** " & testcasename() & ": INFO: CERT_RCA_NEW was sent to the IUT ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
YannGarcia
committed
// Postamble
f_cfHttpDown_tlm();
} // End of function f_TC_SECPKI_ITSS_CTLDIST_01_BV_pki
} // End of group f_TC_SECPKI_ITSS_CTLDIST_01_BV
YannGarcia
committed
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
/**
* @desc Check that the IUT retransmits the updated Delta CTL
* <pre>
* Pics Selection: PICS_UC_SEC_05_2
* Initial conditions: {
* the IUT is configured to redistribute the Delta CTL
* and the IUT contains an CTL information
* containing ctlSequence (SN)
* }
* Expected behaviour:
* ensure that {
* when {
* the IUT has received the Delta CTL
* containing ctlSequence
* indicating value greater than SN
* }
* then {
* the IUT is started to broadcast the received Delta CTL
* }
* }
* </pre>
*
* @see ETSI TS 103 525-2 TP SECPKI_ITSS_CTLDIST_02_BV
* @reference ETSI TS 103 601, clause 4.2.1.4
*/
testcase TC_SECPKI_ITSS_CTLDIST_02_BV() runs on ItsMtc system ItsPkiItssSystem {
// Local variables
var ItsPkiItss v_itss;
var ItsPkiHttp v_cpoc;
YannGarcia
committed
// Test control
if (not PICS_IUT_ITS_S_ROLE or not PICS_UC_SEC_05_2) {
log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_UC_SEC_05_2 required for executing the TC ***");
setverdict(inconc);
stop;
}
YannGarcia
committed
// Test component configuration
f_cfMtcUp03(v_itss, v_cpoc);
// Start components
v_itss.start(f_TC_SECPKI_ITSS_CTLDIST_02_BV_itss());
v_cpoc.start(f_TC_SECPKI_ITSS_CTLDIST_02_BV_pki());
YannGarcia
committed
// Synchronization
f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
YannGarcia
committed
// Cleanup
f_cfMtcDown03(v_itss, v_cpoc);
YannGarcia
committed
} // End of testcase TC_SECPKI_ITSS_CTLDIST_02_BV
YannGarcia
committed
group f_TC_SECPKI_ITSS_CTLDIST_02_BV {
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTLDIST_02_BV_itss() runs on ItsPkiItss system ItsPkiItssSystem {
// Local variables
var GeoNetworkingInd v_geonetworking_message;
YannGarcia
committed
// Test component configuration
f_cfUp_itss();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
geoNetworkingPort.clear;
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwSecPdu(
mw_etsiTs103097Data_signed(
mw_signedData
)))) {
tc_ac.stop;
YannGarcia
committed
f_sendUtTriggerUpdateEctl(""); // FIXME Create PIXIT for ETCL URI
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
geoNetworkingPort.clear;
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwSecPdu(
mw_etsiTs103097Data_signed(
mw_signedData
)))) -> value v_geonetworking_message {
tc_ac.stop;
YannGarcia
committed
if (f_verify_broadcasted_delta_ctl(v_geonetworking_message.msgIn) == false) {
log("*** " & testcasename() & ": FAIL: Delta CTL was not successfully broadcasted ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
} else {
log("*** " & testcasename() & ": PASS: Delta CTL was successfully broadcasted ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_success);
}
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Postamble
f_cfDown_itss();
YannGarcia
committed
} // End of function TC_SECPKI_ITSS_CTLDIST_02_BV_itss
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTLDIST_02_BV_pki() runs on ItsPkiHttp system ItsPkiItssSystem {
// Local variable
var HttpMessage v_response;
var Headers v_headers;
// Test component configuration
f_cfHttpUp_tlm();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
tc_ac.start;
alt {
[] a_await_cpoc_http_request_from_iut(
mw_http_request(
mw_http_request_get(
YannGarcia
committed
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
)),
v_response
) {
var HashedId8 v_rca_hashed_id8; // Used for signature
var Oct32 v_rca_private_key;
var EtsiTs103097Certificate v_rca_new; // The CERT_RCA_NEW
var bitstring v_enc_msg;
var ToBeSignedData v_tbs;
var bitstring v_tbs_enc;
var Oct32 v_tbs_signed;
var Signature v_signature;
var Ieee1609Dot2Data v_ieee1609dot2_signed_data;
tc_ac.stop;
// Read certificates
f_getCertificateHash(PICS_IUT_CA_CERTIFICATE_ID, v_rca_hashed_id8);
f_readSigningKey(PICS_IUT_CA_CERTIFICATE_ID, v_rca_private_key);
f_readCertificate(cc_ectl_rca_new, v_rca_new);
// Build the ToBeSignedTlmCtl data structure
v_enc_msg := encvalue(
valueof(
m_to_be_signed_tlm_full_ctl(
f_getCurrentTime() / 1000 + 3600,
10,
{
m_ctrl_command_add(
m_ctl_entry_rca(
m_root_ca_entry(
v_rca_new
)))
}
)));
v_tbs := valueof(
m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(bit2oct(v_enc_msg))
),
m_headerInfo_inner_pki_request(-, (f_getCurrentTime() * 1000)/*us*/)
));
v_tbs_enc := encvalue(v_tbs);
// Sign the certificate
v_tbs_signed := f_signWithEcdsa(bit2oct(v_tbs_enc), v_rca_hashed_id8, v_rca_private_key);
v_signature := valueof(
m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
substr(v_tbs_signed, 0, 32)
),
substr(v_tbs_signed, 32, 32)
)));
log(testcasename() & ": v_signature= ", v_signature);
v_ieee1609dot2_signed_data := valueof(
m_etsiTs103097Data_signed(
m_signedData(
sha256,
v_tbs,
m_signerIdentifier_digest(v_rca_hashed_id8),
v_signature
)));
// Send response with CERT_RCA_NEW
f_init_default_headers_list(-, "tlm_ectl", v_headers);
f_http_send(
v_headers,
m_http_response(
m_http_response_ok(
m_http_message_body_binary(
m_binary_body_ieee1609dot2_data(
v_ieee1609dot2_signed_data
)),
v_headers
)));
YannGarcia
committed
log("*** " & testcasename() & ": INFO: CERT_RCA_NEW was sent to the IUT ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
YannGarcia
committed
// Postamble
f_cfHttpDown_tlm();
} // End of function f_TC_SECPKI_ITSS_CTLDIST_02_BV_pki
} // End of group f_TC_SECPKI_ITSS_CTLDIST_02_BV
YannGarcia
committed
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
/**
* @desc Check that the IUT is using the proper BTP port to broadcast the Delta CTL
* <pre>
* Pics Selection: PICS_UC_SEC_05_2
* Initial conditions: {
* the IUT is configured to support P2P X_DISTRIBUTION distribution
* and the IUT has received the Delta X_DISTRIBUTION message
* }
* Expected behaviour:
* ensure that {
* when {
* the IUT is triggered to broadcast the Delta X_DISTRIBUTION message
* }
* then {
* the IUT sends the X_MESSAGE
* using the BTP port 2014
* }
* }
* </pre>
*
* @see ETSI TS 103 525-2 TP SECPKI_ITSS_CTLDIST_03_BV
* @reference ETSI TS 103 601, clause 5.4.4
*/
testcase TC_SECPKI_ITSS_CTLDIST_03_BV() runs on ItsMtc system ItsPkiItssSystem {
// Local variables
var ItsPkiItss v_itss;
var ItsPkiHttp v_cpoc;
YannGarcia
committed
// Test control
if (not PICS_IUT_ITS_S_ROLE or not PICS_UC_SEC_05_2) {
log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_UC_SEC_05_2 required for executing the TC ***");
setverdict(inconc);
stop;
}
YannGarcia
committed
// Test component configuration
f_cfMtcUp03(v_itss, v_cpoc);
// Start components
v_itss.start(f_TC_SECPKI_ITSS_CTLDIST_03_BV_itss());
v_cpoc.start(f_TC_SECPKI_ITSS_CTLDIST_03_BV_pki());
YannGarcia
committed
// Synchronization
f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
YannGarcia
committed
// Cleanup
f_cfMtcDown03(v_itss, v_cpoc);
YannGarcia
committed
} // End of testcase TC_SECPKI_ITSS_CTLDIST_03_BV
YannGarcia
committed
group f_TC_SECPKI_ITSS_CTLDIST_03_BV {
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTLDIST_03_BV_itss() runs on ItsPkiItss system ItsPkiItssSystem {
// Local variables
var GeoNetworkingInd v_geonetworking_message;
var octetstring v_payload;
YannGarcia
committed
// Test component configuration
f_cfUp_itss();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
geoNetworkingPort.clear;
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwSecPdu(
mw_etsiTs103097Data_signed(
mw_signedData
)))) {
tc_ac.stop;
YannGarcia
committed
f_sendUtTriggerUpdateEctl(""); // FIXME Create PIXIT for ETCL URI
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
geoNetworkingPort.clear;
tc_ac.start;
alt {
[] geoNetworkingPort.receive(
mw_geoNwInd(
mw_geoNwSecPdu(
mw_etsiTs103097Data_signed(
mw_signedData
)))) -> value v_geonetworking_message {
tc_ac.stop;
YannGarcia
committed
if (f_verify_and_extract_payload(v_geonetworking_message.msgIn, -, v_payload) == false) {
log("*** " & testcasename() & ": INCONC: Failed to verifiy payload ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
} else {
// TODO Check payload
if (substr(v_payload, 0, 2) == int2oct(2014, 2)) { // TODO Reorganize CAM/DENM/BTP test suites
log("*** " & testcasename() & ": PASS: Delta CTL was successfully broadcasted on the correct BTP port ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_success);
} else {
log("*** " & testcasename() & ": FAIL: Delta CTL was not broadcasted on BTP port 114 ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_error);
}
}
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdictPreamble(c_tbDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Postamble
f_cfDown_itss();
YannGarcia
committed
} // End of function TC_SECPKI_ITSS_CTLDIST_03_BV_itss
YannGarcia
committed
function f_TC_SECPKI_ITSS_CTLDIST_03_BV_pki() runs on ItsPkiHttp system ItsPkiItssSystem {
// Local variable
var HttpMessage v_response;
var Headers v_headers;
// Test component configuration
f_cfHttpUp_tlm();
YannGarcia
committed
// Test adapter configuration
YannGarcia
committed
// Preamble
tc_ac.start;
alt {
[] a_await_cpoc_http_request_from_iut(
mw_http_request(
mw_http_request_get(
YannGarcia
committed
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
)),
v_response
) {
var HashedId8 v_rca_hashed_id8; // Used for signature
var Oct32 v_rca_private_key;
var EtsiTs103097Certificate v_rca_new; // The CERT_RCA_NEW
var bitstring v_enc_msg;
var ToBeSignedData v_tbs;
var bitstring v_tbs_enc;
var Oct32 v_tbs_signed;
var Signature v_signature;
var Ieee1609Dot2Data v_ieee1609dot2_signed_data;
tc_ac.stop;
// Read certificates
f_getCertificateHash(PICS_IUT_CA_CERTIFICATE_ID, v_rca_hashed_id8);
f_readSigningKey(PICS_IUT_CA_CERTIFICATE_ID, v_rca_private_key);
f_readCertificate(cc_ectl_rca_new, v_rca_new);
// Build the ToBeSignedTlmCtl data structure
v_enc_msg := encvalue(
valueof(
m_to_be_signed_tlm_full_ctl(
f_getCurrentTime() / 1000 + 3600,
10,
{
m_ctrl_command_add(
m_ctl_entry_rca(
m_root_ca_entry(
v_rca_new
)))
}
)));
v_tbs := valueof(
m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(bit2oct(v_enc_msg))
),
m_headerInfo_inner_pki_request(-, (f_getCurrentTime() * 1000)/*us*/)
));
v_tbs_enc := encvalue(v_tbs);
// Sign the certificate
v_tbs_signed := f_signWithEcdsa(bit2oct(v_tbs_enc), v_rca_hashed_id8, v_rca_private_key);
v_signature := valueof(
m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
substr(v_tbs_signed, 0, 32)
),
substr(v_tbs_signed, 32, 32)
)));
log(testcasename() & ": v_signature= ", v_signature);
v_ieee1609dot2_signed_data := valueof(
m_etsiTs103097Data_signed(
m_signedData(
sha256,
v_tbs,
m_signerIdentifier_digest(v_rca_hashed_id8),
v_signature
)));
// Send response with CERT_RCA_NEW
f_init_default_headers_list(-, "tlm_ectl", v_headers);
f_http_send(
v_headers,
m_http_response(
m_http_response_ok(
m_http_message_body_binary(
m_binary_body_ieee1609dot2_data(
v_ieee1609dot2_signed_data
)),
v_headers
)));
YannGarcia
committed
log("*** " & testcasename() & ": INFO: CERT_RCA_NEW was sent to the IUT ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_success);
}
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
}
} // End of 'alt' statement
YannGarcia
committed
// Test Body
f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
YannGarcia
committed
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
// Postamble
f_cfHttpDown_tlm();
} // End of function f_TC_SECPKI_ITSS_CTLDIST_03_BV_pki
} // End of group f_TC_SECPKI_ITSS_CTLDIST_03_BV
/**
* @desc Check that the IUT stops to redistribute the Delta CTL if anorther node is also sending it
* <pre>
* Pics Selection: PICS_UC_SEC_05_2
* Initial conditions: {
* the IUT is configured to support P2P Delta X_DISTRIBUTION distribution
* and the IUT has started broadcasting the Delta X_DISTRIBUTION message
* signed with X_CERTIFICATE
* and containing ctlSequence (SN)
* }
* Expected behaviour:
* ensure that {
* when {
* the IUT has received the Delta X_DISTRIBUTION
* signed with X_CERTIFICATE
* and containing ctlSequence
* indicating value equal or higher than SN
* }
* then {
* the IUT stops broadfcasting the Delta X_DISTRIBUTION
* signed with X_CERTIFICATE
* and containing ctlSequence (SN)
* }
* }
* </pre>
*
* @see ETSI TS 103 525-2 TP SECPKI_ITSS_CTLDIST_04_BV
* @reference ETSI TS 103 601, clause 5.4.4
*/
testcase TC_SECPKI_ITSS_CTLDIST_04_BV() runs on ItsMtc system ItsPkiItssSystem {
// Local variables
var ItsPkiItss v_itss;
var ItsPkiHttp v_cpoc;
YannGarcia
committed
// Test control
if (not PICS_IUT_ITS_S_ROLE or not PICS_UC_SEC_05_2) {
log("*** " & testcasename() & ": PICS_IUT_ITS_S_ROLE and PICS_UC_SEC_05_2 required for executing the TC ***");
setverdict(inconc);
stop;
}
YannGarcia
committed
// Test component configuration
f_cfMtcUp03(v_itss, v_cpoc);
// Start components
v_itss.start(f_TC_SECPKI_ITSS_CTLDIST_04_BV_itss());
v_cpoc.start(f_TC_SECPKI_ITSS_CTLDIST_04_BV_pki());
YannGarcia
committed
// Synchronization
f_serverSync2ClientsAndStop({c_prDone, c_tbDone});
YannGarcia
committed
// Cleanup
f_cfMtcDown03(v_itss, v_cpoc);
YannGarcia
committed
} // End of testcase TC_SECPKI_ITSS_CTLDIST_04_BV
YannGarcia
committed
group f_TC_SECPKI_ITSS_CTLDIST_04_BV {
function f_broadcast_delta_ctl(
in charstring p_certificate_id,
out Ieee1609Dot2Data p_delta_ctl
) runs on ItsPkiItss return GeoNetworkingPdu {
// Local variables
var GeoNetworkingPdu v_securedGnPdu;
YannGarcia
committed
log(">>> f_broadcast_delta_ctl");
YannGarcia
committed
v_securedGnPdu := f_prepareSecuredCam(p_certificate_id, valueof(m_headerInfo_cam(-, (f_getCurrentTime() * 1000)/*us*/)), valueof(m_signerIdentifier_digest), f_getTsStationId());
log("f_sendSecuredCam: v_securedGnPdu= ", v_securedGnPdu);