ExIcaoVds.Header
(ex_icao_vds v0.3.2)
Copy Markdown
VDS header struct and binary encoder/decoder.
Binary format
<<
0xDC, # magic constant (1 byte)
version, # 0x04 (1 byte)
country_c40::2, # C40 of 3-char ISO country code (2 bytes)
signer_id_len, # byte length of following C40 (1 byte)
signer_id_c40::n, # C40-encoded signer identifier (n bytes)
ref_type, # 0x01 = key_reference, 0x02 = cert_reference (1 byte)
ref_len, # byte length of reference (1 byte)
ref::m, # raw reference bytes (m bytes)
issue_bcd_day, # document issue date, BCD (1 byte)
issue_bcd_month, # BCD (1 byte)
issue_bcd_year, # year (00–99, century inferred by pivot), BCD (1 byte)
sig_bcd_day, # signature creation date, BCD (1 byte)
sig_bcd_month, # BCD (1 byte)
sig_bcd_year, # year (00–99, century inferred by pivot), BCD (1 byte)
feature_definition_reference, # (1 byte)
document_type_category # ASCII char code (1 byte)
>>BCD encoding: each byte stores a two-decimal-digit value as
high_nibble * 10 + low_nibble, e.g. day 28 → 0x28.
The ref_type byte distinguishes key-reference mode (public_key / pinned_key)
from certificate-reference mode (x509). The trust_mode field in the struct
mirrors this distinction.
Summary
Functions
Decodes header bytes from the start of bytes.
Returns {:ok, header, remaining_bytes} or {:error, ExIcaoVds.Error.t()}.
Encodes a Header struct into binary bytes.
Returns {:ok, binary} or {:error, ExIcaoVds.Error.t()}.
Types
@type t() :: %ExIcaoVds.Header{ certificate_reference: binary() | nil, document_issue_date: Date.t() | nil, document_type_category: String.t(), feature_definition_reference: non_neg_integer(), issuing_country: String.t(), key_reference: String.t() | nil, magic_constant: non_neg_integer(), raw: binary() | nil, signature_creation_date: Date.t() | nil, signer_identifier: String.t(), trust_mode: trust_mode(), version: non_neg_integer() }
@type trust_mode() :: :x509 | :public_key | :pinned_key | :custom
Functions
@spec decode(binary()) :: {:ok, t(), binary()} | {:error, ExIcaoVds.Error.t()}
Decodes header bytes from the start of bytes.
Returns {:ok, header, remaining_bytes} or {:error, ExIcaoVds.Error.t()}.
@spec encode(t()) :: {:ok, binary()} | {:error, ExIcaoVds.Error.t()}
Encodes a Header struct into binary bytes.
Returns {:ok, binary} or {:error, ExIcaoVds.Error.t()}.