Commit 4f886d53 authored by garciay's avatar garciay
Browse files

STF545: Add InnerAcRequest/Response support, UpperTester port for ITS-S

parent 8e744cf3
......@@ -34,11 +34,15 @@ module LibItsPki_Functions {
import from LibItsCommon_ASN1_NamedNumbers all;
import from LibItsCommon_Pixits all;
// LibItsGeoNetworking
import from LibItsGeoNetworking_Pixits all;
// LibItsSecurity
import from LibItsSecurity_TypesAndValues all;
import from LibItsSecurity_Templates all;
import from LibItsSecurity_Functions all;
import from LibItsSecurity_Pixits all;
import from LibItsSecurity_TestSystem all;
// LibItsHttp
import from LibItsHttp_TypesAndValues all;
......@@ -58,19 +62,16 @@ module LibItsPki_Functions {
* @param p_certificateId The certificate identifier the TA shall use in case of secured IUT
*/
function f_cfUp(
in charstring p_certificateId := "CERT_TS_A_EA" // TODO Use a constant
in charstring p_certificateId := "CERT_TS_A_EA", // TODO Use a constant
in charstring p_peerCertificateId := "CERT_IUT_A_EA"
) runs on ItsPki /* TITAN TODO: system ItsPkiSystem */ {
map(self:pkiPort, system:pkiPort);
map(self:acPkiPort, system:acPkiPort);
f_connect4SelfOrClientSync();
if( not f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) ) {
log("*** INFO: TEST CASE NOW STOPPING ITSELF! ***");
stop;
}
f_initialiseSecuredMode(p_certificateId, p_peerCertificateId);
f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
f_readCertificate(p_certificateId, vc_eaCertificate);
activate(a_default_pki());
......@@ -87,13 +88,9 @@ module LibItsPki_Functions {
map(self:httpPort, system:httpPort);
f_connect4SelfOrClientSync();
f_initialiseSecuredMode(p_certificateId, p_peerCertificateId);
if( not f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) ) {
log("*** INFO: TEST CASE NOW STOPPING ITSELF! ***");
stop;
}
f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
f_readCertificate(p_certificateId, vc_eaCertificate);
f_readSigningKey(p_certificateId, vc_eaPrivateKey);
f_readEncryptingKey(p_certificateId, vc_eaPrivateEncKey);
......@@ -114,9 +111,11 @@ module LibItsPki_Functions {
map(self:utPort, system:utPort);
map(self:acPort, system:acPort);
f_initializeState();
activate(a_default_pki());
} // End of function f_cfUp_itss
/**
* @desc Deletes default configuration
*/
......@@ -124,6 +123,7 @@ module LibItsPki_Functions {
unmap(self:pkiPort, system:pkiPort);
unmap(self:acPkiPort, system:acPkiPort);
f_disconnect4SelfOrClientSync();
f_uninitialiseSecuredMode();
} // End of function f_cfDown
/**
......@@ -132,6 +132,7 @@ module LibItsPki_Functions {
function f_cfHttpDown() runs on ItsPkiHttp /* TITAN TODO: system ItsPkiHttpSystem */ {
unmap(self:httpPort, system:httpPort);
f_disconnect4SelfOrClientSync();
f_uninitialiseSecuredMode();
} // End of function f_cfHttpDown
/**
......@@ -148,21 +149,37 @@ module LibItsPki_Functions {
/**
* @desc Initialise secure mode if required
*/
function f_initialiseSecuredMode() runs on ItsPki {
function f_initialiseSecuredMode(
in charstring p_certificateId := "CERT_TS_A_EA", // TODO Use a constant
in charstring p_peerCertificateId := "CERT_IUT_A_EA"
) runs on ItsSecurityBaseComponent {
// Local variables
// Load certificates
if( not f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) ) {
log("*** INFO: TEST CASE NOW STOPPING ITSELF! ***");
setverdict(inconc);
stop;
}
f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
} // End of function f_initialiseSecuredMode()
function f_uninitialiseSecuredMode() runs on ItsPki {
function f_uninitialiseSecuredMode() runs on ItsSecurityBaseComponent {
f_unloadCertificates();
} // End of function f_uninitialiseSecuredMode()
function f_initializeState() runs on ItsPkiItss {
var Oct8 v_hashedId8ToBeUsed := f_setupIutCertificate(vc_hashedId8ToBeUsed);
f_utInitializeIut(UtPkiInitialize: { v_hashedId8ToBeUsed } );
f_sleep(PX_NEIGHBOUR_DISCOVERY_DELAY);
// f_acLoadScenario(p_scenario);
// f_acStartScenario();
}
} // End of pkiConfigurationFunctions
group ac_port {
......@@ -281,7 +298,7 @@ module LibItsPki_Functions {
}
// 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));
// Get 16 last byte of SHA256 of InnerEcRequestSignedForPop
// Prepae for getting the 16 most bytes of SHA256 of InnerEcRequestSignedForPop
p_hash_inner_ec_request_signed_for_pop := f_hashWithSha256(bit2oct(v_inner_ec_request_signed_for_pop_msg));
if (f_build_pki_secured_message(vc_eaPrivateKey, valueof(m_signerIdentifier_self), vc_eaHashedId8, p_publicKeyCompressed, p_compressedMode, bit2oct(v_inner_ec_request_signed_for_pop_msg), p_ieee1609dot2_signed_and_encrypted_data) == false) {
log("*** f_http_build_enrolment_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***");
......
......@@ -77,6 +77,11 @@ module LibItsPki_Templates {
) modifies m_etsiTs103097Data_encrypted := {
} // End of template m_enrolmentRequestMessage
template (present) EnrolmentRequestMessage mw_enrolmentRequestMessage(
template (present) EncryptedData p_encryptedData := ?
) modifies mw_etsiTs103097Data_encrypted := {
} // End of template mw_enrolmentRequestMessage
template (present) EnrolmentRequestMessage mw_enrolmentResponseMessage(
template (present) EncryptedData p_encryptedData := ?
) modifies mw_etsiTs103097Data_encrypted := {
......@@ -88,8 +93,8 @@ module LibItsPki_Templates {
} // End of template m_authorizationRequestMessage
template (value) AuthorizationResponseMessage m_authorizationResponseMessage(
in template (value) EncryptedData p_encryptedData
) modifies m_etsiTs103097Data_encrypted := {
in template (value) EncryptedData p_encryptedData
) modifies m_etsiTs103097Data_encrypted := {
} // End of template m_authorizationResponseMessage
template (value) EtsiTs102941DataContent m_enrolmentRequest(
......@@ -98,6 +103,17 @@ module LibItsPki_Templates {
enrolmentRequest := p_enrolmentRequest
} // End of template m_enrolmentRequest
template (present) EtsiTs102941DataContent mw_enrolmentRequest(
template (present) InnerEcRequestSignedForPop p_enrolmentRequest := ?
) := {
enrolmentRequest := p_enrolmentRequest
} // End of template mw_enrolmentRequest
template (present) InnerEcRequestSignedForPop mw_innerEcRequestSignedForPop(
template (present) SignedData p_signedData := ?
) modifies mw_etsiTs103097Data_signed := {
} // End of template mw_innerEcRequestSignedForPop
template (present) EtsiTs102941DataContent mw_enrolmentResponse(
template (present) InnerEcResponse p_enrolmentResponse := ?
) := {
......
......@@ -15,11 +15,6 @@ module LibItsPki_TestSystem {
import from LibCommon_Sync all;
import from LibCommon_Time all;
// LibItsCommon
import from LibItsCommon_TestSystem all;
import from LibItsCommon_TypesAndValues all;
import from LibItsExternal_TypesAndValues all;
// LibIts
import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
import from IEEE1609dot2 language "ASN.1:1997" all;
......@@ -28,58 +23,75 @@ module LibItsPki_TestSystem {
import from EtsiTs102941MessagesItss language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
// LibItsHttp
import from LibItsHttp_TestSystem all;
// LibItsSecurity
import from LibItsSecurity_TestSystem all;
// LibItsGeoNetworking
import from LibItsGeoNetworking_TestSystem all;
// LibItsCommon
import from LibItsCommon_TestSystem all;
import from LibItsCommon_TypesAndValues all;
// LibItsPki
import from LibItsPki_TypesAndValues all;
/**
* @desc Adapter control port
*/
type port AdapterControlPkiPort message {
out AcPkiPrimitive;
in AcPkiResponse;
} // End of AdapterControlPkiPort
/**
* @desc Adapter control port
*/
type port AdapterControlPort message {
out AcPkiPrimitive;
in AcPkiResponse;
} // End of AdapterControlPort
/**
* @desc Upper Tester port
*/
type port UpperTesterPort message {
out UtPkiInitialize, UtPkiTrigger;
in UtPkiResults;
} // End of UpperTesterPort
// LibItsGeoNetworking
import from LibItsGeoNetworking_TestSystem all;
type port PkiPort message {
inout InnerEcRequest, InnerEcResponse;
}
// LibItsSecurity
import from LibItsSecurity_TestSystem all;
type component ItsPkiSystem {
port AdapterControlPkiPort acPkiPort;
port PkiPort pkiPort;
} // End of component ItsPkiSystem
// LibItsHttp
import from LibItsHttp_TestSystem all;
type component ItsPkiHttpSystem extends HttpTestAdapter{
} // End of component ItsPkiHttpSystem
group portDefinitions {
/**
* @desc Adapter control port
*/
type port AdapterControlPort message {
out AcPkiPrimitive;
in AcPkiResponse;
} // End of AdapterControlPort
/**
* @desc Adapter control port
*/
type port AdapterControlPkiPort message {
out AcPkiPrimitive;
in AcPkiResponse;
} // End of AdapterControlPkiPort
/**
* @desc Upper Tester port
*/
type port UpperTesterPort message {
out UtPkiInitialize, UtPkiTrigger;
in UtPkiResults;
} // End of UpperTesterPort
} // End of group portDefinitions
group interfacePorts {
type port PkiPort message {
inout InnerEcRequest, InnerEcResponse;
} // End of PkiPort
} // End of group interfacePorts
type component ItsPkiItssSystem extends ItsPkiSystem {
port AdapterControlPort acPort;
port UpperTesterPort utPort;
port GeoNetworkingPort geoNetworkingPort;
} // End of component ItsPkiItssSystem
group componentDefinitions {
type component ItsPkiSystem {
port AdapterControlPkiPort acPkiPort;
port PkiPort pkiPort;
} // End of component ItsPkiSystem
type component ItsPkiHttpSystem extends HttpTestAdapter{
} // End of component ItsPkiHttpSystem
type component ItsPkiItssSystem extends ItsPkiSystem {
port AdapterControlPort acPort;
port UpperTesterPort utPort;
port GeoNetworkingPort geoNetworkingPort;
} // End of component ItsPkiItssSystem
} // End of group componentDefinitions
type component ItsPki extends ItsSecurityBaseComponent, ItsBaseMtc {
port AdapterControlPkiPort acPkiPort;
......
......@@ -23,42 +23,6 @@ module LibItsPki_TypesAndValues {
} // End of group constants
group acPrimitives {
/**
* @desc TA primitives for Pki
*/
type union AcPkiPrimitive {
AcSetSecurityData acSetSecurityData
} with {
variant ""
}
/**
* @desc Primitive for receiveing response from TA
*/
type union AcPkiResponse {
boolean result
} with {
variant ""
}
type record AcSetSecurityData {
charstring certificateId,
charstring peer_certificateId,
octetstring private_key,
octetstring public_key_compressed,
integer public_key_compressed_mode
} with {
variant ""
encode "LibItsPki"
} // AcSetSecurityData
} with {
variant ""
encode "AdapterControl"
} // End of group acPrimitives
group utPrimitives {
/**
......@@ -110,6 +74,42 @@ module LibItsPki_TypesAndValues {
variant ""
} // End of group utPrimitives
group acPrimitives {
/**
* @desc TA primitives for Pki
*/
type union AcPkiPrimitive {
AcSetSecurityData acSetSecurityData
} with {
variant ""
}
/**
* @desc Primitive for receiveing response from TA
*/
type union AcPkiResponse {
boolean result
} with {
variant ""
}
type record AcSetSecurityData {
charstring certificateId,
charstring peer_certificateId,
octetstring private_key,
octetstring public_key_compressed,
integer public_key_compressed_mode
} with {
variant ""
encode "LibItsPki"
} // AcSetSecurityData
} with {
variant ""
encode "AdapterControl"
} // End of group acPrimitives
}
with {
variant ""
......
Markdown is supported
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