Commit 65fa3f87 authored by garciay's avatar garciay
Browse files

Start Security support

Add Service Advertisement support
parent 06138be7
......@@ -840,4 +840,12 @@ module ItsRSUsSimulator_Functions {
return vc_sequenceNumber;
}
function f_payload_template(
in integer p_dest_port,
in integer p_src_port
) return template (present) octetstring {
template (present) octetstring v_out :=
int2oct(PICS_SREM_BTP_DESTINATION_PORT, 2) & int2oct(PICS_SREM_BTP_SOURCE_PORT, 2) & ? length (1 .. 65535);
return v_out
}
} // End of module ItsRSUsSimulator_Functions
......@@ -124,10 +124,7 @@ module ItsRSUsSimulator_Templates {
in template (present) UInt16 p_seqNumber := ?,
in template (present) NextHeader p_nextHeader := ?
) modifies mw_geoNwBroadcastPacketWithNextHeader := {
payload :=
int2oct(PICS_SREM_BTP_DESTINATION_PORT, 2) &
int2oct(PICS_SREM_BTP_SOURCE_PORT, 2) &
'*'O
payload := f_payload_template(PICS_SREM_BTP_DESTINATION_PORT, PICS_SREM_BTP_SOURCE_PORT)
}
/**
......@@ -141,10 +138,7 @@ module ItsRSUsSimulator_Templates {
in template (present) LongPosVector p_sourceLongPosVec := ?,
in template (value) NextHeader p_nextHeader
) modifies mw_geoNwTsbPacketWithNextHeader := {
payload :=
int2oct(PICS_SREM_BTP_DESTINATION_PORT, 2) &
int2oct(PICS_SREM_BTP_SOURCE_PORT, 2) &
'?'O
payload := f_payload_template(PICS_SREM_BTP_DESTINATION_PORT, PICS_SREM_BTP_SOURCE_PORT)
}
/**
......@@ -157,10 +151,7 @@ module ItsRSUsSimulator_Templates {
in template (present) UInt16 p_seqNumber := ?,
in template (present) LongPosVector p_sourceLongPosVec := ?
) modifies mw_geoNwTsbPacket := {
payload :=
int2oct(PICS_DENM_BTP_DESTINATION_PORT, 2) &
int2oct(PICS_DENM_BTP_SOURCE_PORT, 2) &
'?'O
payload := f_payload_template(PICS_DENM_BTP_DESTINATION_PORT, PICS_DENM_BTP_SOURCE_PORT)
} // End of template mw_geoNwTsbPacketWithNextHeader_denm
/**
......@@ -175,10 +166,7 @@ module ItsRSUsSimulator_Templates {
in template (present) NextHeader p_nextHeader,
in template (present) CAM p_cam := ?
) modifies mw_geoNwShbPacket := {
payload :=
int2oct(PICS_CAM_BTP_DESTINATION_PORT, 2) &
int2oct(PICS_CAM_BTP_SOURCE_PORT, 2) &
'?'O
payload := f_payload_template(PICS_CAM_BTP_DESTINATION_PORT, PICS_CAM_BTP_SOURCE_PORT)
} // End of template mw_geoNwShbPacketWithNextHeader_cam
} // End of group geoNetworkingTemplates
......
......@@ -14,6 +14,7 @@ module ItsRSUsSimulator_TypesAndValues {
import from EVCSN_PDU_Descriptions language "ASN.1:1997" all;
import from SSEM_PDU_Descriptions language "ASN.1:1997" all;
import from DSRC language "ASN.1:1997" all;
import from DSRC_REGION_noCircular language "ASN.1:1997" all;
import from EfcDsrcApplication language "ASN.1:1997" all;
// LibItsGeoNetworking
......
......@@ -37,6 +37,12 @@ module TestCodec_Certificates {
signature_ := omit
} // End of template m_etsiTs103097Certificate
template (value) IssuerIdentifier m_issuerIdentifier_self(
in template (value) HashAlgorithm p_self
) := {
self_ := p_self
} // End of template m_issuerIdentifier_self
template (value) IssuerIdentifier m_issuerIdentifier_sha256AndDigest(
in template (value) HashedId8 p_sha256AndDigest
) := {
......@@ -53,11 +59,11 @@ module TestCodec_Certificates {
in template (value) CertificateId p_id,
in template (value) HashedId3 p_cracaId,
in template (value) CrlSeries p_crlSeries,
in template (value) ValidityPeriod p_validityPeriod,
in template (value) SequenceOfPsidSsp p_appPermissions,
in template (value) SequenceOfPsidGroupPermissions p_certIssuePermissions,
in template (value) SequenceOfPsidGroupPermissions p_certRequestPermissions,
in template (value) VerificationKeyIndicator p_verifyKeyIndicator,
in template (omit) ValidityPeriod p_validityPeriod := omit,
in template (omit) GeographicRegion p_region := omit,
in template (omit) SubjectAssurance p_assuranceLevel := omit,
in template (omit) PublicEncryptionKey p_encryptionKey := omit
......@@ -84,13 +90,13 @@ module TestCodec_Certificates {
duration := p_duration
} // End of template m_validity_period
template (omit) PsidSsp m_psidSsp(
template (omit) PsidSsp m_appPermissions(
in template (value) Psid p_psid,
in template (omit) ServiceSpecificPermissions p_ssp := omit
) := {
psid := p_psid,
ssp := p_ssp
} // End of template m_psidSsp
} // End of template m_appPermissions
template (omit) PsidSspRange m_psidSspRange(
in Psid p_psid,
......@@ -143,28 +149,40 @@ module TestCodec_Certificates {
} // End of template m_eccP256CurvePoint_compressed_y_0
testcase tc_certificate_1() runs on TCType system TCType {
var template (value) EtsiTs103097Certificate v_cert;
var HashedId8 v_sha256AndDigest := '0000000000000000'O;
var HashedId3 v_cracaId := '000000'O;
var CrlSeries v_crlSeries := 0;
var SequenceOfPsidSspRange v_certIssuePermissions := { valueof(m_psidSspRange(1)) };
var SequenceOfPsidSspRange v_certRequestPermissions := { valueof(m_psidSspRange(2)) };
var template (value) EtsiTs103097Certificate v_cert; // ETSI TS 103 097 V1.3.1 Clause 6 Bullet 1
var charstring v_certId := "STF528 Root Certificate";
var HashAlgorithm v_self := sha256; // ETSI TS 103 097 V1.3.1 Clause 7.2.3 Root CA certificates Bullet 1
var HashedId3 v_cracaId := '000000'O; // ETSI TS 103 097 V1.3.1 Clause 6 Bullet 2
var CrlSeries v_crlSeries := 0; // ETSI TS 103 097 V1.3.1 Clause 6 Bullet 3
var SequenceOfPsidSsp v_appPermissions := { // ETSI TS 102 965 Table A.1: ETSI ITS standardized ITS-AIDs
valueof(m_appPermissions(36, { bitmapSsp := '001100110011'O })),
valueof(m_appPermissions(37, { bitmapSsp := '001100110011'O }))
};
var SequenceOfPsidSspRange v_certIssuePermissions := { // ETSI TS 103 097 V1.3.1 Clause 7.2.3 Root CA certificates Bullet 3
valueof(m_psidSspRange(1)) // FIXME What is the content of certIssuePermissions?
};
var SequenceOfPsidSspRange v_certRequestPermissions := { // FIXME Could this componet be present? If yes, What is the content of certIssuePermissions?
valueof(m_psidSspRange(2))
};
var Oct32 v_compressed_y_0 := '0000000000000000000000000000000000000000000000000000000000000000'O;
var HashedId8 v_sha256AndDigest;
var bitstring v_encMsg;
var integer v_res := 0;
var bitstring v_expEncMsg := oct2bit('310020'O);
// Generate Private/Public keys
var Oct32 private_key;
//f_generate_keys_pair(private_key, v_compressed_y_0, "compressed-y-0");
// Store Private key in binary format
//f_save_key(private_key);
// Fill Certificate template with the public key
v_cert := m_etsiTs103097Certificate(
m_issuerIdentifier_sha256AndDigest(v_sha256AndDigest),
m_issuerIdentifier_self(v_self),
m_toBeSignedCertificate(
{ name := "tc_certificate_1" },
{ name := v_certId },
v_cracaId,
v_crlSeries,
m_validity_period(0, { milliseconds := 1000 }),
{
m_psidSsp(1),
m_psidSsp(2, { bitmapSsp := '001100110011'O })
},
v_appPermissions,
{
m_PsidGroupPermissions(
m_subjectPermissions_explicit(
......@@ -184,21 +202,15 @@ module TestCodec_Certificates {
)))
)
);
// Encode template
// Encode it ==> Get octetstring
log("Encode template ", valueof(v_cert));
v_encMsg := encvalue(v_cert);
log("Encoded message: ", bit2oct(v_encMsg));
// Check result
if (not isbound(v_encMsg)) {
setverdict(fail, "Encoding failed!");
stop;
}
if (not match(v_encMsg, v_expEncMsg)) {
log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
setverdict(fail, "Encoding failed, not the expected result!");
stop;
}
// Update v_sha256AndDigest
//f_hashWithSha256(bit2oct(v_encMsg));
//f_HashedId8FromSha256();
// Sign the certificate
//f_signWithEcdsaNistp256WithSha256();
setverdict(pass, "Encoding passed.");
} // End of testcase tc_certificate_1
......
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