Loading ttcn/Pki/LibItsPki_Functions.ttcn +36 −19 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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()); Loading @@ -88,12 +89,8 @@ module LibItsPki_Functions { map(self:httpPort, system:httpPort); 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); f_readSigningKey(p_certificateId, vc_eaPrivateKey); f_readEncryptingKey(p_certificateId, vc_eaPrivateEncKey); Loading @@ -114,6 +111,8 @@ 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 Loading @@ -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 /** Loading @@ -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 /** Loading @@ -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 { Loading Loading @@ -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 ***"); Loading ttcn/Pki/LibItsPki_Templates.ttcn +18 −2 Original line number Diff line number Diff line Loading @@ -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 := { Loading @@ -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 := ? ) := { Loading ttcn/Pki/LibItsPki_TestSystem.ttcn +61 −49 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -28,32 +23,39 @@ 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; // LibItsCommon import from LibItsCommon_TestSystem all; import from LibItsCommon_TypesAndValues all; // LibItsSecurity import from LibItsSecurity_TestSystem all; // LibItsPki import from LibItsPki_TypesAndValues all; // LibItsGeoNetworking import from LibItsGeoNetworking_TestSystem all; // LibItsPki import from LibItsPki_TypesAndValues all; // LibItsSecurity import from LibItsSecurity_TestSystem all; // LibItsHttp import from LibItsHttp_TestSystem all; group portDefinitions { /** * @desc Adapter control port */ type port AdapterControlPkiPort message { type port AdapterControlPort message { out AcPkiPrimitive; in AcPkiResponse; } // End of AdapterControlPkiPort } // End of AdapterControlPort /** * @desc Adapter control port */ type port AdapterControlPort message { type port AdapterControlPkiPort message { out AcPkiPrimitive; in AcPkiResponse; } // End of AdapterControlPort } // End of AdapterControlPkiPort /** * @desc Upper Tester port Loading @@ -63,9 +65,17 @@ module LibItsPki_TestSystem { 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 group componentDefinitions { type component ItsPkiSystem { port AdapterControlPkiPort acPkiPort; Loading @@ -81,6 +91,8 @@ module LibItsPki_TestSystem { port GeoNetworkingPort geoNetworkingPort; } // End of component ItsPkiItssSystem } // End of group componentDefinitions type component ItsPki extends ItsSecurityBaseComponent, ItsBaseMtc { port AdapterControlPkiPort acPkiPort; port PkiPort pkiPort; Loading ttcn/Pki/LibItsPki_TypesAndValues.ttcn +36 −36 Original line number Diff line number Diff line Loading @@ -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 { /** Loading Loading @@ -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 "" Loading Loading
ttcn/Pki/LibItsPki_Functions.ttcn +36 −19 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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()); Loading @@ -88,12 +89,8 @@ module LibItsPki_Functions { map(self:httpPort, system:httpPort); 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); f_readSigningKey(p_certificateId, vc_eaPrivateKey); f_readEncryptingKey(p_certificateId, vc_eaPrivateEncKey); Loading @@ -114,6 +111,8 @@ 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 Loading @@ -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 /** Loading @@ -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 /** Loading @@ -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 { Loading Loading @@ -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 ***"); Loading
ttcn/Pki/LibItsPki_Templates.ttcn +18 −2 Original line number Diff line number Diff line Loading @@ -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 := { Loading @@ -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 := ? ) := { Loading
ttcn/Pki/LibItsPki_TestSystem.ttcn +61 −49 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -28,32 +23,39 @@ 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; // LibItsCommon import from LibItsCommon_TestSystem all; import from LibItsCommon_TypesAndValues all; // LibItsSecurity import from LibItsSecurity_TestSystem all; // LibItsPki import from LibItsPki_TypesAndValues all; // LibItsGeoNetworking import from LibItsGeoNetworking_TestSystem all; // LibItsPki import from LibItsPki_TypesAndValues all; // LibItsSecurity import from LibItsSecurity_TestSystem all; // LibItsHttp import from LibItsHttp_TestSystem all; group portDefinitions { /** * @desc Adapter control port */ type port AdapterControlPkiPort message { type port AdapterControlPort message { out AcPkiPrimitive; in AcPkiResponse; } // End of AdapterControlPkiPort } // End of AdapterControlPort /** * @desc Adapter control port */ type port AdapterControlPort message { type port AdapterControlPkiPort message { out AcPkiPrimitive; in AcPkiResponse; } // End of AdapterControlPort } // End of AdapterControlPkiPort /** * @desc Upper Tester port Loading @@ -63,9 +65,17 @@ module LibItsPki_TestSystem { 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 group componentDefinitions { type component ItsPkiSystem { port AdapterControlPkiPort acPkiPort; Loading @@ -81,6 +91,8 @@ module LibItsPki_TestSystem { port GeoNetworkingPort geoNetworkingPort; } // End of component ItsPkiItssSystem } // End of group componentDefinitions type component ItsPki extends ItsSecurityBaseComponent, ItsBaseMtc { port AdapterControlPkiPort acPkiPort; port PkiPort pkiPort; Loading
ttcn/Pki/LibItsPki_TypesAndValues.ttcn +36 −36 Original line number Diff line number Diff line Loading @@ -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 { /** Loading Loading @@ -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 "" Loading