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
7e714d0e
Commit
7e714d0e
authored
Sep 26, 2014
by
garciay
Browse files
Starting review of AtsSecurity TCs
parent
97a6d123
Changes
2
Hide whitespace changes
Inline
Side-by-side
ttcn/GeoNetworking/LibItsGeoNetworking_Functions.ttcn
View file @
7e714d0e
...
...
@@ -146,6 +146,9 @@ module LibItsGeoNetworking_Functions {
f_connect4SelfOrClientSync
();
activate
(
a_cf01Down
());
// Initialise secured mode
f_initialiseSecuredMode
();
//Initialze the IUT
f_initialState
();
...
...
@@ -156,11 +159,10 @@ module LibItsGeoNetworking_Functions {
}
// end f_cf01Up
/**
* @desc Deletes configuration cf01
*/
function
f_cf01Down
()
runs
on
ItsGeoNetworking
{
f_uninitialiseSecuredMode
();
// Unmap
unmap
(
self
:
acPort
,
system
:
acPort
);
unmap
(
self
:
utPort
,
system
:
utPort
);
...
...
@@ -213,6 +215,9 @@ module LibItsGeoNetworking_Functions {
//Initialze the IUT
if
(
p_mainUtComponent
==
c_compMTC
)
{
// Initialise secured mode
f_initialiseSecuredMode
();
// MTC intializes IUT
f_initialState
();
}
...
...
@@ -240,8 +245,11 @@ module LibItsGeoNetworking_Functions {
*/
function
f_cf02Down
()
runs
on
ItsMtc
{
// Local variables
var
integer
i
;
f_uninitialiseSecuredMode
();
// Unmap & Disconnect
for
(
i
:=
0
;
i
<
lengthof
(
vc_componentTable
);
i
:=
i
+
1
)
{
unmap
(
vc_componentTable
[
i
].
gnComponent
:
utPort
,
system
:
utPort
);
...
...
@@ -297,6 +305,9 @@ module LibItsGeoNetworking_Functions {
//Initialze the IUT
if
(
p_mainUtComponent
==
c_compMTC
)
{
// Initialise secured mode
f_initialiseSecuredMode
();
// MTC intializes IUT
f_initialState
();
}
...
...
@@ -324,8 +335,11 @@ module LibItsGeoNetworking_Functions {
*/
function
f_cf03Down
()
runs
on
ItsMtc
{
// Local variables
var
integer
i
;
f_uninitialiseSecuredMode
();
// Unmap & Disconnect
for
(
i
:=
0
;
i
<
lengthof
(
vc_componentTable
);
i
:=
i
+
1
)
{
unmap
(
vc_componentTable
[
i
].
gnComponent
:
utPort
,
system
:
utPort
);
...
...
@@ -383,6 +397,9 @@ module LibItsGeoNetworking_Functions {
//Initialze the IUT
if
(
p_mainUtComponent
==
c_compMTC
)
{
// Initialise secured mode
f_initialiseSecuredMode
();
// MTC intializes IUT
f_initialState
();
}
...
...
@@ -410,8 +427,11 @@ module LibItsGeoNetworking_Functions {
*/
function
f_cf04Down
()
runs
on
ItsMtc
{
// Local variables
var
integer
i
;
f_uninitialiseSecuredMode
();
// Unmap & Disconnect
for
(
i
:=
0
;
i
<
lengthof
(
vc_componentTable
);
i
:=
i
+
1
)
{
unmap
(
vc_componentTable
[
i
].
gnComponent
:
utPort
,
system
:
utPort
);
...
...
@@ -465,6 +485,9 @@ module LibItsGeoNetworking_Functions {
//Initialze the IUT
if
(
p_mainUtComponent
==
c_compMTC
)
{
// Initialise secured mode
f_initialiseSecuredMode
();
// MTC intializes IUT
f_initialState
();
}
...
...
@@ -491,8 +514,11 @@ module LibItsGeoNetworking_Functions {
*/
function
f_cf05Down
()
runs
on
ItsMtc
{
// Local variables
var
integer
i
;
f_uninitialiseSecuredMode
();
// Unmap & Disconnect
for
(
i
:=
0
;
i
<
lengthof
(
vc_componentTable
);
i
:=
i
+
1
)
{
unmap
(
vc_componentTable
[
i
].
gnComponent
:
utPort
,
system
:
utPort
);
...
...
@@ -547,6 +573,9 @@ module LibItsGeoNetworking_Functions {
//Initialze the IUT
if
(
p_mainUtComponent
==
c_compMTC
)
{
// Initialise secured mode
f_initialiseSecuredMode
();
// MTC intializes IUT
f_initialState
();
}
...
...
@@ -573,8 +602,11 @@ module LibItsGeoNetworking_Functions {
*/
function
f_cf06Down
()
runs
on
ItsMtc
{
// Local variables
var
integer
i
;
f_uninitialiseSecuredMode
();
// Unmap & Disconnect
for
(
i
:=
0
;
i
<
lengthof
(
vc_componentTable
);
i
:=
i
+
1
)
{
unmap
(
vc_componentTable
[
i
].
gnComponent
:
utPort
,
system
:
utPort
);
...
...
@@ -628,6 +660,9 @@ module LibItsGeoNetworking_Functions {
//Initialze the IUT
if
(
p_mainUtComponent
==
c_compMTC
)
{
// Initialise secured mode
f_initialiseSecuredMode
();
// MTC intializes IUT
f_initialState
();
}
...
...
@@ -654,8 +689,11 @@ module LibItsGeoNetworking_Functions {
*/
function
f_cf07Down
()
runs
on
ItsMtc
{
// Local variables
var
integer
i
;
f_uninitialiseSecuredMode
();
// Unmap & Disconnect
for
(
i
:=
0
;
i
<
lengthof
(
vc_componentTable
);
i
:=
i
+
1
)
{
unmap
(
vc_componentTable
[
i
].
gnComponent
:
utPort
,
system
:
utPort
);
...
...
@@ -667,7 +705,7 @@ module LibItsGeoNetworking_Functions {
unmap
(
self
:
utPort
,
system
:
utPort
);
disconnect
(
self
:
syncPort
,
mtc
:
syncPort
);
}
// end f_cf0
6
Down
}
// end f_cf0
y
Down
/**
* @desc Behavior function for initializing component's variables and tables
...
...
@@ -693,9 +731,6 @@ module LibItsGeoNetworking_Functions {
function
f_startBeingNeighbour
()
runs
on
ItsGeoNetworking
{
vc_neighbourDefault
:=
activate
(
a_neighbourDefault
());
if
(
PICS_SECURED_MODE
==
true
)
{
f_acEnableSecurity
();
}
f_acTriggerEvent
(
m_startBeaconing
(
m_beaconHeader
(
f_getPosition
(
vc_componentName
)).
beaconHeader
));
f_sleepIgnoreDef
(
PX_NEIGHBOUR_DISCOVERY_DELAY
);
}
// end f_startBeingNeighbour
...
...
@@ -706,13 +741,25 @@ module LibItsGeoNetworking_Functions {
function
f_stopBeingNeighbour
()
runs
on
ItsGeoNetworking
{
f_acTriggerEvent
(
m_stopBeaconing
);
if
(
PICS_SECURED_MODE
==
true
)
{
f_acDisableSecurity
();
}
deactivate
(
vc_neighbourDefault
);
}
// end f_stopBeingNeighbour
/**
* @desc Initialise secure mode if required
*/
function
f_initialiseSecuredMode
()
runs
on
ItsBaseGeoNetworking
{
if
(
PICS_SECURED_MODE
==
true
)
{
f_acEnableSecurity
();
}
}
// End of function f_initialiseSecuredMode()
function
f_uninitialiseSecuredMode
()
runs
on
ItsBaseGeoNetworking
{
if
(
PICS_SECURED_MODE
==
true
)
{
f_acDisableSecurity
();
}
}
// End of function f_initialiseSecuredMode()
}
// end geoConfigurationFunctions
group
componentFunctions
{
...
...
@@ -1052,7 +1099,7 @@ module LibItsGeoNetworking_Functions {
in
float
p_squareMeters
)
return
float
{
log
(
"*** f_distance: INFO: calling fx_computeRadiusFromCircularArea() ***"
);
//
log("*** f_distance: INFO: calling fx_computeRadiusFromCircularArea() ***");
return
fx_computeRadiusFromCircularArea
(
p_squareMeters
);
}
...
...
@@ -1068,7 +1115,7 @@ module LibItsGeoNetworking_Functions {
in
LongPosVector
p_pointB
)
return
float
{
log
(
"*** f_distance: INFO: calling fx_computeDistance() ***"
);
//
log("*** f_distance: INFO: calling fx_computeDistance() ***");
return
fx_computeDistance
(
p_pointA
.
latitude
,
p_pointA
.
longitude
,
p_pointB
.
latitude
,
p_pointB
.
longitude
);
}
...
...
@@ -1512,7 +1559,6 @@ module LibItsGeoNetworking_Functions {
f_utInitializeIut
(
m_gnInitialize
);
}
/**
* @desc Receive and reply to LS Requests
* @param p_reqSeqNumber Expected sequence number of the received LS Request
...
...
@@ -1665,7 +1711,9 @@ module LibItsGeoNetworking_Functions {
* @desc Triggers test adapter to enable security support
* @return FncRetCode
*/
function
f_acEnableSecurity
()
runs
on
ItsGeoNetworking
return
FncRetCode
{
function
f_acEnableSecurity
()
runs
on
ItsBaseGeoNetworking
return
FncRetCode
{
// Local variables
var
template
(
value
)
ToBeSignedSecuredMessage
v_toBeSignedSecuredMessage
;
// Build the beacon template
...
...
@@ -1688,7 +1736,7 @@ module LibItsGeoNetworking_Functions {
* @desc Triggers test adapter to disable security support
* @return FncRetCode
*/
function
f_acDisableSecurity
()
runs
on
ItsGeoNetworking
return
FncRetCode
{
function
f_acDisableSecurity
()
runs
on
Its
Base
GeoNetworking
return
FncRetCode
{
return
f_acTriggerEvent
(
AcGnPrimitive
:
{
acDisableSecurity
:=
m_disableSecurity
}
);
...
...
@@ -2297,15 +2345,18 @@ module LibItsGeoNetworking_Functions {
* @desc Receive GN message with security containing certificate as a signer info
* @param p_cert returns the certificate used for sign received message
*/
altstep
a_securedMessageWithCertificate
(
out
SecuredMessage
p_received
altstep
a_securedMessageWithCertificate
(
out
SecuredMessage
p_received
)
runs
on
ItsGeoNetworking
{
var
SecuredMessage
v_secMsg
;
[]
a_securedMessage
(
[]
a_securedMessage
(
mw_securedMessage
(
superset
(
mw_header_field_signer_info_certificate
)),
p_received
)
{}
}
)
{
//Nothing to do
}
}
// End of altstep a_securedMessageWithCertificate
/**
* @desc Receive GN message with security containing certificate chain as a signer info
...
...
@@ -2350,7 +2401,7 @@ module LibItsGeoNetworking_Functions {
alt
{
[]
a_securedMessageWithCertificate
(
v_recv
){
var
SignerInfo
v_si
;
if
(
f_getMsgSignerInfo
(
v_recv
,
v_si
)){
if
(
f_getMsgSignerInfo
(
v_recv
,
v_si
))
{
p_cert
:=
v_si
.
signerInfo
.
certificate
;
v_ret
:=
true
;
}
...
...
ttcn/Security/LibItsSecurity_Functions.ttcn3
View file @
7e714d0e
...
...
@@ -110,7 +110,9 @@ module LibItsSecurity_Functions {
return
p_cert
.
signer_infos
[
v_counter
].
signerInfo
.
digest
;
}
}
// End of 'for' statement
// digest not found, compute it
// Digest not found, compute it
log
(
"f_calculateDigestFromCertificate: Not found in certificate, compute it"
);
v_toBeHashedData
:=
bit2oct
(
encvalue
(
p_cert
));
v_hash
:=
f_hashWithSha256
(
v_toBeHashedData
);
return
substr
(
v_hash
,
lengthof
(
v_hash
)
-
8
,
8
);
...
...
@@ -658,9 +660,12 @@ module LibItsSecurity_Functions {
for
(
var
integer
i
:=
0
;
i
<
v_length
;
i
:=
i
+
1
)
{
if
(
valueof
(
p_securedMessage
).
header_fields
[
i
].
type_
==
p_headerFieldType
)
{
p_return
:=
valueof
(
p_securedMessage
).
header_fields
[
i
];
// log("f_getMsgHeaderField: p_return=", p_return);
return
true
;
}
}
log
(
"f_getMsgHeaderField: return false"
);
return
false
;
}
...
...
@@ -672,12 +677,16 @@ module LibItsSecurity_Functions {
out
SignerInfo
p_signerInfo
)
return
boolean
{
var
HeaderField
v_hf
;
if
(
f_getMsgHeaderField
(
p_securedMessage
,
e_signer_info
,
v_hf
)){
if
(
isbound
(
v_hf
.
headerField
.
signer
)){
if
(
f_getMsgHeaderField
(
p_securedMessage
,
e_signer_info
,
v_hf
)
==
true
)
{
if
(
isbound
(
v_hf
.
headerField
.
signer
))
{
p_signerInfo
:=
v_hf
.
headerField
.
signer
;
log
(
"f_getMsgSignerInfo: p_signerInfo="
,
p_signerInfo
);
return
true
;
}
}
log
(
"f_getMsgSignerInfo: return false"
);
return
false
;
}
...
...
@@ -703,7 +712,7 @@ module LibItsSecurity_Functions {
in
template
(
value
)
Certificate
p_cert
,
out
SignerInfo
p_si
)
return
boolean
{
if
(
isbound
(
valueof
(
p_cert
).
signer_infos
)
if
(
isbound
(
valueof
(
p_cert
).
signer_infos
)
and
lengthof
(
p_cert
.
signer_infos
)
>
0
)
{
p_si
:=
valueof
(
p_cert
).
signer_infos
[
0
];
return
true
;
...
...
@@ -838,7 +847,7 @@ module LibItsSecurity_Functions {
* @return The decimal coordinate on success, 0.0, otherwise
* @verdict Unchanged
*/
external
function
fx_dms2dd
(
in
i
nt
eger
p_degrees
,
in
i
nt
eger
p_minutes
,
in
float
p_seconds
,
in
charstring
p_latlon
)
return
float
;
external
function
fx_dms2dd
(
in
I
nt
p_degrees
,
in
I
nt
p_minutes
,
in
float
p_seconds
,
in
Oct1
p_latlon
)
return
float
;
}
// End of group geodesic
...
...
@@ -1078,14 +1087,17 @@ module LibItsSecurity_Functions {
*/
function
f_dms2dd
(
in
integer
p_degrees
,
in
integer
p_minutes
,
in
float
p_seconds
,
in
charstring
p_latlon
)
return
float
{
var
Oct1
v_latlon
;
// Sanity checks
if
(
lengthof
(
p_latlon
)
!=
1
)
{
return
0.0
;
}
else
if
((
p_latlon
!=
"N"
)
and
(
p_latlon
!=
"S"
)
and
(
p_latlon
!=
"E"
)
and
(
p_latlon
!=
"W"
))
{
return
0.0
;
}
v_latlon
:=
char2oct
(
p_latlon
);
return
fx_dms2dd
(
p_degrees
,
p_minutes
,
p_seconds
,
p
_latlon
);
return
fx_dms2dd
(
p_degrees
,
p_minutes
,
p_seconds
,
v
_latlon
);
}
// End of function f_dms2dd
/**
...
...
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