java.lang.Object
de.wuespace.telestion.extension.mavlink.security.MavV2Signator

public final class MavV2Signator extends Object
The 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 Type
    Method
    Description
    static 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 since secondJan2015 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getTimestamp

      public static byte[] getTimestamp()
      Returns a MAVLink-Timestamp (which is a custom timestamp using 10 microseconds since secondJan2015 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 NoSuchAlgorithmException
      Creates 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-Message
      payload - of the MAVLink-Message
      crcExtra - for the MAVLink-Message
      linkId - of the message
      timestamp - 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 NoSuchAlgorithmException
      Creates 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-Message
      payload - of the MAVLink-Message
      crcExtra - for the MAVLink-Message
      linkId - of the message
      Returns:
      full 13 MAVLink-Signature
      Throws:
      NoSuchAlgorithmException - at missing massage digest