ExIcaoVds.Codec (ex_icao_vds v0.3.2)

Copy Markdown

Full VDS encode/decode: assembles and parses complete VDS byte sequences.

VDS wire format:

[header bytes] [message zone bytes] [0xFF] [algorithm] [sig_len] [signature]

The signed payload is header_bytes <> message_zone_bytes — everything before the 0xFF marker.

Summary

Functions

Decodes raw VDS bytes into {:ok, %{header, message_zone, signature_zone}}.

Encodes a complete VDS from its three zones. zones must be a map or keyword with :header, :message_zone, :signature_zone.

Low-level decode that does not verify the signature — suitable for inspection.

Returns the bytes that must be signed: header_bytes <> message_zone_bytes.

Functions

decode(bytes, opts \\ [])

@spec decode(
  binary(),
  keyword()
) ::
  {:ok,
   %{
     header: ExIcaoVds.Header.t(),
     message_zone: ExIcaoVds.MessageZone.t(),
     signature_zone: ExIcaoVds.SignatureZone.t()
   }}
  | {:error, ExIcaoVds.Error.t()}

Decodes raw VDS bytes into {:ok, %{header, message_zone, signature_zone}}.

Pass profile: and profile_config: opts to enable field-name decoding in the message zone.

encode(map)

@spec encode(map()) :: {:ok, binary()} | {:error, ExIcaoVds.Error.t()}

Encodes a complete VDS from its three zones. zones must be a map or keyword with :header, :message_zone, :signature_zone.

inspect_bytes(bytes, opts \\ [])

@spec inspect_bytes(
  binary(),
  keyword()
) :: {:ok, map()} | {:error, ExIcaoVds.Error.t()}

Low-level decode that does not verify the signature — suitable for inspection.

signing_payload(header, mz)

@spec signing_payload(ExIcaoVds.Header.t(), ExIcaoVds.MessageZone.t()) ::
  {:ok, binary()} | {:error, ExIcaoVds.Error.t()}

Returns the bytes that must be signed: header_bytes <> message_zone_bytes.