Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TTCN-3 Libraries
LibIts
Commits
b31f565a
Commit
b31f565a
authored
Nov 01, 2018
by
Yann Garcia
Browse files
Add unit tests
parent
6c6c9f38
Changes
4
Hide whitespace changes
Inline
Side-by-side
ttcn/Http/LibItsHttp_BinaryTemplates.ttcn
View file @
b31f565a
...
...
@@ -47,17 +47,4 @@ module LibItsHttp_BinaryTemplates {
ieee1609dot2_data
:=
p_ieee1609dot2_data
}
// End of template mw_binary_body_ieee1609dot2_data
// Move to Pki
// template (present) BinaryBody mw_binary_body_innerEcRequest(
// template (present) InnerEcRequest p_innerEcRequest := ?
// ) := {
// innerEcRequest := p_innerEcRequest
// } // End of template mw_binary_body_innerEcRequest
//
// template (present) BinaryBody mw_binary_body_innerEcResponse(
// template (present) InnerEcResponse p_innerEcResponse := ?
// ) := {
// innerEcResponse := p_innerEcResponse
// } // End of template mw_binary_body_innerEcResponse
//
}
// End of module LibItsHttp_BinaryTemplates
ttcn/Pki/LibItsPki_Functions.ttcn
View file @
b31f565a
...
...
@@ -188,13 +188,14 @@ module LibItsPki_Functions {
group
ac_port
{
function
f_sendAcPkiPrimitive
(
in
charstring
p_certificate
,
in
octetstring
p_private_key
,
in
octetstring
p_publicKeyCompressed
,
in
integer
p_compressedMode
)
runs
on
ItsPki
{
var
AcSetSecurityData
v_ac_set_security_data
;
v_ac_set_security_data
:=
{
PICS_TS_CERTIFICATE_ID
,
PICS_IUT_CERTIFICATE_ID
,
p_private_key
,
p_publicKeyCompressed
,
p_compressedMode
};
v_ac_set_security_data
:=
{
p_certificate
,
PICS_IUT_CERTIFICATE_ID
,
p_private_key
,
p_publicKeyCompressed
,
p_compressedMode
};
acPort
.
send
(
AcPkiPrimitive
:
{
acSetSecurityData
:=
v_ac_set_security_data
});
tc_ac
.
start
;
alt
{
...
...
@@ -278,26 +279,26 @@ module LibItsPki_Functions {
group
http
{
function
f_http_build_
enrolment
_request
(
function
f_http_build_
inner_ec
_request
(
out
octetstring
p_private_key
,
out
octetstring
p_publicKeyX
,
out
octetstring
p_publicKeyY
,
out
octetstring
p_publicKeyCompressed
,
out
integer
p_compressedMode
,
out
Ieee1609Dot2Data
p_ieee1609dot2_signed_and_encrypted_data
,
out
Oct32
p_hash_inner_ec_request_signed_for_pop
)
runs
on
ItsPkiHttp
{
var
octetstring
v_publicKeyX
;
var
octetstring
v_publicKeyY
var
InnerEcRequest
v_inner_ec_request
;
var
Ieee1609Dot2Data
v_inner_ec_request_signed_for_pop
;
var
bitstring
v_inner_ec_request_signed_for_pop_msg
;
if
(
f_generate_inner_ec_request
(
p_private_key
,
p_publicKeyX
,
p_publicKeyY
,
p_publicKeyCompressed
,
p_compressedMode
,
v_inner_ec_request
)
==
false
)
{
log
(
"*** f_http_build_
enrolment
_request: ERROR: Failed to generate InnerEcRequest ***"
);
if
(
f_generate_inner_ec_request
(
p_private_key
,
p_publicKeyCompressed
,
p_compressedMode
,
v_inner_ec_request
)
==
false
)
{
log
(
"*** f_http_build_
inner_ec
_request: ERROR: Failed to generate InnerEcRequest ***"
);
f_selfOrClientSyncAndVerdict
(
"error"
,
e_error
);
}
// Generate InnerEcRequestSignedForPoP
if
(
f_generate_inner_ec_request_signed_for_pop
(
p_private_key
,
v_inner_ec_request
,
v_inner_ec_request_signed_for_pop
)
==
false
)
{
log
(
"*** f_http_build_
enrolment
_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***"
);
log
(
"*** f_http_build_
inner_ec
_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***"
);
f_selfOrClientSyncAndVerdict
(
"error"
,
e_error
);
}
// Secure InnerEcRequestSignedForPoP message
...
...
@@ -305,18 +306,16 @@ module LibItsPki_Functions {
// Prepae for getting the 16 most bytes of SHA256 of InnerEcRequestSignedForPop
p_hash_inner_ec_request_signed_for_pop
:=
f_hashWithSha256
(
bit2oct
(
v_inner_ec_request_signed_for_pop_msg
));
if
(
f_build_pki_secured_message
(
vc_eaPrivateKey
,
valueof
(
m_signerIdentifier_self
),
vc_eaHashedId8
,
p_publicKeyCompressed
,
p_compressedMode
,
bit2oct
(
v_inner_ec_request_signed_for_pop_msg
),
p_ieee1609dot2_signed_and_encrypted_data
)
==
false
)
{
log
(
"*** f_http_build_
enrolment
_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***"
);
log
(
"*** f_http_build_
inner_ec
_request: ERROR: Failed to generate InnerEcRequestSignedForPop ***"
);
f_selfOrClientSyncAndVerdict
(
"error"
,
e_error
);
}
log
(
"*** f_http_build_
enrolment
_request: DEBUG: v_inner_ec_request_signed_for_pop_msg= "
,
v_inner_ec_request_signed_for_pop_msg
);
log
(
"*** f_http_build_
enrolment
_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data= "
,
p_ieee1609dot2_signed_and_encrypted_data
);
log
(
"*** f_http_build_
enrolment
_request: DEBUG: p_hash_inner_ec_request_signed_for_pop= "
,
p_hash_inner_ec_request_signed_for_pop
);
}
// End of function f_http_build_
enrolment
_request
log
(
"*** f_http_build_
inner_ec
_request: DEBUG: v_inner_ec_request_signed_for_pop_msg= "
,
v_inner_ec_request_signed_for_pop_msg
);
log
(
"*** f_http_build_
inner_ec
_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data= "
,
p_ieee1609dot2_signed_and_encrypted_data
);
log
(
"*** f_http_build_
inner_ec
_request: DEBUG: p_hash_inner_ec_request_signed_for_pop= "
,
p_hash_inner_ec_request_signed_for_pop
);
}
// End of function f_http_build_
inner_ec
_request
function
f_http_build_invalid_enrolment_request
(
out
octetstring
p_private_key
,
out
octetstring
p_publicKeyX
,
out
octetstring
p_publicKeyY
,
out
octetstring
p_publicKeyCompressed
,
out
integer
p_compressedMode
,
out
Ieee1609Dot2Data
p_ieee1609dot2_signed_and_encrypted_data
,
...
...
@@ -326,7 +325,7 @@ module LibItsPki_Functions {
var
Ieee1609Dot2Data
v_inner_ec_request_signed_for_pop
;
var
bitstring
v_inner_ec_request_signed_for_pop_msg
;
if
(
f_generate_inner_ec_request
(
p_private_key
,
p_publicKeyX
,
p_publicKeyY
,
p_publicKeyCompressed
,
p_compressedMode
,
v_inner_ec_request
)
==
false
)
{
if
(
f_generate_inner_ec_request
(
p_private_key
,
p_publicKeyCompressed
,
p_compressedMode
,
v_inner_ec_request
)
==
false
)
{
log
(
"*** f_http_build_invalid_enrolment_request: ERROR: Failed to generate InnerEcRequest ***"
);
f_selfOrClientSyncAndVerdict
(
"error"
,
e_error
);
}
...
...
@@ -346,6 +345,15 @@ module LibItsPki_Functions {
log
(
"*** f_http_build_invalid_enrolment_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data = "
,
p_ieee1609dot2_signed_and_encrypted_data
);
}
// End of function f_http_build_invalid_enrolment_request
function
f_http_build_authorization_validation_request
(
out
octetstring
p_private_key
,
out
octetstring
p_publicKeyCompressed
,
out
integer
p_compressedMode
,
out
Ieee1609Dot2Data
p_ieee1609dot2_signed_and_encrypted_data
)
runs
on
ItsPkiHttp
{
log
(
"*** f_http_build_invalid_enrolment_request: DEBUG: p_ieee1609dot2_signed_and_encrypted_data = "
,
p_ieee1609dot2_signed_and_encrypted_data
);
}
}
// End of group http
group
generate_certificates
{
...
...
@@ -460,18 +468,18 @@ module LibItsPki_Functions {
function
f_generate_inner_ec_request
(
out
octetstring
p_private_key
,
out
octetstring
p_publicKeyX
,
out
octetstring
p_publicKeyY
,
out
octetstring
p_publicKeyCompressed
,
out
integer
p_compressedMode
,
out
InnerEcRequest
p_inner_ec_request
)
return
boolean
{
// Local variables
var
Oct32
v_publicKeyX
;
var
Oct32
v_publicKeyY
;
var
EccP256CurvePoint
v_eccP256_curve_point
;
log
(
">>> f_generate_inner_ec_request"
);
// Generate keys for the certificate to be requested
if
(
f_generate_key_pair_nistp256
(
p_private_key
,
p
_publicKeyX
,
p
_publicKeyY
,
p_publicKeyCompressed
,
p_compressedMode
)
==
false
)
{
if
(
f_generate_key_pair_nistp256
(
p_private_key
,
v
_publicKeyX
,
v
_publicKeyY
,
p_publicKeyCompressed
,
p_compressedMode
)
==
false
)
{
log
(
"f_generate_inner_ec_request: failed to generate keys"
);
return
false
;
}
...
...
@@ -588,14 +596,14 @@ module LibItsPki_Functions {
in
HashedId8
p_eaHashedId8
,
in
boolean
p_itss_privacy
,
out
octetstring
p_private_enc_key
,
out
octetstring
p_publicEncKeyX
,
out
octetstring
p_publicEncKeyY
,
out
octetstring
p_publicEncKeyCompressed
,
out
integer
p_compressedMode
,
out
InnerAtRequest
p_inner_at_request
,
out
Ieee1609Dot2Data
p_inner_at_request_data
)
return
boolean
{
// Local variables
var
octetstring
public_enc_key_x
;
var
octetstring
public_enc_key_y
;
var
template
(
value
)
EccP256CurvePoint
v_eccP256_curve_point
;
var
Oct32
v_hmac_key
;
var
octetstring
v_message_to_tag
;
...
...
@@ -607,7 +615,7 @@ module LibItsPki_Functions {
var
Ieee1609Dot2Data
v_signed_ec_signature
;
// Generate encryption keys for the certificate to be requested
if
(
f_generate_key_pair_nistp256
(
p_private_enc_key
,
p_
public
EncKeyX
,
p_
public
EncKeyY
,
p_publicEncKeyCompressed
,
p_compressedMode
)
==
false
)
{
if
(
f_generate_key_pair_nistp256
(
p_private_enc_key
,
public
_enc_key_x
,
public
_enc_key_y
,
p_publicEncKeyCompressed
,
p_compressedMode
)
==
false
)
{
return
false
;
}
if
(
p_compressedMode
==
0
)
{
...
...
@@ -785,14 +793,16 @@ module LibItsPki_Functions {
in
Certificate
p_certificate
,
out
AuthorizationValidationRequest
p_authorization_validation_request
)
return
boolean
{
// TODO
return
false
;
p_authorization_validation_request
.
sharedAtRequest
:=
p_inner_at_request
.
sharedAtRequest
;
p_authorization_validation_request
.
ecSignature
:=
p_inner_at_request
.
ecSignature
;
return
true
;
}
// End of function f_generate_authorization_validation_request
function
f_generate_authorization_validation_response
(
in
InnerAtRequest
p_inner_at_request
,
in
Certificate
p_certificate
,
out
AuthorizationValidationRe
quest
p_authorization_validation_re
quest
out
AuthorizationValidationRe
sponse
p_authorization_validation_re
sponse
)
return
boolean
{
// TODO
return
false
;
...
...
ttcn/Pki/LibItsPki_Pics.ttcn
View file @
b31f565a
...
...
@@ -21,10 +21,20 @@ module LibItsPki_Pics {
modulepar
charstring
PICS_IUT_CERTIFICATE_ID
:=
"CERT_IUT_A_EA"
;
/**
* @desc Certificate used by the Test System
* @desc Certificate used by the Test System
acting as ITS-S
*/
modulepar
charstring
PICS_TS_CERTIFICATE_ID
:=
"CERT_TS_A_EA"
;
/**
* @desc Certificate used by the Test System acting as EA
*/
modulepar
charstring
PICS_TS_EA_CERTIFICATE_ID
:=
"CERT_TS_A_EA"
;
/**
* @desc Certificate used by the Test System acting as AA
*/
modulepar
charstring
PICS_TS_AA_CERTIFICATE_ID
:=
"CERT_TS_A_EA"
;
/**
* @desc Certificate used by the Test System
*/
...
...
ttcn/Pki/LibItsPki_Templates.ttcn
View file @
b31f565a
...
...
@@ -78,6 +78,11 @@ module LibItsPki_Templates {
)
modifies
m_etsiTs103097Data_encrypted
:=
{
}
// End of template m_authorizationValidationRequestMessage
template
(
present
)
EtsiTs103097Data
mw_authorizationValidationResponseMessage
(
template
(
present
)
EncryptedData
p_encryptedData
:=
?
)
modifies
mw_etsiTs103097Data_encrypted
:=
{
}
// End of template mw_authorizationValidationResponseMessage
template
(
present
)
EnrolmentRequestMessage
mw_enrolmentRequestMessage
(
template
(
present
)
EncryptedData
p_encryptedData
:=
?
)
modifies
mw_etsiTs103097Data_encrypted
:=
{
...
...
@@ -201,7 +206,7 @@ module LibItsPki_Templates {
in
template
(
omit
)
GeographicRegion
p_region
:=
omit
,
in
template
(
omit
)
SubjectAssurance
p_assuranceLevel
:=
omit
)
:=
{
id
:=
{
none_
:=
NULL
},
id
:=
{
none_
:=
NULL
},
validityPeriod
:=
p_validityPeriod
,
region
:=
p_region
,
assuranceLevel
:=
p_assuranceLevel
,
...
...
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