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
14f9b1e9
Commit
14f9b1e9
authored
Dec 01, 2017
by
garciay
Browse files
Start Security support
parent
db3adb48
Changes
1
Hide whitespace changes
Inline
Side-by-side
ttcn/TestCodec/TestCodec_Certificates.ttcn
View file @
14f9b1e9
...
...
@@ -22,19 +22,22 @@ module TestCodec_Certificates {
// LibItsSecurity
import
from
LibItsSecurity_EncdecDeclarations
all
;
//import from LibItsSecurity_Templates all;
//import from LibItsSecurity_Pixits all;
// TestCodec
import
from
TestCodec_TestAndSystem
all
;
template
(
value
)
EtsiTs103097Certificate
m_etsiTs103097Certificate
(
in
template
(
value
)
IssuerIdentifier
p_issuer
,
in
template
(
value
)
ToBeSignedCertificate
p_toBeSigned
)
:=
{
template
(
omit
)
EtsiTs103097Certificate
m_etsiTs103097Certificate
(
in
template
(
value
)
IssuerIdentifier
p_issuer
,
in
template
(
value
)
ToBeSignedCertificate
p_toBeSigned
,
in
template
(
omit
)
Signature
p_signature_
:=
omit
)
:=
{
version
:=
3
,
type_
:=
explicit
,
issuer
:=
p_issuer
,
toBeSigned
:=
p_toBeSigned
,
signature_
:=
omit
signature_
:=
p_signature_
}
// End of template m_etsiTs103097Certificate
template
(
value
)
IssuerIdentifier
m_issuerIdentifier_self
(
...
...
@@ -61,8 +64,8 @@ module TestCodec_Certificates {
in
template
(
value
)
CrlSeries
p_crlSeries
,
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
)
SequenceOfPsidGroupPermissions
p_certRequestPermissions
:=
omit
,
in
template
(
omit
)
ValidityPeriod
p_validityPeriod
:=
omit
,
in
template
(
omit
)
GeographicRegion
p_region
:=
omit
,
in
template
(
omit
)
SubjectAssurance
p_assuranceLevel
:=
omit
,
...
...
@@ -90,6 +93,17 @@ module TestCodec_Certificates {
duration
:=
p_duration
}
// End of template m_validity_period
template
(
value
)
GeographicRegion
m_geographicRegion_identifiedRegion
(
in
template
(
value
)
SequenceOfIdentifiedRegion
p_identifiedRegion
)
:=
{
identifiedRegion
:=
p_identifiedRegion
}
template
(
value
)
IdentifiedRegion
m_identifiedRegion
(
in
template
(
value
)
CountryOnly
p_countryOnly
)
:=
{
countryOnly
:=
p_countryOnly
}
template
(
omit
)
PsidSsp
m_appPermissions
(
in
template
(
value
)
Psid
p_psid
,
in
template
(
omit
)
ServiceSpecificPermissions
p_ssp
:=
omit
...
...
@@ -98,15 +112,31 @@ module TestCodec_Certificates {
ssp
:=
p_ssp
}
// End of template m_appPermissions
template
(
omit
)
PsidSspRange
m_psidSspRange
(
in
Psid
p_psid
,
in
template
(
omit
)
SspRange
p_sspRange
:=
omit
template
(
value
)
PsidSspRange
m_psidSspRange
(
in
Psid
p_psid
,
in
template
(
value
)
SspRange
p_sspRange
:=
m_SspRange_all
)
:=
{
psid
:=
p_psid
,
sspRange
:=
p_sspRange
}
// End of template m_psidSspRange
template
(
value
)
PsidGroupPermissions
m_PsidGroupPermissions
(
template
(
value
)
SspRange
m_SspRange_all
:=
{
all_
:=
NULL
}
// End of template m_SspRange_all
template
(
value
)
SspRange
m_SspRange_opaque
(
in
template
(
value
)
SequenceOfOctetString
p_opaque
)
:=
{
opaque
:=
p_opaque
}
// End of template m_SspRange_opaque
template
(
value
)
SspRange
m_SspRange_bitmapSspRange
(
in
template
(
value
)
BitmapSspRange
p_bitmapSspRange
)
:=
{
bitmapSspRange
:=
p_bitmapSspRange
}
// End of template m_SspRange_bitmapSspRange
template
(
value
)
PsidGroupPermissions
m_psidGroupPermissions
(
in
template
(
value
)
SubjectPermissions
p_subjectPermissions
,
in
integer
p_minChainLength
:=
1
,
in
integer
p_chainLengthRange
:=
0
,
...
...
@@ -116,7 +146,7 @@ module TestCodec_Certificates {
minChainLength
:=
p_minChainLength
,
chainLengthRange
:=
p_chainLengthRange
,
eeType
:=
p_eeType
}
// End of template m_
P
sidGroupPermissions
}
// End of template m_
p
sidGroupPermissions
template
(
value
)
SubjectPermissions
m_subjectPermissions_explicit
(
in
SequenceOfPsidSspRange
p_certIssuePermissions
...
...
@@ -124,6 +154,10 @@ module TestCodec_Certificates {
explicit
:=
p_certIssuePermissions
}
// End of template m_subjectPermissions_explicit
template
(
value
)
SubjectPermissions
m_subjectPermissions_all
:=
{
all_
:=
NULL
}
// End of template m_subjectPermissions_all
template
(
value
)
VerificationKeyIndicator
m_verificationKeyIndicator_verificationKey
(
in
template
(
value
)
PublicVerificationKey
p_verificationKey
)
:=
{
...
...
@@ -148,6 +182,12 @@ module TestCodec_Certificates {
compressed_y_0
:=
p_compressed_y_0
}
// End of template m_eccP256CurvePoint_compressed_y_0
template
(
value
)
EccP256CurvePoint
m_eccP256CurvePoint_compressed_x_only
(
in
Oct32
p_x_only
)
:=
{
x_only
:=
p_x_only
}
// End of template m_eccP256CurvePoint_compressed_x_only
template
(
value
)
Signature
m_signature_ecdsaNistP256
(
in
template
(
value
)
EcdsaP256Signature
p_ecdsaNistP256Signature
)
:=
{
...
...
@@ -185,8 +225,8 @@ module TestCodec_Certificates {
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
:=
'
00110011
001
1
'O
})),
valueof
(
m_appPermissions
(
37
,
{
bitmapSsp
:=
'
00110011
001
1
'O
}))
valueof
(
m_appPermissions
(
36
,
{
bitmapSsp
:=
'
830
001
'
O
})),
valueof
(
m_appPermissions
(
37
,
{
bitmapSsp
:=
'
830
001
'
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?
...
...
@@ -214,23 +254,23 @@ module TestCodec_Certificates {
v_crlSeries
,
v_appPermissions
,
{
m_
P
sidGroupPermissions
(
m_
p
sidGroupPermissions
(
m_subjectPermissions_explicit
(
v_certIssuePermissions
))
},
{
m_PsidGroupPermissions
(
m_subjectPermissions_explicit
(
v_certRequestPermissions
))
},
m_verificationKeyIndicator_verificationKey
(
// FIXME Do we use it? If so what is the content?
m_publicVerificationKey_ecdsaNistP256
(
m_eccP256CurvePoint_x_y
(
v_publicKeyX
,
v_publicKeyY
)))
))),
{
m_psidGroupPermissions
(
m_subjectPermissions_explicit
(
v_certRequestPermissions
))
}
)
);
// Encode it ==> Get octetstring
...
...
@@ -253,6 +293,78 @@ module TestCodec_Certificates {
setverdict
(
pass
,
"Encoding passed."
);
}
// End of testcase tc_root_certificate_1
testcase
tc_certificate_1
()
runs
on
TCType
system
TCType
{
var
template
(
value
)
EtsiTs103097Certificate
v_cert
;
var
charstring
v_certId
:=
"vehicle-test.example.com"
;
var
HashAlgorithm
v_self
:=
sha256
;
var
HashedId3
v_cracaId
:=
'
5
E6F5B
'
O
;
var
CrlSeries
v_crlSeries
:=
2
;
var
octetstring
v_private_key
:=
''
O
;
var
octetstring
v_publicKeyX
:=
''
O
;
var
octetstring
v_publicKeyY
:=
''
O
;
var
HashedId8
v_sha256AndDigest
;
var
octetstring
v_sig
:=
''
O
;
var
bitstring
v_encMsg
:=
''
B
;
// Generate Private/Public keys
f_generate_key_pair
(
v_private_key
,
v_publicKeyX
,
v_publicKeyX
);
// Store Private key in binary format
//f_save_key(v_private_key);
// Fill Certificate template with the public key
v_cert
:=
m_etsiTs103097Certificate
(
m_issuerIdentifier_sha256AndDigest
(
'
AF232618BE5E6F55
'
O
),
m_toBeSignedCertificate
(
{
name
:=
v_certId
},
v_cracaId
,
v_crlSeries
,
{
valueof
(
m_appPermissions
(
35
,
{
bitmapSsp
:=
'
830001
'
O
}))
},
{
m_psidGroupPermissions
(
m_subjectPermissions_all
,
2
,
0
,
oct2bit
(
'
C0
'
O
)
),
m_psidGroupPermissions
(
m_subjectPermissions_explicit
(
{
valueof
(
m_psidSspRange
(
35
)),
valueof
(
m_psidSspRange
(
256
))
}
))
},
m_verificationKeyIndicator_verificationKey
(
// FIXME Do we use it? If so what is the content?
m_publicVerificationKey_ecdsaNistP256
(
m_eccP256CurvePoint_compressed_y_0
(
'
08
C3C070B040C040108033070D0501CE0C0A0806017B00F030D203EA04BE0903
'
O
))),
-
,
m_validity_period
(
17469212
,
{
years
:=
10
}
),
m_geographicRegion_identifiedRegion
(
{
m_identifiedRegion
(
12
),
m_identifiedRegion
(
34
)
}
)
),
m_signature_ecdsaNistP256
(
m_ecdsaNistP256Signature
(
m_eccP256CurvePoint_compressed_x_only
(
'
08
B2030104020A0D010C0105C0F80BB1460239348D17405C1A845151D4061200
'
O
),
'
2617
CF4E6B25097F03F502AD0C6F2F125974700D31A60FD1EF12040E4D8231AB
'
O
)
)
);
v_encMsg
:=
encvalue
(
v_cert
);
setverdict
(
pass
,
"Encoding passed."
);
}
// End of testcase tc_certificate_1
group
helpersFunctions
{
group
signing
{
...
...
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