Commit 15ed5690 authored by garciay's avatar garciay
Browse files

STF545: Execute first EA tests

parent aabcd1ce
......@@ -140,15 +140,19 @@ module LibItsCommon_TypesAndValues {
with {
encode "AdapterControl"
}
/**
* @see ETSI TS 102 965 Intelligent Transport Systems (ITS); Application Object Identifier (ITS-AID); Registration list ETSI ITS registration list
*/
group securityConstants {
const integer c_its_aid_CAM := 36;
const integer c_its_aid_DENM := 37;
const integer c_its_aid_SPAT := 137;
const integer c_its_aid_MAP := 138;
const integer c_its_aid_IVI := 139;
const integer c_its_aid_TLC := 140;
const integer c_its_aid_GN := 141;
const integer c_its_aid_TLC := 140;
const integer c_its_aid_GN := 141;
const integer c_its_aid_SCR := 36; // Secured Certificate Request
}
}
with {
......
module LibItsPki_EncdecDeclarations {
// LibIts
import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
// LibIts
import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
import from EtsiTs102941MessagesItss language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
import from LibItsSecurity_TypesAndValues all;
import from LibItsSecurity_TypesAndValues all;
/**
* @desc Encoding function for EtsiTs102941TypesEnrolment InnerEcRequest
* @param p The certificate to encode
* @return The encode message in OER format
*/
external function fx_enc_InnerEcRequest(in EtsiTs102941TypesEnrolment.InnerEcRequest p) return bitstring
with {extension "prototype(convert) encode(PER)"}
external function fx_enc_EtsiTs102941Data(in EtsiTs102941MessagesItss.EtsiTs102941Data p_etsi_ts_102941_data) return bitstring
with {extension "prototype(convert) encode(PER)"}
external function fx_dec_EtsiTs102941Data(inout bitstring b, out EtsiTs102941MessagesItss.EtsiTs102941Data p_etsi_ts_102941_data)return integer
with {extension "prototype(sliding) decode(PER)"}
/**
* @desc Encoding function for EtsiTs102941TypesEnrolment InnerEcRequest
* @param p The certificate to encode
* @return The encode message in OER format
*/
external function fx_enc_InnerEcRequest(in EtsiTs102941TypesEnrolment.InnerEcRequest p) return bitstring
with {extension "prototype(convert) encode(PER)"}
external function fx_dec_InnerEcRequest(inout bitstring b, out EtsiTs102941TypesEnrolment.InnerEcRequest p) return integer
with {extension "prototype(sliding) decode(PER)"}
external function fx_dec_InnerEcRequest(inout bitstring b, out EtsiTs102941TypesEnrolment.InnerEcRequest p) return integer
with {extension "prototype(sliding) decode(PER)"}
/**
* @desc Encoding function for EtsiTs102941TypesEnrolment InnerEcResponse
* @param p The certificate to encode
* @return The encode message in OER format
*/
external function fx_enc_InnerEcResponse(in EtsiTs102941TypesEnrolment.InnerEcResponse p) return bitstring
with {extension "prototype(convert) encode(PER)"}
/**
* @desc Encoding function for EtsiTs102941TypesEnrolment InnerEcResponse
* @param p The certificate to encode
* @return The encode message in OER format
*/
external function fx_enc_InnerEcResponse(in EtsiTs102941TypesEnrolment.InnerEcResponse p) return bitstring
with {extension "prototype(convert) encode(PER)"}
external function fx_dec_InnerEcResponse(inout bitstring b, out EtsiTs102941TypesEnrolment.InnerEcResponse p) return integer
with {extension "prototype(sliding) decode(PER)"}
external function fx_dec_InnerEcResponse(inout bitstring b, out EtsiTs102941TypesEnrolment.InnerEcResponse p) return integer
with {extension "prototype(sliding) decode(PER)"}
} // End of module LibItsPki_EncdecDeclarations
......@@ -29,7 +29,7 @@ module LibItsPki_Functions {
import from CAM_PDU_Descriptions language "ASN.1:1997" all;
// LibItsCommon
import from LibItsCommon_TestSystem all;
import from LibItsCommon_TypesAndValues all;
import from LibItsCommon_Functions all;
import from LibItsCommon_ASN1_NamedNumbers all;
import from LibItsCommon_Pixits all;
......@@ -128,14 +128,14 @@ module LibItsPki_Functions {
group inner_ec_xxx {
function f_generate_innerEcRequestSignedForPop(
out Oct32 p_private_key,
out Oct32 p_publicKeyX,
out Oct32 p_publicKeyY,
out Oct32 p_publicKeyCompressed,
out integer p_compressedMode,
out InnerEcRequest p_inner_ec_request
) return boolean {
function f_generate_inner_ec_request(
out Oct32 p_private_key,
out Oct32 p_publicKeyX,
out Oct32 p_publicKeyY,
out Oct32 p_publicKeyCompressed,
out integer p_compressedMode,
out InnerEcRequest p_inner_ec_request
) return boolean {
// Local variables
var template (value) EccP256CurvePoint v_eccP256_curve_point;
......@@ -152,10 +152,10 @@ module LibItsPki_Functions {
} else {
v_eccP256_curve_point := m_eccP256CurvePoint_compressed_y_1(p_publicKeyCompressed);
}
// Build the Proof of Possession InnerEcRequestSignedForPop
// Build the Proof of Possession InnerEcRequest
p_inner_ec_request := valueof(
m_innerEcRequest(
"CanonicalItsId",
"CanonicalItsId", // TODO Use PIXIT
m_publicKeys(
m_publicVerificationKey_ecdsaNistP256(v_eccP256_curve_point),
m_encryptionKey(
......@@ -165,40 +165,91 @@ module LibItsPki_Functions {
),
m_certificateSubjectAttributes(
{ // ETSI TS 102 965 Table A.1: ETSI ITS standardized ITS-AIDs
valueof(m_appPermissions(36, { bitmapSsp := '830001'O })),
valueof(m_appPermissions(37, { bitmapSsp := '830001'O }))
valueof(m_appPermissions(36, { bitmapSsp := '830001'O })), // TODO Use PIXIT
valueof(m_appPermissions(37, { bitmapSsp := '830001'O })) // TODO Use PIXIT
},
m_validityPeriod(
17469212,
m_duration_years(10)
m_duration_years(10) // TODO Use PIXIT
),
m_geographicRegion_identifiedRegion(
{
m_identifiedRegion_country_only(12),
m_identifiedRegion_country_only(34)
m_identifiedRegion_country_only(12), // TODO Use PIXIT
m_identifiedRegion_country_only(34) // TODO Use PIXIT
}
),
'C0'O
'C0'O // TODO Use PIXIT
)
)
);
);
return true;
} // End of function f_generate_innerEcRequestSignedForPop
} // End of function f_generate_inner_ec_request
function f_buildPkiSecuredinnerEcRequestSignedForPop(
in Oct32 p_private_key,
in Oct32 p_publicKeyCompressed,
in integer p_compressedMode,
in InnerEcRequest p_inner_ec_request,
out Ieee1609Dot2Data p_ieee1609dot2_signed_and_encrypted_data
function f_generate_inner_ec_request_signed_for_pop(
in Oct32 p_private_key,
in InnerEcRequest p_inner_ec_request,
out Ieee1609Dot2Data p_inner_ec_request_signed_for_pop
) return boolean {
// Local variables
var template (value) EccP256CurvePoint v_eccP256_curve_point;
var octetstring v_encoded_inner_ec_request;
var template (value) ToBeSignedData v_tbs;
var Oct32 v_tbs_signed;
// Encode it
v_encoded_inner_ec_request := bit2oct(encvalue(p_inner_ec_request));
// Signed the encoded InnerEcRequestSignedForPop
v_tbs := m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(
v_encoded_inner_ec_request
)
),
m_headerInfo_inner_ec_request(
c_its_aid_SCR,
f_getCurrentTime())
);
// Signed the encoded InnerEcRequestSignedForPop
v_tbs_signed := f_signWithEcdsaNistp256WithSha256(bit2oct(encvalue(v_tbs)), int2oct(0, 32), p_private_key);
// Finalyse signed InnerEcRequestSignedForPop
p_inner_ec_request_signed_for_pop := valueof(
m_etsiTs103097Data_signed(
m_signedData(
sha256,
v_tbs,
m_signerIdentifier_self,
m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
substr(v_tbs_signed, 0, 32)
),
substr(v_tbs_signed, 32, 32)
)
)
)
)
);
return true;
} // End of function f_generate_inner_ec_request_signed_for_pop
} // End of group inner_ec_xxx
group pki_functions {
function f_build_pki_secured_message(
in Oct32 p_private_key,
in Oct32 p_publicKeyCompressed,
in integer p_compressedMode,
in octetstring p_pki_message,
out Ieee1609Dot2Data p_ieee1609dot2_signed_and_encrypted_data
) return boolean {
// Local variables
var template (value) EccP256CurvePoint v_eccP256_curve_point;
var template (value) ToBeSignedData v_tbs;
var Oct32 v_tbs_signed;
var template (value) Ieee1609Dot2Data v_ieee1609dot2_signed_data;
var octetstring v_encoded_inner_ec_request;
var Oct12 v_nonce;
var Oct16 v_authentication_vector;
var Oct16 v_encrypted_sym_key;
......@@ -207,12 +258,10 @@ module LibItsPki_Functions {
var HashedId8 v_recipientId;
var octetstring v_encrypted_inner_ec_request;
// Encode it
v_encoded_inner_ec_request := bit2oct(encvalue(p_inner_ec_request));
// Signed the encoded InnerEcRequestSignedForPop
v_tbs := m_toBeSignedData(
m_signedDataPayload(
m_etsiTs103097Data_unsecured(v_encoded_inner_ec_request)
m_etsiTs103097Data_unsecured(p_pki_message)
),
m_headerInfo_inner_ec_request(12345, f_getCurrentTime()) // TODO Use PIXIT
);
......@@ -223,7 +272,7 @@ module LibItsPki_Functions {
m_signedData(
sha256,
v_tbs,
m_signerIdentifier_self,
m_signerIdentifier_self, // TODO ETSI TS 102 941 Clause 6.2.3.2.1 bullet 5 dash 3: Using disgest of EC if non canonical indentifier
m_signature_ecdsaNistP256(
m_ecdsaP256Signature(
m_eccP256CurvePoint_x_only(
......@@ -270,7 +319,25 @@ module LibItsPki_Functions {
);
return true;
} // End of function f_buildPkiSecuredinnerEcRequestSignedForPop
} // End of function f_build_pki_secured_message
function f_generate_inner_ec_response(
in Oct32 p_inner_ec_request_hashed_id,
in EtsiTs103097Certificate p_certificate,
out InnerEcResponse p_inner_ec_response
) return boolean {
// Local variables
// Build the Proof of Possession InnerEcResponse
p_inner_ec_response := valueof(
m_innerEcResponse_ok(
substr(p_inner_ec_request_hashed_id, 0, 16),
p_certificate
)
);
return true;
} // End of function f_generate_inner_ec_response
} // End of group inner_ec_xxx
......
......@@ -10,127 +10,156 @@
*
*/
module LibItsPki_Templates {
// LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
// LibItsCommon
import from LibItsCommon_TypesAndValues all;
import from LibItsCommon_Functions all;
import from LibItsCommon_TypesAndValues all;
import from LibItsCommon_ASN1_NamedNumbers all;
// LibIts
import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
import from IEEE1609dot2 language "ASN.1:1997" all;
import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
import from EtsiTs102941MessagesItss language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
// LibItsSecurity
import from LibItsSecurity_Templates all;
template (value) EnrolmentRequestMessage m_enrolmentRequestMessage(
in template (value) EncryptedData p_encryptedData
) modifies m_etsiTs103097Data_encrypted := {
} // End of template m_enrolmentRequestMessage
template (present) EnrolmentRequestMessage mw_enrolmentResponseMessage(
template (present) EncryptedData p_encryptedData := ?
) modifies mw_etsiTs103097Data_encrypted := {
} // End of template mw_enrolmentResponseMessage
template (value) EtsiTs102941DataContent m_enrolmentRequest(
in template (value) InnerEcRequestSignedForPop p_enrolmentRequest
) := {
enrolmentRequest := p_enrolmentRequest
} // End of template m_enrolmentRequest
template (present) EtsiTs102941DataContent mw_enrolmentResponse(
template (present) InnerEcResponse p_enrolmentResponse := ?
) := {
enrolmentResponse := p_enrolmentResponse
} // End of template mw_enrolmentResponse
template (value) InnerEcRequest m_innerEcRequest(
in template (value) charstring p_itsId,
in template (value) PublicKeys p_publicKeys,
in template (value) CertificateSubjectAttributes p_requestedSubjectAttributes //(WITH COMPONENTS{certIssuePermissions ABSENT}),
) := {
itsId := p_itsId,
certificateFormat := 1,
publicKeys := p_publicKeys,
requestedSubjectAttributes := p_requestedSubjectAttributes
} // End of template m_innerEcRequest
template (omit) PublicKeys m_publicKeys(
in template (value) PublicVerificationKey p_verificationKey,
in template (omit) PublicEncryptionKey p_encryptionKey := omit
) := {
verificationKey := p_verificationKey,
encryptionKey := p_encryptionKey
} // End of template m_publicKeys
template PublicKeys mw_publicKeys(
template (present) PublicVerificationKey p_verificationKey := ?,
template PublicEncryptionKey p_encryptionKey := *
) := {
verificationKey := p_verificationKey,
encryptionKey := p_encryptionKey
} // End of template mw_publicKeys
template (omit) CertificateSubjectAttributes m_certificateSubjectAttributes(
in template (value) SequenceOfPsidSsp p_appPermissions,
in template (omit) ValidityPeriod p_validityPeriod := omit,
in template (omit) GeographicRegion p_region := omit,
in template (omit) SubjectAssurance p_assuranceLevel := omit
) := {
id := { none_ := NULL },
validityPeriod := p_validityPeriod,
region := p_region,
assuranceLevel := p_assuranceLevel,
appPermissions := p_appPermissions,
certIssuePermissions := omit
} // End of template m_certificateSubjectAttributes
// LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
// LibItsCommon
import from LibItsCommon_TypesAndValues all;
import from LibItsCommon_Functions all;
import from LibItsCommon_TypesAndValues all;
import from LibItsCommon_ASN1_NamedNumbers all;
// LibIts
import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
import from IEEE1609dot2 language "ASN.1:1997" all;
import from EtsiTs102941BaseTypes language "ASN.1:1997" all;
import from EtsiTs102941TypesEnrolment language "ASN.1:1997" all;
import from EtsiTs102941MessagesItss language "ASN.1:1997" all;
import from EtsiTs103097Module language "ASN.1:1997" all;
// LibItsSecurity
import from LibItsSecurity_Templates all;
template (value) InnerEcResponse m_innerEcResponse_ok(
in template (value) Oct16 p_requestHash,
in template (value) EtsiTs103097Certificate p_certificate
) := {
requestHash := p_requestHash,
responseCode := ok,
certificate := p_certificate
} // End of template m_innerEcResponse_ok
template (present) InnerEcResponse mw_innerEcResponse_ok(
template (present) Oct16 p_requestHash := ?,
template (present) EtsiTs103097Certificate p_certificate := ?
) := {
requestHash := p_requestHash,
responseCode := ok,
certificate := p_certificate
} // End of template mw_innerEcResponse_ok
template (value) InnerEcResponse m_innerEcResponse_ko(
in template (value) Oct16 p_requestHash,
in template (value) EnrolmentResponseCode p_responseCode
) := {
requestHash := p_requestHash,
responseCode := p_responseCode,
certificate := omit
} // End of template m_innerEcResponse_ko
template (present) InnerEcResponse mw_innerEcResponse_ko(
template (present) Oct16 p_requestHash := ?,
template (present) EnrolmentResponseCode p_responseCode := complement(ok)
) := {
requestHash := p_requestHash,
responseCode := p_responseCode,
certificate := *
} // End of template mw_innerEcResponse_ko
} // End of module LibItsPki_Templates
\ No newline at end of file
template (value) EtsiTs102941Data m_etsiTs102941Data_inner_ec_request_signed_for_pop(
in template (value) InnerEcRequestSignedForPop p_inner_ec_request_signed_for_pop
) := {
version := 1,
content := {
enrolmentRequest := p_inner_ec_request_signed_for_pop
}
} // End of template m_etsiTs102941Data_inner_ec_request_signed_for_pop
template (value) EtsiTs102941Data m_etsiTs102941Data_inner_ec_response(
in template (value) InnerEcResponse p_inner_ec_response
) := {
version := 1,
content := {
enrolmentResponse := p_inner_ec_response
}
} // End of template m_etsiTs102941Data_inner_ec_response
template (value) EnrolmentRequestMessage m_enrolmentRequestMessage(
in template (value) EncryptedData p_encryptedData
) modifies m_etsiTs103097Data_encrypted := {
} // End of template m_enrolmentRequestMessage
template (present) EnrolmentRequestMessage mw_enrolmentResponseMessage(
template (present) EncryptedData p_encryptedData := ?
) modifies mw_etsiTs103097Data_encrypted := {
} // End of template mw_enrolmentResponseMessage
template (value) EtsiTs102941DataContent m_enrolmentRequest(
in template (value) InnerEcRequestSignedForPop p_enrolmentRequest
) := {
enrolmentRequest := p_enrolmentRequest
} // End of template m_enrolmentRequest
template (present) EtsiTs102941DataContent mw_enrolmentResponse(
template (present) InnerEcResponse p_enrolmentResponse := ?
) := {
enrolmentResponse := p_enrolmentResponse
} // End of template mw_enrolmentResponse
template (value) InnerEcRequest m_innerEcRequest(
in template (value) charstring p_itsId,
in template (value) PublicKeys p_publicKeys,
in template (value) CertificateSubjectAttributes p_requestedSubjectAttributes
) := {
itsId := p_itsId,
certificateFormat := 1,
publicKeys := p_publicKeys,
requestedSubjectAttributes := p_requestedSubjectAttributes
} // End of template m_innerEcRequest
template (present) InnerEcRequest mw_innerEcRequest(
template (present) charstring p_itsId := ?,
template (present) PublicKeys p_publicKeys := ?,
template (present) CertificateSubjectAttributes p_requestedSubjectAttributes := ?
) := {
itsId := p_itsId,
certificateFormat := 1,
publicKeys := p_publicKeys,
requestedSubjectAttributes := p_requestedSubjectAttributes
} // End of template mw_innerEcRequest
template (omit) PublicKeys m_publicKeys(
in template (value) PublicVerificationKey p_verificationKey,
in template (omit) PublicEncryptionKey p_encryptionKey := omit
) := {
verificationKey := p_verificationKey,
encryptionKey := p_encryptionKey
} // End of template m_publicKeys
template PublicKeys mw_publicKeys(
template (present) PublicVerificationKey p_verificationKey := ?,
template PublicEncryptionKey p_encryptionKey := *
) := {
verificationKey := p_verificationKey,
encryptionKey := p_encryptionKey
} // End of template mw_publicKeys
template (omit) CertificateSubjectAttributes m_certificateSubjectAttributes(
in template (value) SequenceOfPsidSsp p_appPermissions,
in template (omit) ValidityPeriod p_validityPeriod := omit,
in template (omit) GeographicRegion p_region := omit,
in template (omit) SubjectAssurance p_assuranceLevel := omit
) := {
id := { none_ := NULL },
validityPeriod := p_validityPeriod,
region := p_region,
assuranceLevel := p_assuranceLevel,
appPermissions := p_appPermissions,
certIssuePermissions := omit
} // End of template m_certificateSubjectAttributes
template (value) InnerEcResponse m_innerEcResponse_ok(
in template (value) Oct16 p_requestHash,
in template (value) EtsiTs103097Certificate p_certificate
) := {
requestHash := p_requestHash,
responseCode := ok,
certificate := p_certificate
} // End of template m_innerEcResponse_ok
template (present) InnerEcResponse mw_innerEcResponse_ok(
template (present) Oct16 p_requestHash := ?,
template (present) EtsiTs103097Certificate p_certificate := ?
) := {
requestHash := p_requestHash,
responseCode := ok,
certificate := p_certificate
} // End of template mw_innerEcResponse_ok
template (value) InnerEcResponse m_innerEcResponse_ko(
in template (value) Oct16 p_requestHash,
in template (value) EnrolmentResponseCode p_responseCode
) := {
requestHash := p_requestHash,
responseCode := p_responseCode,
certificate := omit
} // End of template m_innerEcResponse_ko
template (present) InnerEcResponse mw_innerEcResponse_ko(
template (present) Oct16 p_requestHash := ?,
template (present) EnrolmentResponseCode p_responseCode := complement(ok)
) := {
requestHash := p_requestHash,
responseCode := p_responseCode,
certificate := *
} // End of template mw_innerEcResponse_ko
} // End of module LibItsPki_Templates
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