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
32aba41f
Commit
32aba41f
authored
Jul 09, 2018
by
garciay
Browse files
Bug fixed in scripts
parent
db1d6a2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
etc/TestCodec/TestCodec.cfg
View file @
32aba41f
...
...
@@ -311,8 +311,8 @@ system.utPort.params := "UT_GN/UDP(dst_ip=192.168.56.1,dst_port=12346,src_ip=192
#TestCodec_SecuredMessages.tc_secured_message_signed_and_encrypted_1
#TestCodec_SecuredMessages.tc_secured_message_signed_and_encrypted_2
# Chain of certificates
TestCodec_ChainOfCertificates.tc_full_check_certificate_1
TestCodec_ChainOfCertificates.tc_full_check_certificate_2
#
TestCodec_ChainOfCertificates.tc_full_check_certificate_1
#
TestCodec_ChainOfCertificates.tc_full_check_certificate_2
# Encryption
#TestCodec_SignedAndEncryptedMessages.tc_test_hmac_sha256_test1
#TestCodec_SignedAndEncryptedMessages.tc_test_hmac_sha256_test2
...
...
@@ -325,6 +325,10 @@ TestCodec_ChainOfCertificates.tc_full_check_certificate_2
#TestCodec_SignedAndEncryptedMessages.tc_decrypted_signed_message_3
#TestCodec_SignedAndEncryptedMessages.tc_decrypted_signed_message_4
#TestCodec_SignedAndEncryptedMessages.tc_decrypted_signed_message_5
# Pki
TestCodec_Pki.tc_inner_ec_request_1
TestCodec_Pki.tc_inner_ec_request_2
TestCodec_Pki.tc_inner_ec_response_1
[MAIN_CONTROLLER]
# The options herein control the behavior of MC.
...
...
ttcn/TestCodec/TestCodec_Pki.ttcn
View file @
32aba41f
...
...
@@ -17,6 +17,7 @@ module TestCodec_Pki {
import
from
LibCommon_VerdictControl
all
;
import
from
LibCommon_Sync
all
;
import
from
LibCommon_BasicTypesAndValues
all
;
import
from
LibCommon_DataStrings
all
;
// LibIts
import
from
IEEE1609dot2BaseTypes
language
"ASN.1:1997"
all
;
...
...
@@ -43,19 +44,31 @@ module TestCodec_Pki {
import
from
LibItsSecurity_Functions
all
;
// LibItsPki
import
from
LibItsPki_EncdecDeclarations
all
;
import
from
LibItsPki_Templates
all
;
// TestCodec
import
from
TestCodec_TestAndSystem
all
;
testcase
tc_inner_ec_request_1
()
runs
on
TCType
system
TCType
{
var
bitstring
v_encMsg
;
var
integer
v_res
:=
0
;
var
bitstring
v_expEncMsg
:=
oct2bit
(
'340010'O
);
var
EtsiTs103097Certificate
v_certificate
;
var
InnerEcRequest
v_innerEcRequest
;
f_readCertificate
(
"CERT_IUT_F_AT"
,
v_certificate
);
var
InnerEcRequest
v_exp_innerEcReq
;
var
bitstring
v_exp_enc_msg
:=
oct2bit
(
'
0004544
F444F010080823C5C40E2D3117A493E97ECA2EA7AE164A2E3EBC856EEC760428442076370ED837C831A5617008422388301018000FA60010380012481040301FFFF80012581050401FFFFFF8002008D81020100
'
O
);
var
bitstring
v_enc_msg
:=
oct2bit
(
'
80030080
db4f29fdf09200d2708300000000001a5617008422388301018000fa60010380012481040301ffff80012581050401ffffff80018d810201008080823c5c40e2d3117a493e97eca2ea7ae164a2e3ebc856eec760428442076370ed83808051aae5e5db859816de75db80112fba869e2704829b912d1be3b082f2e531c061c5699757849f335c816ddda1742e3e6c0c2a0930146d1e0697bf035b14655afd
'
O
);
// CERT_IUT_E_AT.oer
var
Oct32
v_private_key
:=
'
9
e85f9242800761c6ee2889bb7bbad8942927caad8519729f8475ee50302e7f7
'
O
;
// CERT_IUT_E_AT.vkey
// Decode certificate
v_res
:=
decvalue
(
v_enc_msg
,
v_certificate
);
if
(
v_res
==
0
)
{
log
(
"Decoded message: "
,
v_certificate
);
setverdict
(
pass
,
"Decoded succeed"
);
}
else
{
setverdict
(
fail
,
"Decoding failed"
);
}
// Create InnerEcRequest request
v_innerEcRequest
:=
valueof
(
m_innerEcRequest
(
"TODO"
,
m_publicKeys
(
...
...
@@ -68,51 +81,34 @@ module TestCodec_Pki {
v_certificate
.
toBeSigned
.
region
,
v_certificate
.
toBeSigned
.
assuranceLevel
)));
// Encode template
// Encode
InnerEcRequest
template
log
(
"Encode template "
,
v_innerEcRequest
);
v_enc
M
sg
:=
encvalue
(
v_innerEcRequest
);
log
(
"Encoded message: "
,
bit2oct
(
v_enc
M
sg
));
v_enc
_m
sg
:=
encvalue
(
v_innerEcRequest
);
log
(
"Encoded message: "
,
bit2oct
(
v_enc
_m
sg
));
// Check result
if
(
not
isbound
(
v_enc
M
sg
))
{
setverdict
(
fail
,
"Encoding failed!"
);
if
(
not
isbound
(
v_enc
_m
sg
))
{
setverdict
(
fail
,
"Encoding
InnerEcRequest
failed!"
);
stop
;
}
if
(
not
match
(
v_enc
M
sg
,
v_exp
EncM
sg
))
{
log
(
"Expected message: "
,
bit2oct
(
valueof
(
v_exp
EncM
sg
)));
setverdict
(
fail
,
"Encoding failed, not the expected result!"
);
if
(
not
match
(
v_enc
_m
sg
,
v_exp
_enc_m
sg
))
{
log
(
"Expected message: "
,
bit2oct
(
valueof
(
v_exp
_enc_m
sg
)));
setverdict
(
fail
,
"Encoding
InnerEcRequest
failed, not the expected result!"
);
stop
;
}
setverdict
(
pass
,
"Encoding passed."
);
}
// End of testcase tc_inner_ec_request_1
testcase
tc_inner_ec_response_1
()
runs
on
TCType
system
TCType
{
var
bitstring
v_encMsg
;
var
integer
v_res
:=
0
;
var
bitstring
v_expEncMsg
:=
oct2bit
(
'340010'O
);
var
EtsiTs103097Certificate
v_certificate
;
var
InnerEcResponse
v_innerEcResponse
;
f_readCertificate
(
"CERT_IUT_F_AT"
,
v_certificate
);
v_innerEcResponse
:=
valueof
(
m_innerEcResponse_ok
(
int2oct
(
10
,
16
),
v_certificate
));
// Encode template
log
(
"Encode template "
,
v_innerEcResponse
);
v_encMsg
:=
encvalue
(
v_innerEcResponse
);
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
;
v_res
:=
decvalue
(
v_exp_enc_msg
,
v_exp_innerEcReq
);
if
(
v_res
==
0
)
{
log
(
"Decoded message: "
,
v_certificate
);
setverdict
(
pass
,
"Decoded succeed"
);
if
(
not
match
(
v_innerEcRequest
,
v_exp_innerEcReq
))
{
log
(
"Expected message: "
,
bit2oct
(
valueof
(
v_exp_enc_msg
)));
setverdict
(
fail
,
"Encoding failed, not the expected result!"
);
stop
;
}
}
else
{
setverdict
(
fail
,
"Decoding failed"
);
}
setverdict
(
pass
,
"Encoding passed."
);
}
// End of testcase tc_inner_ec_re
sponse
_1
}
// End of testcase tc_inner_ec_re
quest
_1
testcase
tc_inner_ec_request_2
()
runs
on
TCType
system
TCType
{
var
template
(
value
)
EtsiTs103097Data
v_signed_data
;
...
...
@@ -121,9 +117,9 @@ module TestCodec_Pki {
var
EtsiTs103097Data
v_encrypted_data_dec
;
var
EtsiTs103097Certificate
v_certificate
;
var
InnerEcRequest
v_innerEcRequest
;
var
bitstring
v_enc
M
sg
;
var
bitstring
v_enc
_m
sg
;
var
integer
v_res
:=
0
;
var
bitstring
v_exp
EncM
sg
:=
oct2bit
(
'340010'O
);
var
bitstring
v_exp
_enc_m
sg
:=
oct2bit
(
'340010'O
);
var
octetstring
v_raw_payload_to_be_signed
;
var
HashedId8
v_digest
:=
'0000000000000000'O
;
var
HashedId8
v_encrypted_hashedId8
:=
'0000000000000000'O
;
...
...
@@ -171,9 +167,9 @@ module TestCodec_Pki {
);
log
(
"v_signed_data = "
,
v_signed_data
);
v_enc
M
sg
:=
encvalue
(
valueof
(
v_signed_data
));
v_enc
_m
sg
:=
encvalue
(
valueof
(
v_signed_data
));
setverdict
(
pass
,
"Encoding passed."
);
if
(
decvalue
(
v_enc
M
sg
,
v_signed_data_dec
)
!=
0
)
{
if
(
decvalue
(
v_enc
_m
sg
,
v_signed_data_dec
)
!=
0
)
{
setverdict
(
fail
);
stop
;
}
else
if
(
not
(
match
(
valueof
(
v_signed_data
),
v_signed_data_dec
)))
{
...
...
@@ -203,14 +199,14 @@ module TestCodec_Pki {
m_SymmetricCiphertext_aes128ccm
(
m_aesCcmCiphertext
(
'
0102030405060708090
a0b0c
'
O
,
bit2oct
(
v_enc
M
sg
)
bit2oct
(
v_enc
_m
sg
)
)
)
)
);
v_enc
M
sg
:=
encvalue
(
valueof
(
v_encrypted_data
));
v_enc
_m
sg
:=
encvalue
(
valueof
(
v_encrypted_data
));
setverdict
(
pass
,
"Encoding passed."
);
if
(
decvalue
(
v_enc
M
sg
,
v_encrypted_data_dec
)
!=
0
)
{
if
(
decvalue
(
v_enc
_m
sg
,
v_encrypted_data_dec
)
!=
0
)
{
setverdict
(
fail
);
stop
;
}
else
if
(
not
(
match
(
valueof
(
v_encrypted_data
),
v_encrypted_data_dec
)))
{
...
...
@@ -220,4 +216,50 @@ module TestCodec_Pki {
setverdict
(
pass
,
"Decoding passed."
);
}
// End of testcase tc_inner_ec_request_2
}
// End of module TestCodec_Pki
\ No newline at end of file
testcase
tc_inner_ec_response_1
()
runs
on
TCType
system
TCType
{
var
integer
v_res
:=
0
;
var
EtsiTs103097Certificate
v_certificate
;
var
InnerEcResponse
v_innerEcResponse
;
var
bitstring
v_exp_enc_msg
:=
oct2bit
(
'
400000000000000000000000000000000
A0080030080DB4F29FDF09200D2708300000000001A5617008422388301018000FA60010380012481040301FFFF80012581050401FFFFFF8002008D810201008080823C5C40E2D3117A493E97ECA2EA7AE164A2E3EBC856EEC760428442076370ED83808051AAE5E5DB859816DE75DB80112FBA869E2704829B912D1BE3B082F2E531C061C5699757849F335C816DDDA1742E3E6C0C2A0930146D1E0697BF035B14655AFD
'
O
);
var
bitstring
v_enc_msg
:=
oct2bit
(
'
80030080
db4f29fdf09200d2708300000000001a5617008422388301018000fa60010380012481040301ffff80012581050401ffffff80018d810201008080823c5c40e2d3117a493e97eca2ea7ae164a2e3ebc856eec760428442076370ed83808051aae5e5db859816de75db80112fba869e2704829b912d1be3b082f2e531c061c5699757849f335c816ddda1742e3e6c0c2a0930146d1e0697bf035b14655afd
'
O
);
// CERT_IUT_E_AT.oer
var
Oct32
v_private_key
:=
'
9
e85f9242800761c6ee2889bb7bbad8942927caad8519729f8475ee50302e7f7
'
O
;
// CERT_IUT_E_AT.vkey
// Decode certificate
v_res
:=
decvalue
(
v_enc_msg
,
v_certificate
);
if
(
v_res
==
0
)
{
log
(
"Decoded message: "
,
v_certificate
);
setverdict
(
pass
,
"Decoded succeed"
);
}
else
{
setverdict
(
fail
,
"Decoding failed"
);
}
// Create InnerEcResponse request
v_innerEcResponse
:=
valueof
(
m_innerEcResponse_ok
(
int2oct
(
10
,
16
),
v_certificate
));
// Encode InnerEcResponse template
log
(
"Encode template "
,
v_innerEcResponse
);
v_enc_msg
:=
encvalue
(
v_innerEcResponse
);
log
(
"Encoded message: "
,
bit2oct
(
v_enc_msg
));
// Check result
if
(
not
isbound
(
v_enc_msg
))
{
setverdict
(
fail
,
"Encoding failed!"
);
stop
;
}
if
(
not
match
(
v_enc_msg
,
v_exp_enc_msg
))
{
log
(
"Expected message: "
,
bit2oct
(
valueof
(
v_exp_enc_msg
)));
setverdict
(
fail
,
"Encoding failed, not the expected result!"
);
stop
;
}
setverdict
(
pass
,
"Encoding passed."
);
}
// End of testcase tc_inner_ec_response_1
control
{
execute
(
tc_inner_ec_request_1
());
execute
(
tc_inner_ec_request_2
());
execute
(
tc_inner_ec_response_1
());
}
}
// End of module TestCodec_Pki
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