Stateful MAVLink 2 signing policy helpers.
This module validates parsed signed frames against a shared key, tracks
inbound replay state by {source_system, source_component, link_id}, and
signs unsigned outbound MAVLink 2 frames with a per-connection timestamp.
Optional timestamp load/save callbacks let applications preserve the local
signing timestamp across restarts.
Summary
Types
@type new_error() ::
:invalid_accept_unsigned
| :invalid_options
| :invalid_link_id
| :invalid_secret_key
| :invalid_timestamp
| :invalid_timestamp_load
| :invalid_timestamp_save
| :missing_link_id
| :missing_secret_key
| :timestamp_load_failed
@type sign_error() ::
:already_signed
| :checksum_invalid
| :invalid_crc_extra
| :invalid_link_id
| :invalid_mavlink_2_frame
| :invalid_secret_key
| :invalid_timestamp
| :mavlink_1_not_signable
| :missing_crc_extra
| :missing_mavlink_2_raw
| :timestamp_save_failed
| :timestamp_exhausted
| :unsupported_incompatible_flags
@type stream_key() :: {0..255, 0..255, 0..255}
@type t() :: %XMAVLink.Signing{ accept_unsigned: boolean(), link_id: 0..255, secret_key: <<_::256>>, stream_timestamps: %{required(stream_key()) => timestamp()}, timestamp: timestamp(), timestamp_load: timestamp_load() | nil, timestamp_save: timestamp_save() | nil }
@type timestamp() :: 0..281_474_976_710_655
@type timestamp_load() :: (-> timestamp_load_result()) | {module(), atom(), [term()]}
@type timestamp_save() :: (timestamp() -> timestamp_save_result()) | {module(), atom(), [term()]}
@type validate_error() ::
:invalid_mavlink_2_frame
| :invalid_secret_key
| :signature_invalid
| :signature_replay
| :signature_too_old
| :signed_frame_unsupported
| :timestamp_save_failed
| :unsigned_frame
| :unsigned_frame_rejected
Functions
@spec now_timestamp() :: timestamp()
@spec sign_outbound(XMAVLink.Frame.t(), t() | nil) :: {:ok, XMAVLink.Frame.t(), t() | nil} | {:error, sign_error(), t() | nil}
@spec validate_inbound(XMAVLink.Frame.t(), t() | nil) :: {:ok, XMAVLink.Frame.t(), t() | nil} | {:error, validate_error(), t() | nil}