Commits (1)
...@@ -34,11 +34,15 @@ module LibItsPki_Functions { ...@@ -34,11 +34,15 @@ module LibItsPki_Functions {
import from LibItsCommon_ASN1_NamedNumbers all; import from LibItsCommon_ASN1_NamedNumbers all;
import from LibItsCommon_Pixits all; import from LibItsCommon_Pixits all;
// LibItsGeoNetworking
import from LibItsGeoNetworking_Pixits all;
// LibItsSecurity // LibItsSecurity
import from LibItsSecurity_TypesAndValues all; import from LibItsSecurity_TypesAndValues all;
import from LibItsSecurity_Templates all; import from LibItsSecurity_Templates all;
import from LibItsSecurity_Functions all; import from LibItsSecurity_Functions all;
import from LibItsSecurity_Pixits all; import from LibItsSecurity_Pixits all;
import from LibItsSecurity_TestSystem all;
// LibItsHttp // LibItsHttp
import from LibItsHttp_TypesAndValues all; import from LibItsHttp_TypesAndValues all;
...@@ -58,19 +62,16 @@ module LibItsPki_Functions { ...@@ -58,19 +62,16 @@ module LibItsPki_Functions {
* @param p_certificateId The certificate identifier the TA shall use in case of secured IUT * @param p_certificateId The certificate identifier the TA shall use in case of secured IUT
*/ */
function f_cfUp( 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 */ { ) runs on ItsPki /* TITAN TODO: system ItsPkiSystem */ {
map(self:pkiPort, system:pkiPort); map(self:pkiPort, system:pkiPort);
map(self:acPkiPort, system:acPkiPort); map(self:acPkiPort, system:acPkiPort);
f_connect4SelfOrClientSync(); f_connect4SelfOrClientSync();
if( not f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) ) { f_initialiseSecuredMode(p_certificateId, p_peerCertificateId);
log("*** INFO: TEST CASE NOW STOPPING ITSELF! ***");
stop;
}
f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
f_readCertificate(p_certificateId, vc_eaCertificate); f_readCertificate(p_certificateId, vc_eaCertificate);
activate(a_default_pki()); activate(a_default_pki());
...@@ -87,13 +88,9 @@ module LibItsPki_Functions { ...@@ -87,13 +88,9 @@ module LibItsPki_Functions {
map(self:httpPort, system:httpPort); map(self:httpPort, system:httpPort);
f_connect4SelfOrClientSync(); 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_readCertificate(p_certificateId, vc_eaCertificate);
f_readSigningKey(p_certificateId, vc_eaPrivateKey); f_readSigningKey(p_certificateId, vc_eaPrivateKey);
f_readEncryptingKey(p_certificateId, vc_eaPrivateEncKey); f_readEncryptingKey(p_certificateId, vc_eaPrivateEncKey);
...@@ -114,9 +111,11 @@ module LibItsPki_Functions { ...@@ -114,9 +111,11 @@ module LibItsPki_Functions {
map(self:utPort, system:utPort); map(self:utPort, system:utPort);
map(self:acPort, system:acPort); map(self:acPort, system:acPort);
f_initializeState();
activate(a_default_pki()); activate(a_default_pki());
} // End of function f_cfUp_itss } // End of function f_cfUp_itss
/** /**
* @desc Deletes default configuration * @desc Deletes default configuration
*/ */
...@@ -124,6 +123,7 @@ module LibItsPki_Functions { ...@@ -124,6 +123,7 @@ module LibItsPki_Functions {
unmap(self:pkiPort, system:pkiPort); unmap(self:pkiPort, system:pkiPort);
unmap(self:acPkiPort, system:acPkiPort); unmap(self:acPkiPort, system:acPkiPort);
f_disconnect4SelfOrClientSync(); f_disconnect4SelfOrClientSync();
f_uninitialiseSecuredMode();
} // End of function f_cfDown } // End of function f_cfDown
/** /**
...@@ -132,6 +132,7 @@ module LibItsPki_Functions { ...@@ -132,6 +132,7 @@ module LibItsPki_Functions {
function f_cfHttpDown() runs on ItsPkiHttp /* TITAN TODO: system ItsPkiHttpSystem */ { function f_cfHttpDown() runs on ItsPkiHttp /* TITAN TODO: system ItsPkiHttpSystem */ {
unmap(self:httpPort, system:httpPort); unmap(self:httpPort, system:httpPort);
f_disconnect4SelfOrClientSync(); f_disconnect4SelfOrClientSync();
f_uninitialiseSecuredMode();
} // End of function f_cfHttpDown } // End of function f_cfHttpDown
/** /**
...@@ -148,21 +149,37 @@ module LibItsPki_Functions { ...@@ -148,21 +149,37 @@ module LibItsPki_Functions {
/** /**
* @desc Initialise secure mode if required * @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 // Local variables
// Load certificates // Load certificates
if( not f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) ) { if( not f_loadCertificates(PX_IUT_SEC_CONFIG_NAME) ) {
log("*** INFO: TEST CASE NOW STOPPING ITSELF! ***"); log("*** INFO: TEST CASE NOW STOPPING ITSELF! ***");
setverdict(inconc);
stop; stop;
} }
f_prepareCertificates(p_certificateId, vc_aaCertificate, vc_atCertificate);
} // End of function f_initialiseSecuredMode() } // End of function f_initialiseSecuredMode()
function f_uninitialiseSecuredMode() runs on ItsPki { function f_uninitialiseSecuredMode() runs on ItsSecurityBaseComponent {
f_unloadCertificates(); f_unloadCertificates();
} // End of function f_uninitialiseSecuredMode() } // 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 } // End of pkiConfigurationFunctions
group ac_port { group ac_port {
...@@ -281,7 +298,7 @@ module LibItsPki_Functions { ...@@ -281,7 +298,7 @@ module LibItsPki_Functions {
} }
// Secure InnerEcRequestSignedForPoP message // 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)); 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)); 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) { 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 ***"); log("*** f_http_build_enrolment_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***");
......
...@@ -77,6 +77,11 @@ module LibItsPki_Templates { ...@@ -77,6 +77,11 @@ module LibItsPki_Templates {
) modifies m_etsiTs103097Data_encrypted := { ) modifies m_etsiTs103097Data_encrypted := {
} // End of template m_enrolmentRequestMessage } // 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) EnrolmentRequestMessage mw_enrolmentResponseMessage(
template (present) EncryptedData p_encryptedData := ? template (present) EncryptedData p_encryptedData := ?
) modifies mw_etsiTs103097Data_encrypted := { ) modifies mw_etsiTs103097Data_encrypted := {
...@@ -88,8 +93,8 @@ module LibItsPki_Templates { ...@@ -88,8 +93,8 @@ module LibItsPki_Templates {
} // End of template m_authorizationRequestMessage } // End of template m_authorizationRequestMessage
template (value) AuthorizationResponseMessage m_authorizationResponseMessage( template (value) AuthorizationResponseMessage m_authorizationResponseMessage(
in template (value) EncryptedData p_encryptedData in template (value) EncryptedData p_encryptedData
) modifies m_etsiTs103097Data_encrypted := { ) modifies m_etsiTs103097Data_encrypted := {
} // End of template m_authorizationResponseMessage } // End of template m_authorizationResponseMessage
template (value) EtsiTs102941DataContent m_enrolmentRequest( template (value) EtsiTs102941DataContent m_enrolmentRequest(
...@@ -98,6 +103,17 @@ module LibItsPki_Templates { ...@@ -98,6 +103,17 @@ module LibItsPki_Templates {
enrolmentRequest := p_enrolmentRequest enrolmentRequest := p_enrolmentRequest
} // End of template m_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) EtsiTs102941DataContent mw_enrolmentResponse(
template (present) InnerEcResponse p_enrolmentResponse := ? template (present) InnerEcResponse p_enrolmentResponse := ?
) := { ) := {
......
...@@ -15,11 +15,6 @@ module LibItsPki_TestSystem { ...@@ -15,11 +15,6 @@ module LibItsPki_TestSystem {
import from LibCommon_Sync all; import from LibCommon_Sync all;
import from LibCommon_Time all; import from LibCommon_Time all;
// LibItsCommon
import from LibItsCommon_TestSystem all;
import from LibItsCommon_TypesAndValues all;
import from LibItsExternal_TypesAndValues all;
// LibIts // LibIts
import from IEEE1609dot2BaseTypes language "ASN.1:1997" all; import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
import from IEEE1609dot2 language "ASN.1:1997" all; import from IEEE1609dot2 language "ASN.1:1997" all;
...@@ -28,58 +23,75 @@ module LibItsPki_TestSystem { ...@@ -28,58 +23,75 @@ module LibItsPki_TestSystem {
import from EtsiTs102941MessagesItss language "ASN.1:1997" all; import from EtsiTs102941MessagesItss language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all; import from EtsiTs103097Module language "ASN.1:1997" all;
// LibItsHttp // LibItsCommon
import from LibItsHttp_TestSystem all; import from LibItsCommon_TestSystem all;
import from LibItsCommon_TypesAndValues all;
// LibItsSecurity
import from LibItsSecurity_TestSystem all;
// LibItsGeoNetworking
import from LibItsGeoNetworking_TestSystem all;
// LibItsPki // LibItsPki
import from LibItsPki_TypesAndValues all; import from LibItsPki_TypesAndValues all;
/** // LibItsGeoNetworking
* @desc Adapter control port import from LibItsGeoNetworking_TestSystem all;
*/
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
type port PkiPort message { // LibItsSecurity
inout InnerEcRequest, InnerEcResponse; import from LibItsSecurity_TestSystem all;
}
type component ItsPkiSystem { // LibItsHttp
port AdapterControlPkiPort acPkiPort; import from LibItsHttp_TestSystem all;
port PkiPort pkiPort;
} // End of component ItsPkiSystem
type component ItsPkiHttpSystem extends HttpTestAdapter{ group portDefinitions {
} // End of component ItsPkiHttpSystem
/**
* @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 { group componentDefinitions {
port AdapterControlPort acPort;
port UpperTesterPort utPort; type component ItsPkiSystem {
port GeoNetworkingPort geoNetworkingPort; port AdapterControlPkiPort acPkiPort;
} // End of component ItsPkiItssSystem 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 { type component ItsPki extends ItsSecurityBaseComponent, ItsBaseMtc {
port AdapterControlPkiPort acPkiPort; port AdapterControlPkiPort acPkiPort;
......
...@@ -23,42 +23,6 @@ module LibItsPki_TypesAndValues { ...@@ -23,42 +23,6 @@ module LibItsPki_TypesAndValues {
} // End of group constants } // 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 { group utPrimitives {
/** /**
...@@ -110,6 +74,42 @@ module LibItsPki_TypesAndValues { ...@@ -110,6 +74,42 @@ module LibItsPki_TypesAndValues {
variant "" variant ""
} // End of group utPrimitives } // 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 { with {
variant "" variant ""
......