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

Adds an ARC set to a message (RFC 8617 §5.1): an ARC-Authentication-Results (AAR), an ARC-Message-Signature (AMS) and an ARC-Seal (AS) field, with the instance after the highest one found.

What the set says comes from the message. The AAR carries the results of every Authentication-Results: field of the message that claims :authserv_id (Karta.Auth.AuthenticationResults.ours?/2), in order, joined into one (§4.1.1); the chain validation status of the seal (cv=) is the arc= result among them. Without such a field, or without an arc= result in it, nothing is sealed (:no_results): the sealer never vouches for a message it has no record of checking. An ARC-Authentication-Results: field that claims the same authserv-id is not one of them: only the newest sealer's own field is its own.

When nothing is added (an error): the newest ARC-Seal already says cv=fail (:chain_failed, §5.1 step 2); the next instance would be above 50 (:too_many_sets); the status contradicts the chain (:bad_chain: none with ARC fields present, pass without a complete chain).

What is signed. The AMS signs, with relaxed canonicalisation, the whole body and the header fields Karta.Auth.DKIM.Signer signs (From, Subject, Date, To, Cc and Reply-To oversigned, and so on), plus every DKIM-Signature field present (§4.1.2); never an Authentication-Results or ARC field. The AS signs the ARC fields of every earlier set and the new set's (§5.1.1); when the status is fail, only the new set's (§5.1.2).

The fields are written with the tags in the order of RFC 8617's examples (i= first), folded at tag boundaries, b= in lines of 72 characters. The signature is computed over the field exactly as it is written (folding included), so any folding verifies.

A specification is a keyword list:

  • :key - a Karta.Auth.DKIM.Key (RSA of at least 1024 bits, RFC 8301 §3.2, or Ed25519)
  • :domain - d=; :selector - s=
  • :authserv_id - the authserv-id whose results go into the AAR (a MIME token)
  • :headers - the AMS's h= names instead of the default (optional)
  • :form - :folded (the default) or :standardized: the tags in alphabetical order and b= in one piece, the form the ARC test suite's signing tests expect (dkimpy calls it standardize)

Options for the call: :now (Unix seconds, t=; default now).

The message must have only CRLF line endings.

Summary

Types

Why a message could not be sealed.

Functions

The ARC set for message: its ARC-Seal, ARC-Message-Signature and ARC-Authentication-Results fields, in that order.

message with its new ARC set in front.

Types

error()

@type error() ::
  Karta.Mail.Headers.error()
  | :bare_line_ending
  | :key_too_small
  | :bad_domain
  | :bad_selector
  | :bad_authserv_id
  | :bad_headers
  | :no_results
  | :bad_results
  | :chain_failed
  | :too_many_sets
  | :bad_chain

Why a message could not be sealed.

Functions

seal(message, spec, opts \\ [])

@spec seal(binary(), keyword(), keyword()) :: {:ok, binary()} | {:error, error()}

The ARC set for message: its ARC-Seal, ARC-Message-Signature and ARC-Authentication-Results fields, in that order.

seal_message(message, spec, opts \\ [])

@spec seal_message(binary(), keyword(), keyword()) ::
  {:ok, binary()} | {:error, error()}

message with its new ARC set in front.