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
033af58d
Commit
033af58d
authored
Oct 27, 2016
by
garciay
Browse files
Major bug fixed in secured beacons
parent
15777646
Changes
1
Hide whitespace changes
Inline
Side-by-side
javasrc/adapter/org/etsi/its/adapter/ports/GnPort.java
View file @
033af58d
...
...
@@ -123,12 +123,8 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
basicHeader
[
0
]
&=
0xFE
;
basicHeader
[
0
]
|=
0x02
;
// Secured mode
// Update the beacon timestamp field
byte
[]
beacon
=
ByteHelper
.
concat
(
ByteHelper
.
extract
(
p_beacon
,
4
,
16
),
// Extract Common Header + GN address
p_tst
,
// Update the timestamp field
ByteHelper
.
extract
(
p_beacon
,
20
,
p_beacon
.
length
-
4
-
20
)
// Add remaining bytes
);
// Basic Header is not part of signed data
byte
[]
beacon
=
ByteHelper
.
extract
(
p_beacon
,
4
,
p_beacon
.
length
-
4
);
//TERFactory.getInstance().logDebug("GnPort.buildSecuredBeacon (2): " + ByteHelper.byteArrayToString(beacon));
// Prepare the message to be signed
byte
[]
toBeSignedData
=
buildToBeSignedData
(
beacon
,
p_currentTime
,
p_sendDigest
);
...
...
@@ -225,7 +221,7 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
byte
[]
signatureBytes
;
try
{
signatureBytes
=
CryptoLib
.
signWithEcdsaNistp256WithSha256
(
p_toBeSignedData
,
management
.
getSigningPrivateKey
());
//
//TERFactory.getInstance().logDebug("GnPort.signSecuredMessage: signatureBytes=" + ByteHelper.byteArrayToString(signatureBytes));
//TERFactory.getInstance().logDebug("GnPort.signSecuredMessage: signatureBytes=" + ByteHelper.byteArrayToString(signatureBytes));
// Add signature
securedBeaconHeader
=
ByteHelper
.
concat
(
p_toBeSignedData
,
...
...
@@ -297,18 +293,24 @@ public class GnPort extends ProtocolPort implements Runnable, IEthernetSpecific
int
sopvPos
=
12
;
if
(
headerType
!=
HT_BEACON
&&
!(
headerType
==
HT_TSB
&&
headerSubType
==
HST_SHB
)
)
{
sopvPos
+=
4
;
}
System
.
arraycopy
(
message
,
sopvPos
,
sopv
,
0
,
24
);
}
try
{
System
.
arraycopy
(
message
,
sopvPos
,
sopv
,
0
,
24
);
}
catch
(
IndexOutOfBoundsException
e
)
{
// Decoding issue
return
;
}
//TERFactory.getInstance().logDebug("GnPort.receive: sopv=" + ByteHelper.byteArrayToString(sopv));
// Security disable, null will be translated into omit
lowerInfo
.
put
(
SecurityHelper
.
SEC_SSP
,
null
);
lowerInfo
.
put
(
SecurityHelper
.
SEC_ITS_AID
,
null
);
}
else
if
((
basicHdr
[
0
]
&
0x0f
)
==
0x02
)
{
// Secured tag
byte
[]
payload
=
SecurityHelper
.
getInstance
().
checkSecuredProfileAndExtractPayload
(
message
,
basicHdr
.
length
,
management
.
isEnforceSecuredModeSet
(),
management
.
getItsAidOther
(),
lowerInfo
);
if
(
payload
!=
null
)
{
//
//TERFactory.getInstance().logDebug("GnPort.receive: payload=" + ByteHelper.byteArrayToString(payload));
//TERFactory.getInstance().logDebug("GnPort.receive: payload=" + ByteHelper.byteArrayToString(payload));
byte
[]
commonHdr
=
new
byte
[
8
];
System
.
arraycopy
(
payload
,
0
,
commonHdr
,
0
,
8
);
//
//TERFactory.getInstance().logDebug("GnPort.receive: commonHdr=" + ByteHelper.byteArrayToString(commonHdr));
//TERFactory.getInstance().logDebug("GnPort.receive: commonHdr=" + ByteHelper.byteArrayToString(commonHdr));
byte
[]
htHst
=
new
byte
[
1
];
System
.
arraycopy
(
commonHdr
,
1
,
htHst
,
0
,
1
);
headerType
=
(
int
)(
htHst
[
0
]
>>
4
);
...
...
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