Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
TTCN-3 Libraries
LibIts
Compare revisions
4b09f4e418e6e62ce9be0a9a44a5c1c9805585d9...9fd3f291599a06ba28b36128afe7dff953310fb8
Commits (1)
Add TLM test
· 9fd3f291
Yann Garcia
authored
Apr 06, 2020
9fd3f291
Hide whitespace changes
Inline
Side-by-side
ttcn/Pki/LibItsPki_Functions.ttcn
View file @
9fd3f291
...
...
@@ -3040,6 +3040,7 @@ module LibItsPki_Functions {
log
(
"f_verify_rca_crl_response_message: Invalid nextUpdate value"
);
return
false
;
}
// TODO Verify RCA certificate & signature
}
}
...
...
@@ -3066,7 +3067,7 @@ module LibItsPki_Functions {
return
false
;
}
else
{
if
(
f_verify_ctl_entry
(
v_ctl_command
.
add
)
==
false
)
{
log
(
"f_verify_full_ctl: ctlCommands contains in
a
vlid entries"
);
log
(
"f_verify_full_ctl: ctlCommands contains inv
a
lid entries"
);
return
false
;
}
}
...
...
@@ -3116,33 +3117,43 @@ module LibItsPki_Functions {
return
false
;
}
else
{
if
(
f_verify_ectl_entry
(
v_ectl_command
.
add
)
==
false
)
{
log
(
"f_verify_full_ectl: ctlCommands contains in
a
vlid entries"
);
log
(
"f_verify_full_ectl: ctlCommands contains inv
a
lid entries"
);
return
false
;
}
}
}
// End of 'for' statements
return
true
;
}
function
f_verify_ctl_entry
(
in
CtlEntry
p_ctl_entry
)
return
boolean
{
log
(
">>> f_verify_ctl_entry: p_ctl_entry="
,
p_ctl_entry
);
if
(
ischosen
(
p_ctl_entry
.
rca
))
{
if
(
match
(
p_ctl_entry
.
rca
,
mw_root_ca_entry
(
mw_etsiTs103097Certificate
))
==
false
)
{
return
false
;
}
else
{
// TODO Verify RCA certificate & signature
}
}
else
if
(
ischosen
(
p_ctl_entry
.
ea
))
{
if
(
match
(
p_ctl_entry
.
ea
,
mw_ea_entry
(
mw_etsiTs103097Certificate
))
==
false
)
{
return
false
;
}
else
{
// TODO Verify RCA certificate & signature
}
}
else
if
(
ischosen
(
p_ctl_entry
.
aa
))
{
if
(
match
(
p_ctl_entry
.
aa
,
mw_aa_entry
(
mw_etsiTs103097Certificate
))
==
false
)
{
return
false
;
}
else
{
// TODO Verify RCA certificate & signature
}
}
else
if
(
ischosen
(
p_ctl_entry
.
dc
))
{
if
(
match
(
p_ctl_entry
.
dc
,
mw_dc_entry
)
==
false
)
{
return
false
;
}
else
{
// TODO Verify RCA certificate & signature
}
}
else
{
return
false
;
...
...
@@ -3150,27 +3161,91 @@ module LibItsPki_Functions {
return
true
;
}
function
f_verify_ectl_entry
(
in
CtlEntry
p_ctl_entry
)
return
boolean
{
log
(
">>> f_verify_ectl_entry: p_ctl_entry="
,
p_ctl_entry
);
if
(
ischosen
(
p_ctl_entry
.
tlm
))
{
if
(
match
(
p_ctl_entry
.
tlm
,
mw_tlm_entry
(
mw_etsiTs103097Certificate
))
==
false
)
{
return
false
;
}
else
{
// TODO Verify selsigned certificate
}
}
else
if
(
ischosen
(
p_ctl_entry
.
rca
))
{
if
(
match
(
p_ctl_entry
.
rca
,
mw_root_ca_entry
(
mw_etsiTs103097Certificate
))
==
false
)
{
return
false
;
}
else
{
// TODO Verify RCA certificate & signature
}
}
else
{
return
false
;
}
return
true
;
}
}
// End of group rca
group
tlm
{
function
f_verify_tlm_ectl_response_message
(
in
Ieee1609Dot2Data
p_ieee1609dot2_signed_data
,
in
boolean
p_check_security
:=
true
,
out
ToBeSignedTlmCtl
p_to_be_signed_tlm_ectl
)
return
boolean
{
var
bitstring
v_etsi_ts_102941_data_msg
;
var
bitstring
v_tbs
;
var
Certificate
v_certificate
;
var
boolean
v_result
;
var
Oct32
v_issuer
;
var
EtsiTs102941Data
v_etsi_ts_102941_data
;
log
(
">>> f_verify_tlm_ectl_response_message: p_ieee1609dot2_signed_data= "
,
p_ieee1609dot2_signed_data
);
// 1. Verify signature
log
(
"f_verify_tlm_ectl_response_message: p_ieee1609dot2_signed_data.content.signedData.tbsData= "
,
p_ieee1609dot2_signed_data
.
content
.
signedData
.
tbsData
);
v_tbs
:=
encvalue
(
p_ieee1609dot2_signed_data
.
content
.
signedData
.
tbsData
);
v_certificate
:=
p_ieee1609dot2_signed_data
.
content
.
signedData
.
signer
.
certificate
[
0
];
if
(
ischosen
(
p_ieee1609dot2_signed_data
.
content
.
signedData
.
signature_
.
ecdsaBrainpoolP384r1Signature
))
{
v_result
:=
f_verifyEcdsa
(
bit2oct
(
v_tbs
),
int2oct
(
0
,
48
),
p_ieee1609dot2_signed_data
.
content
.
signedData
.
signature_
,
v_certificate
.
toBeSigned
.
verifyKeyIndicator
.
verificationKey
);
}
else
{
v_result
:=
f_verifyEcdsa
(
bit2oct
(
v_tbs
),
int2oct
(
0
,
32
),
p_ieee1609dot2_signed_data
.
content
.
signedData
.
signature_
,
v_certificate
.
toBeSigned
.
verifyKeyIndicator
.
verificationKey
);
}
if
(
v_result
==
false
)
{
if
(
p_check_security
==
true
)
{
return
false
;
}
}
v_etsi_ts_102941_data_msg
:=
oct2bit
(
p_ieee1609dot2_signed_data
.
content
.
signedData
.
tbsData
.
payload
.
data
.
content
.
unsecuredData
);
if
(
decvalue
(
v_etsi_ts_102941_data_msg
,
v_etsi_ts_102941_data
)
!=
0
)
{
log
(
"f_verify_tlm_ectl_response_message: Failed to decode EtsiTs102941Data"
);
return
false
;
}
else
{
log
(
"f_verify_tlm_ectl_response_message: v_etsi_ts_102941_data= "
,
v_etsi_ts_102941_data
);
log
(
"f_verify_pki_response_message: TlmCertificateTrustListMessage matching= "
,
match
(
v_etsi_ts_102941_data
,
mw_etsiTs102941Data_to_be_signed_tlm_ctl
));
if
(
match
(
v_etsi_ts_102941_data
,
mw_etsiTs102941Data_to_be_signed_tlm_ctl
)
==
false
)
{
log
(
"f_verify_tlm_ectl_response_message: Failed to decode certificateTrustListTlm"
);
return
false
;
}
else
{
p_to_be_signed_tlm_ectl
:=
v_etsi_ts_102941_data
.
content
.
certificateTrustListTlm
;
log
(
"f_verify_tlm_ectl_response_message: p_to_be_signed_tlm_ectl= "
,
p_to_be_signed_tlm_ectl
);
if
(
p_to_be_signed_tlm_ectl
.
nextUpdate
<=
f_getCurrentTime
()
/
1000
)
{
log
(
"f_verify_tlm_ectl_response_message: Invalid nextUpdate value: compared values="
,
p_to_be_signed_tlm_ectl
.
nextUpdate
,
"/"
,
f_getCurrentTime
()
/
1000
);
return
false
;
}
// TODO Verify RCA certificate & signature
}
}
return
true
;
}
}
// End of group tlm
group
awaiting_messages
{
function
f_await_http_inner_ec_request_response
(
out
Oct32
p_private_key
,
out
Oct32
p_compressed_public_key
,
...
...
ttcn/Pki/LibItsPki_Templates.ttcn
View file @
9fd3f291
...
...
@@ -169,6 +169,15 @@ module LibItsPki_Templates {
}
}
// End of template mw_etsiTs102941Data_to_be_signed_crl
template
(
present
)
EtsiTs102941Data
mw_etsiTs102941Data_to_be_signed_tlm_ctl
(
template
(
present
)
ToBeSignedTlmCtl
p_to_be_signed_tlm
:=
?
)
:=
{
version
:=
PkiProtocolVersion
,
content
:=
{
certificateTrustListTlm
:=
p_to_be_signed_tlm
}
}
// End of template mw_etsiTs102941Data_to_be_signed_crl
template
(
value
)
EtsiTs102941DataContent
m_enrolmentRequest
(
in
template
(
value
)
InnerEcRequestSignedForPop
p_enrolmentRequest
)
:=
{
...
...
ttcn/Security/LibItsSecurity_Templates.ttcn
View file @
9fd3f291
...
...
@@ -344,19 +344,19 @@ module LibItsSecurity_Templates {
* @desc Recv template for message signed with digest
*/
template
(
present
)
SignerIdentifier
mw_signerIdentifier_digest
(
in
template
(
present
)
HashedId8
p_digest
:=
?
template
(
present
)
HashedId8
p_digest
:=
?
)
:=
{
digest
:=
p_digest
}
// End of template mw_signerIdentifier_digest
template
(
present
)
SignerIdentifier
mw_signerIdentifier_certificate
(
in
template
(
present
)
EtsiTs103097Certificate
p_certificate
:=
?
template
(
present
)
EtsiTs103097Certificate
p_certificate
:=
?
)
:=
{
certificate
:=
{
p_certificate
}
}
// End of template m_signerIdentifier_certificate
template
(
present
)
SignerIdentifier
mw_signerIdentifier_certificates
(
in
template
(
present
)
SequenceOfCertificate
p_certificates
:=
?
template
(
present
)
SequenceOfCertificate
p_certificates
:=
?
)
:=
{
certificate
:=
p_certificates
}
// End of template mw_signerIdentifier_certificates
...
...
@@ -376,7 +376,7 @@ module LibItsSecurity_Templates {
* @see Draft ETSI TS 103 097 V1.3.1 Clause 4.2.9 Signature
*/
template
(
present
)
Signature
mw_signature
(
in
template
(
present
)
EcdsaP256Signature
p_ecdsaSignature
:=
?
template
(
present
)
EcdsaP256Signature
p_ecdsaSignature
:=
?
)
:=
{
ecdsaNistP256Signature
:=
p_ecdsaSignature
}
// End of template mw_signature
...
...
@@ -388,8 +388,8 @@ module LibItsSecurity_Templates {
* @see Draft ETSI TS 103 097 V1.3.1 Clause 4.2.10 EcdsaP256Signature
*/
template
(
present
)
EcdsaP256Signature
mw_ecdsaSignature
(
in
template
(
present
)
EccP256CurvePoint
p_rSig
:=
?
,
in
template
(
present
)
octetstring
p_sSig
:=
?
template
(
present
)
EccP256CurvePoint
p_rSig
:=
?
,
template
(
present
)
octetstring
p_sSig
:=
?
)
:=
{
rSig
:=
p_rSig
,
sSig
:=
p_sSig
...
...
@@ -404,8 +404,8 @@ module LibItsSecurity_Templates {
* @see Draft ETSI TS 103 097 V1.3.1 Clause 4.2.19 TwoDLocation
*/
template
(
present
)
TwoDLocation
mw_twoDLocation
(
in
template
(
present
)
SecLatitude
p_latitude
,
in
template
(
present
)
SecLongitude
p_longitude
template
(
present
)
SecLatitude
p_latitude
,
template
(
present
)
SecLongitude
p_longitude
)
:=
{
latitude
:=
p_latitude
,
longitude
:=
p_longitude
...
...
@@ -419,9 +419,9 @@ module LibItsSecurity_Templates {
* @see Draft ETSI TS 103 097 V1.3.1 Clause 4.2.20 ThreeDLocation
*/
template
(
present
)
ThreeDLocation
mw_threeDLocation
(
in
template
(
present
)
SecLatitude
p_latitude
,
in
template
(
present
)
SecLongitude
p_longitude
,
in
template
(
present
)
SecElevation
p_elevation
template
(
present
)
SecLatitude
p_latitude
,
template
(
present
)
SecLongitude
p_longitude
,
template
(
present
)
SecElevation
p_elevation
)
:=
{
latitude
:=
p_latitude
,
longitude
:=
p_longitude
,
...
...
@@ -435,8 +435,8 @@ module LibItsSecurity_Templates {
* @see Draft ETSI TS 103 097 V1.3.1 Clause 4.2.21 GeographicRegion
*/
template
(
present
)
GeographicRegion
mw_geographicRegion_circle
(
in
template
(
present
)
TwoDLocation
p_center
:=
?
,
in
template
(
present
)
UInt16
p_radius
:=
?
template
(
present
)
TwoDLocation
p_center
:=
?
,
template
(
present
)
UInt16
p_radius
:=
?
)
:=
{
circularRegion
:=
{
center
:=
p_center
,
...
...
@@ -460,7 +460,7 @@ module LibItsSecurity_Templates {
* @see Draft ETSI TS 103 097 V1.3.1 Clause 4.2.21 GeographicRegion
*/
template
(
present
)
GeographicRegion
mw_geographicRegion_polygonal
(
in
template
(
present
)
PolygonalRegion
p_polygonal_region
:=
?
template
(
present
)
PolygonalRegion
p_polygonal_region
:=
?
)
:=
{
polygonalRegion
:=
p_polygonal_region
}
// End of template mw_geographicRegion_polygonial
...
...
@@ -471,7 +471,7 @@ module LibItsSecurity_Templates {
* @see Draft ETSI TS 103 097 V1.3.1 Clause 4.2.21 GeographicRegion
*/
template
(
present
)
GeographicRegion
mw_geographicRegion_identified
(
in
template
(
present
)
SequenceOfIdentifiedRegion
p_identifiedRegion
:=
?
template
(
present
)
SequenceOfIdentifiedRegion
p_identifiedRegion
:=
?
)
:=
{
identifiedRegion
:=
p_identifiedRegion
}
// End of template mw_geographicRegion_identifiedRegion
...
...