Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ITS - Intelligent Transport Systems
ITS
Commits
af17db64
Commit
af17db64
authored
Jun 04, 2018
by
garciay
Browse files
Finalyse first PKI TC
parent
92780b6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
ttcn/AtsPki/ItsPki_Functions.ttcn
View file @
af17db64
...
...
@@ -48,58 +48,150 @@ module ItsPki_Functions {
import
from
LibItsSecurity_TypesAndValues
all
;
import
from
LibItsSecurity_Templates
all
;
import
from
LibItsSecurity_Functions
all
;
import
from
LibItsSecurity_TestSystem
all
;
function
f_prepareEnrollmentRequest
(
in
charstring
p_configId
,
in
template
(
value
)
InnerEcRequest
p_innerEcRequest
)
runs
on
ItsGeoNetworking
return
GeoNetworkingPdu
{
// Local variables
var
GnNonSecuredPacket
v_gnNonSecuredPacket
;
var
octetstring
v_encMsg
;
var
octetstring
v_gnPayload
;
var
LongPosVector
v_longPosVectorNodeB
:=
f_getPosition
(
c_compNodeB
);
// Use NodeB
var
template
(
value
)
Ieee1609Dot2Data
v_securedMessage
:=
{};
// Encode the unsecured payload
v_encMsg
:=
bit2oct
(
encvalue
(
valueof
(
p_innerEcRequest
)));
//f_buildGnSecuredOtherMessage(v_securedMessage,
v_gnPayload
:=
bit2oct
(
encvalue
(
valueof
(
p_innerEcRequest
)));
// Build signed Ieee1609Dot2Data
v_gnNonSecuredPacket
:=
valueof
(
m_geoNwUnicastPacket_with_payload
(
v_longPosVectorNodeB
,
f_getIutShortPosVector
(),
vc_localSeqNumber
,
c_defaultHopLimit
,
m_trafficClass
,
v_gnPayload
));
// Encode it
v_gnPayload
:=
bit2oct
(
encvalue
(
v_gnNonSecuredPacket
)
);
/*f_buildGnSecuredOtherMessage(
v_securedMessage,
m_payload_signed(v_gnPayload),
p_issuerIdentifier,
valueof(m_threeDLocation(
v_longPosVectorNodeB.latitude,
v_longPosVectorNodeB.longitude,
0
)),
p_headerFields,
p_configId,
p_addMissingHeaders
);*/
// Return secured Gn packet
return
valueof
(
m_geoNwSecPdu
(
v_gnNonSecuredPacket
,
v_securedMessage
));
function
f_sendEnrollmentRequest
(
in
template
(
value
)
InnerEcRequest
p_innerEcRequest
,
in
charstring
p_configId
,
in
template
(
value
)
HeaderInfo
p_headerInfo
,
in
SignerIdentifier
p_signerIdentifier
,
in
boolean
p_addMissingHeaders
:=
true
)
runs
on
ItsGeoNetworking
return
GeoNetworkingPdu
{
// Local variables
var
GnNonSecuredPacket
v_gnNonSecuredPacket
;
var
octetstring
v_encMsg
;
var
octetstring
v_gnPayload
;
var
LongPosVector
v_longPosVectorNodeB
:=
f_getPosition
(
c_compNodeB
);
// Use NodeB
var
EtsiTs103097Data
v_securedMessage
:=
{};
// Encode the unsecured payload
v_encMsg
:=
bit2oct
(
encvalue
(
valueof
(
p_innerEcRequest
)));
v_gnPayload
:=
bit2oct
(
encvalue
(
valueof
(
p_innerEcRequest
)));
// Build signed Ieee1609Dot2Data
v_gnNonSecuredPacket
:=
valueof
(
m_geoNwUnicastPacket_with_payload
(
v_longPosVectorNodeB
,
f_getIutShortPosVector
(),
vc_localSeqNumber
,
c_defaultHopLimit
,
m_trafficClass
,
v_gnPayload
));
// Encode it
v_gnPayload
:=
bit2oct
(
encvalue
(
v_gnNonSecuredPacket
)
);
f_buildGnSecuredPki
(
v_securedMessage
,
valueof
(
m_toBeSignedData
(
m_signedDataPayload
(
m_etsiTs103097Data_unsecured
(
v_gnPayload
)),
p_headerInfo
)),
p_signerIdentifier
,
p_configId
/*,
p_addMissingHeaders*/
);
// Return secured Gn packet
return
valueof
(
m_geoNwSecPdu
(
v_gnNonSecuredPacket
,
v_securedMessage
));
}
function
f_buildGnSecuredPki
(
inout
EtsiTs103097Data
p_securedMessage
,
in
ToBeSignedData
p_payloadField
,
in
SignerIdentifier
p_signerIdentifierType
,
in
charstring
p_certificateName
:=
""
/*,
in boolean p_addMissingHeaders := true*/
)
runs
on
ItsSecurityBaseComponent
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_buildGnSecuredPki: 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_buildGnSecuredPki: p_signerIdentifierType=", p_signerIdentifierType);
if
(
ischosen
(
p_signerIdentifierType
.
certificate
))
{
// Add the AT certificate
log
(
"*** "
&
testcasename
()
&
"f_buildGnSecuredPki: 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_buildGnSecuredPki: 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_buildGnSecuredPki: p_securedMessage = ", p_securedMessage);
return
f_buildGnSecuredMessage
(
p_securedMessage
,
p_certificateName
,
p_payloadField
/*, v_mandatoryHeaders*/
);
}
// End of function f_buildGnSecuredPki
}
// End of module ItsPki_Functions
\ No newline at end of file
ttcn/AtsPki/ItsPki_TestCases.ttcn
View file @
af17db64
...
...
@@ -77,7 +77,7 @@ module ItsPki_TestCases {
}
// Test component configuration
f_cf01Up
();
f_cf01Up
();
// Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
v_longPosVectorIut
:=
f_getPosition
(
c_compIut
);
f_readCertificate
(
vc_hashedId8ToBeUsed
,
v_certificate
);
...
...
@@ -89,8 +89,7 @@ module ItsPki_TestCases {
f_selfOrClientSyncAndVerdictPreamble
(
c_prDone
,
e_success
);
// Test Body
v_securedGnPdu
:=
f_prepareEnrollmentRequest
(
cc_taCert_A
,
v_securedGnPdu
:=
f_sendEnrollmentRequest
(
m_innerEcRequest
(
"TODO"
,
m_publicKeys
(
...
...
@@ -103,8 +102,11 @@ module ItsPki_TestCases {
v_certificate
.
toBeSigned
.
region
,
v_certificate
.
toBeSigned
.
assuranceLevel
)));
f_sendGeoNetMessage
(
valueof
(
m_geoNwReq_linkLayerBroadcast
(
v_securedGnPdu
)));
)),
cc_taCert_A
,
valueof
(
mw_headerInfo_gn
(
-
,
f_computeGnTimestamp
())),
valueof
(
m_signerIdentifier_digest
)
);
tc_ac
.
start
;
alt
{
[]
geoNetworkingPort
.
receive
(
...
...
ttcn/AtsSecurity/ItsSecurity_TestCases.ttcn
View file @
af17db64
...
...
@@ -77,6 +77,34 @@ module ItsSecurity_TestCases {
f_cf01Down();
} // End of testcase TC_TEST_1
testcase TC_TEST_2() runs on ItsGeoNetworking system ItsSecSystem { // TODO To be rremoved, for debug purpose only
// Local variables
var LongPosVector v_longPosVectorIut;
var GeoNetworkingInd v_geoNwInd;
// Test component configuration
f_cf01Up(); // Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
v_longPosVectorIut := f_getPosition(c_compIut);
// Test adapter configuration
// Preamble
f_sendSecuredDenm(
cc_taCert_B,
valueof(
m_headerInfo_denm(
-,
f_computeGnTimestamp(),
m_threeDLocation(v_longPosVectorIut.latitude, v_longPosVectorIut.longitude, 0))
),
valueof(m_signerIdentifier_digest)
);
// Postamble
f_cf01Down();
} // End of testcase TC_TEST_2
/**
* @desc Sending behaviour test cases
* @see ETSI TS 103 096-2 V1.3.32 (2018-01) Clause 5.2 Sending behaviour
...
...
@@ -120,7 +148,7 @@ module ItsSecurity_TestCases {
}
// Test component configuration
f_cf01Up();
f_cf01Up();
// Initialise IUT with CERT_IUT_A_AT signed with CERT_IUT_A_AA
v_longPosVectorIut := f_getPosition(c_compIut);
// Test adapter configuration
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment