Commit 368ce917 authored by garciay's avatar garciay
Browse files

STF545: Update test case to push security staff in the Test System

parent c7d6717d
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
/** /**
* @author ETSI / STF544 * @author ETSI / STF544
* @version $URL$ * @version $URL$
* $Id$ * $Id$
* @desc Module containing functions for ITS PKI ATS * @desc Module containing functions for ITS PKI ATS
* @copyright ETSI Copyright Notification * @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission. * No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media. * The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved. * All rights reserved.
* *
*/ */
module ItsPki_Functions { module ItsPki_Functions {
// LibCommon // LibCommon
import from LibCommon_BasicTypesAndValues all; import from LibCommon_BasicTypesAndValues all;
import from LibCommon_Time all; import from LibCommon_Time 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;
import from EtsiTs102941BaseTypes language "ASN.1:1997" all; import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all; import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
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;
// LibItsCommon // LibItsCommon
import from LibItsCommon_TestSystem all; import from LibItsCommon_TestSystem all;
import from LibItsCommon_Functions all; import from LibItsCommon_Functions all;
import from LibItsCommon_ASN1_NamedNumbers all; import from LibItsCommon_ASN1_NamedNumbers all;
// LibItsGeoNetworking // LibItsGeoNetworking
//import from LibItsGeoNetworking_Functions all; //import from LibItsGeoNetworking_Functions all;
//import from LibItsGeoNetworking_Templates all; //import from LibItsGeoNetworking_Templates all;
//import from LibItsGeoNetworking_TypesAndValues all; //import from LibItsGeoNetworking_TypesAndValues 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;
// LibItsHttp // LibItsHttp
import from LibItsHttp_TypesAndValues all; import from LibItsHttp_TypesAndValues all;
import from LibItsHttp_Templates all; import from LibItsHttp_Templates all;
import from LibItsHttp_BinaryTemplates all; import from LibItsHttp_BinaryTemplates all;
import from LibItsHttp_Functions all; import from LibItsHttp_Functions all;
// LibItsPki // LibItsPki
import from LibItsPki_Templates all; import from LibItsPki_Templates all;
import from LibItsPki_TestSystem all; import from LibItsPki_TestSystem all;
function f_sendEnrollmentRequest(
in template (value) InnerEcRequest p_innerEcRequest,
in charstring p_configId,
in template (value) HeaderInfo p_headerInfo,
in SignerIdentifier p_signerIdentifier
) runs on ItsPki {
// Local variables
var octetstring v_encMsg;
var octetstring v_raw_payload_to_be_signed;
var EtsiTs103097Data v_securedMessage := {};
var HeaderLines v_headers;
// Encode the unsecured payload
v_encMsg := bit2oct(encvalue(valueof(p_innerEcRequest)));
v_raw_payload_to_be_signed := bit2oct(encvalue(valueof(p_innerEcRequest)));
// Build signed Ieee1609Dot2Data
f_buildSecuredPki(
v_securedMessage,
valueof(m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(
v_raw_payload_to_be_signed
)),
p_headerInfo
)),
p_signerIdentifier,
p_configId
);
// Send HTTP request
v_encMsg := bit2oct(encvalue(v_securedMessage));
f_init_default_headers_list(v_headers);
httpPort.send(m_http_request(m_http_request_post("/", v_headers, m_http_message_body_binary(m_binary_body_raw(v_encMsg)))));
}
function f_buildSecuredPki(
inout EtsiTs103097Data p_securedMessage,
in ToBeSignedData p_payloadField,
in SignerIdentifier p_signerIdentifierType,
in charstring p_certificateName := ""/*,
in boolean p_addMissingHeaders := true*/
) runs on ItsPki return boolean {
// Local variables
var EtsiTs103097Certificate v_aaCertificate, v_atCertificate;
// Load certificates if required
if (f_prepareCertificates(p_certificateName, v_aaCertificate, v_atCertificate) == false) {
return false;
}
//log("f_buildSecuredPki: v_atCertificate = ", v_atCertificate);
// Fill the structure with default values, these values will be updated later
p_securedMessage := valueof(m_etsiTs103097Data_signed(
m_signedData(
sha256,
p_payloadField,
m_signerIdentifier_self,
m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(int2oct(0, 32)),
int2oct(0, 32)
)
)
)
));
// Prepare mandatory headers
//log("f_buildSecuredPki: p_signerIdentifierType=", p_signerIdentifierType);
if (ischosen(p_signerIdentifierType.certificate)) { // Add the AT certificate
log("*** " & testcasename() & "f_buildSecuredPki: TODO ***");
stop;
/* TODO
* v_signerInfo := valueof(
m_header_info_signer_info(
m_signerIdentifier_certificate(
v_atCertificate
)));
} else if (valueof(p_signerIdentifierType) == e_certificate_chain) { // Add the AT certificate + AA EtsiTs103097Certificate
v_signerInfo := valueof(
m_header_info_signer_info(
m_signerIdentifier_certificates(
{
v_aaCertificate,
v_atCertificate
}
)
));*/
} else if (ischosen(p_signerIdentifierType.digest)) { // Add the AT certificate digest
if (ischosen(v_atCertificate.issuer.sha256AndDigest)) {
p_securedMessage.content.signedData.hashId := sha256;
p_securedMessage.content.signedData.signer := valueof(m_signerIdentifier_digest(
f_calculateDigestSha256FromCertificate(v_atCertificate)
));
} else if (ischosen(v_atCertificate.issuer.sha384AndDigest)) {
p_securedMessage.content.signedData.hashId := sha384;
p_securedMessage.content.signedData.signer := valueof(m_signerIdentifier_digest(
f_calculateDigestSha384FromCertificate(v_atCertificate)
));
}
} else {
log("*** " & testcasename() & "f_buildSecuredPki: TODO ***");
stop;
}
if (ispresent(v_atCertificate.signature_)) {
if (ischosen(v_atCertificate.signature_.ecdsaBrainpoolP256r1Signature)) {
p_securedMessage.content.signedData.signature_ := valueof(m_signature_ecdsaBrainpoolP256r1(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(int2oct(0, 32)),
int2oct(0, 32)
)
));
} else if (ischosen(v_atCertificate.signature_.ecdsaBrainpoolP384r1Signature)) {
p_securedMessage.content.signedData.signature_ := valueof(m_signature_ecdsaBrainpoolP384r1(
m_ecdsaP384Signature(
m_eccP384CurvePoint_x_only(int2oct(0, 48)),
int2oct(0, 48)
)
));
} // else, m_signature_ecdsaNistP256 already chosen by default
}
log("f_buildSecuredPki: p_securedMessage = ", p_securedMessage);
return true;
} // End of function f_buildSecuredPki
} // End of module ItsPki_Functions } // End of module ItsPki_Functions
\ No newline at end of file
/** /**
* @author ETSI / STF545 * @author ETSI / STF545
* @version $URL$ * @version $URL$
* $Id$ * $Id$
* @desc Testcases file for Security Protocol * @desc Testcases file for Security Protocol
* @reference ETSI TS 103 097 v1.2.1 * @reference ETSI TS 103 097 v1.2.1
* @copyright ETSI Copyright Notification * @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission. * No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media. * The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved. * All rights reserved.
*/ */
module ItsPki_TestCases { module ItsPki_TestCases {
// Libcommon // Libcommon
import from LibCommon_Time all; import from LibCommon_Time all;
import from LibCommon_VerdictControl all; import from LibCommon_VerdictControl all;
import from LibCommon_Sync all; import from LibCommon_Sync all;
import from LibCommon_BasicTypesAndValues all; import from LibCommon_BasicTypesAndValues 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;
import from EtsiTs102941BaseTypes language "ASN.1:1997" all; import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all; import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
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;
// LibItsCommon // LibItsCommon
import from LibItsCommon_TypesAndValues all; import from LibItsCommon_TypesAndValues all;
import from LibItsCommon_Functions all; import from LibItsCommon_Functions all;
import from LibItsCommon_TypesAndValues all; import from LibItsCommon_TypesAndValues all;
import from LibItsCommon_ASN1_NamedNumbers all; import from LibItsCommon_ASN1_NamedNumbers all;
// LibItsGeoNetworking // LibItsGeoNetworking
import from LibItsGeoNetworking_TypesAndValues all; import from LibItsGeoNetworking_TypesAndValues all;
import from LibItsGeoNetworking_Functions all; import from LibItsGeoNetworking_Functions all;
import from LibItsGeoNetworking_Templates all; import from LibItsGeoNetworking_Templates all;
import from LibItsGeoNetworking_Pics all; import from LibItsGeoNetworking_Pics all;
// LibItsCam // LibItsCam
import from LibItsCam_Templates all; import from LibItsCam_Templates all;
import from LibItsCam_TestSystem all; import from LibItsCam_TestSystem all;
// LibItsDenm // LibItsDenm
import from LibItsDenm_Templates all; import from LibItsDenm_Templates all;
import from LibItsDenm_TestSystem all; import from LibItsDenm_TestSystem all;
// LibItsSecurity // LibItsSecurity
import from LibItsSecurity_TypesAndValues all; import from LibItsSecurity_TypesAndValues all;
import from LibItsSecurity_TestSystem all; import from LibItsSecurity_TestSystem 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_Pics all; import from LibItsSecurity_Pics all;
// LibItsHttp // LibItsHttp
import from LibItsHttp_Templates all; import from LibItsHttp_TypesAndValues all;
import from LibItsHttp_BinaryTemplates all; import from LibItsHttp_Templates all;
import from LibItsHttp_BinaryTemplates all;
// LibItsPki import from LibItsHttp_Functions all;
import from LibItsPki_Templates all;
import from LibItsPki_TestSystem all; // LibItsPki
import from LibItsPki_Templates all;
// AtsPki import from LibItsPki_TestSystem all;
import from ItsPki_Functions all;
// AtsPki
testcase TC_SEC_PKI_SND_EA_01_BV() runs on ItsPki system ItsPkiSystem { import from ItsPki_Functions all;
// Local variables testcase TC_SEC_PKI_SND_EA_01_BV() runs on ItsPki system ItsPkiSystem {
var LongPosVector v_longPosVectorIut;
var GeoNetworkingPdu v_securedGnPdu; // Local variables
var GnRawPayload v_sentRawPayload; var EtsiTs103097Certificate v_certificate;
var EtsiTs103097Certificate v_certificate; var HeaderLines v_headers;
// Test control // Test control
if (not(PICS_GN_SECURITY)) { if (not(PICS_GN_SECURITY)) {
log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***"); log("*** " & testcasename() & ":ERROR: 'PICS_GN_SECURITY' required for executing the TC ***");
stop; stop;
} }
// Test component configuration // Test component configuration
vc_hashedId8ToBeUsed := "CERT_IUT_F_AT"; vc_hashedId8ToBeUsed := "CERT_IUT_F_AT";
f_cf01Up(); // Initialise IUT with CERT_IUT_F_AT signed with CERT_IUT_F_AA f_cf01Up(); // Initialise IUT with CERT_IUT_F_AT signed with CERT_IUT_F_AA
v_longPosVectorIut := f_getPosition(c_compIut);
log("v_longPosVectorIut = ", v_longPosVectorIut); // Test adapter configuration
f_readCertificate(vc_hashedId8ToBeUsed, v_certificate);
// Preamble
// Test adapter configuration f_prNeighbour();
f_readCertificate(vc_hashedId8ToBeUsed, v_certificate);
// Preamble f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
f_prNeighbour();
f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success); // Test Body
f_init_default_headers_list(v_headers);
// Test Body httpPort.send(
f_sendEnrollmentRequest( m_http_request(
m_innerEcRequest( m_http_request_post(
"TODO", "/",
m_publicKeys( v_headers,
v_certificate.toBeSigned.verifyKeyIndicator.verificationKey, m_http_message_body_binary(
v_certificate.toBeSigned.encryptionKey m_binary_body_innerEcRequest(
), m_innerEcRequest(
m_certificateSubjectAttributes( "TODO",
v_certificate.toBeSigned.appPermissions, m_publicKeys(
v_certificate.toBeSigned.validityPeriod, v_certificate.toBeSigned.verifyKeyIndicator.verificationKey,
v_certificate.toBeSigned.region, v_certificate.toBeSigned.encryptionKey
v_certificate.toBeSigned.assuranceLevel ),
m_certificateSubjectAttributes(
)), v_certificate.toBeSigned.appPermissions,
cc_taCert_A, v_certificate.toBeSigned.validityPeriod,
valueof(m_headerInfo_gn(-, f_computeGnTimestamp())), v_certificate.toBeSigned.region,
valueof(m_signerIdentifier_digest) v_certificate.toBeSigned.assuranceLevel
); )))))));
tc_ac.start; tc_ac.start;
alt { alt {
[] httpPort.receive( [] httpPort.receive(
mw_http_response( mw_http_response(
mw_http_response_ok( mw_http_response_ok(
mw_http_message_body_binary( mw_http_message_body_binary(
mw_binary_body_raw mw_binary_body_innerEcResponse(
/*mw_geoNwSecPdu( mw_innerEcResponse_ok
mw_etsiTs103097Data_signed( ))))) {
mw_innerEcResponse()))*/ tc_ac.stop;
)))) { log("*** " & testcasename() & ": PASS: Security protocol version set to 3 ***");
tc_ac.stop; f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
log("*** " & testcasename() & ": PASS: Security protocol version set to 3 ***"); }
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); [] tc_ac.timeout {
} log("*** " & testcasename() & ": INCONC: Expected message not received ***");
[] tc_ac.timeout { f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
log("*** " & testcasename() & ": INCONC: Expected message not received ***"); }
f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout); } // End of 'alt' statement
}
} // End of 'alt' statement // Postamble
f_poNeighbour();
// Postamble f_cf01Down();
f_poNeighbour();
f_cf01Down(); } // End of testcase TC_SEC_ITSS_SND_MSG_01_BV
} // End of testcase TC_SEC_ITSS_SND_MSG_01_BV
} // End of module ItsPki_TestCases } // End of module ItsPki_TestCases
\ No newline at end of file
Subproject commit 10d0d81a0b08db8b53ae74072a528dd0333e4dd7 Subproject commit 00f08fdf2fa8be4f21163899b4b419868d85011e
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