Class MavV2Signator
java.lang.Object
de.wuespace.telestion.extension.mavlink.security.MavV2Signator
The
A signature contains:
This class is designed to be used in a static-context!
MavV2Signator
creates a "unique" 7 byte signature for MavlinkV2-Messages in according to the
specifications.A signature contains:
- 1 byte for the linkId
- 6 bytes for the timestamp
- 6 bytes for the actual signature (SHA256 hashed)
This class is designed to be used in a static-context!
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
generateSignature(byte[] secretKey, byte[] header, byte[] payload, int crcExtra, short linkId)
Creates the full 13 bytes signature for MAVLinkV2-Messages with a unique timestamp, the hashed signature and the linkId.static byte[]
Returns a MAVLink-Timestamp (which is a custom timestamp using 10 microseconds sincesecondJan2015
as a step) of the current time.static byte[]
rawSignature(byte[] secretKey, byte[] header, byte[] payload, int crcExtra, short linkId, byte[] timestamp)
Creates the raw 6 byte signature (SHA-256 hashed) for the given arguments according to the MAVLink-specifications.
-
Method Details
-
getTimestamp
public static byte[] getTimestamp()Returns a MAVLink-Timestamp (which is a custom timestamp using 10 microseconds sincesecondJan2015
as a step) of the current time.- Returns:
- MAVLink timestamp of the current time
-
rawSignature
public static byte[] rawSignature(byte[] secretKey, byte[] header, byte[] payload, int crcExtra, short linkId, byte[] timestamp) throws NoSuchAlgorithmExceptionCreates the raw 6 byte signature (SHA-256 hashed) for the given arguments according to the MAVLink-specifications.- Parameters:
secretKey
- key for the SHA-256 hash (→ must be exchanged on a secure channel)header
- of the MAVLink-Messagepayload
- of the MAVLink-MessagecrcExtra
- for the MAVLink-MessagelinkId
- of the messagetimestamp
- for the message- Returns:
- first 6 bytes of the SHA-256 hashed signature
- Throws:
NoSuchAlgorithmException
- at missing massage digest
-
generateSignature
public static byte[] generateSignature(byte[] secretKey, byte[] header, byte[] payload, int crcExtra, short linkId) throws NoSuchAlgorithmExceptionCreates the full 13 bytes signature for MAVLinkV2-Messages with a unique timestamp, the hashed signature and the linkId.- Parameters:
secretKey
- key for the SHA-256 hash (→ must be exchanged on a secure channel)header
- of the MAVLink-Messagepayload
- of the MAVLink-MessagecrcExtra
- for the MAVLink-MessagelinkId
- of the message- Returns:
- full 13 MAVLink-Signature
- Throws:
NoSuchAlgorithmException
- at missing massage digest
-