Karta.Auth.ARC.Signature (Karta v1.0.0)

The value of an ARC-Message-Signature (AMS) or ARC-Seal (AS) header field (RFC 8617 §4.1.2, §4.1.3), parsed and checked, and the instance of an ARC-Authentication-Results (AAR) field (§4.1.1).

Both signatures are DKIM tag lists (RFC 6376 §3.2, Karta.Auth.DKIM.TagList) in which the instance tag i= (§4.2.1: one or two digits, at least 1) takes the place of DKIM's identity. Tag names and values are case-sensitive; an empty element between two semicolons makes the list invalid (only a final semicolon is allowed); unknown tags are ignored.

  • AMS - required: i, a (rsa-sha256 or ed25519-sha256), b, bh, d, h and s; optional: c, l and t. A v tag is ignored (§4.1.2). Without c, the canonicalisation is relaxed/relaxed, as dkimpy and the ARC test suite have it (DKIM's default would be simple/simple; sealers set c in practice). Unlike DKIM, h= may be empty and need not name From; empty names in it are ignored; naming ARC-Seal makes it invalid (the seal of the same set is added after the signature, §5.1).
  • AS - required: i, a, b, cv (none, pass or fail), d and s; optional: t. Its signature always uses relaxed header canonicalisation; an h tag makes it invalid (§4.1.3).

Domains are kept in lower-case ASCII form, selectors in lower case. The instance may be up to 99 here; that a chain has at most 50 sets is the validator's rule (Karta.Auth.ARC).

Summary

Types

Why a field is unusable; any of them makes the chain fail.

t()

Functions

The instance of an ARC-Message-Signature or ARC-Seal value whose tag list parses and whose i= is valid, even when the rest of it is not; otherwise nil. The highest instance found decides the next one (§5.1).

Parses the value of an ARC-Message-Signature field.

Parses the value of an ARC-Seal field.

The instance of an ARC-Authentication-Results field and the rest of its value (the authentication results): the value must start with i=, one or two digits (at least 1) and a semicolon, white space allowed around each (§4.1.1).

Types

error()

@type error() ::
  :syntax
  | :missing_tag
  | :bad_instance
  | :unsupported_algorithm
  | :bad_canonicalization
  | :bad_domain
  | :bad_selector
  | :bad_headers
  | :bad_length
  | :bad_timestamp
  | :bad_base64
  | :bad_cv
  | :h_in_seal

Why a field is unusable; any of them makes the chain fail.

kind()

@type kind() :: :message_signature | :seal

t()

@type t() :: %Karta.Auth.ARC.Signature{
  algorithm: :rsa_sha256 | :ed25519_sha256,
  body_hash: binary() | nil,
  canonicalization:
    {Karta.Auth.DKIM.Canonical.algorithm(),
     Karta.Auth.DKIM.Canonical.algorithm()},
  cv: :none | :pass | :fail | nil,
  domain: String.t(),
  headers: [String.t()],
  instance: pos_integer(),
  kind: kind(),
  length: non_neg_integer() | nil,
  selector: String.t(),
  signature: binary(),
  timestamp: non_neg_integer() | nil
}

Functions

instance(value)

@spec instance(binary()) :: pos_integer() | nil

The instance of an ARC-Message-Signature or ARC-Seal value whose tag list parses and whose i= is valid, even when the rest of it is not; otherwise nil. The highest instance found decides the next one (§5.1).

parse_message_signature(value)

@spec parse_message_signature(binary()) :: {:ok, t()} | {:error, error()}

Parses the value of an ARC-Message-Signature field.

parse_seal(value)

@spec parse_seal(binary()) :: {:ok, t()} | {:error, error()}

Parses the value of an ARC-Seal field.

results_instance(value)

@spec results_instance(binary()) ::
  {:ok, pos_integer(), binary()} | {:error, :bad_instance}

The instance of an ARC-Authentication-Results field and the rest of its value (the authentication results): the value must start with i=, one or two digits (at least 1) and a semicolon, white space allowed around each (§4.1.1).