Karta.Auth.ARC (Karta v1.0.0)

Validation of a message's Authenticated Received Chain (ARC, RFC 8617 §5.2) on the bytes of the message as received. Karta.Auth.ARC.Sealer adds a set.

The algorithm, in order; the first step that fails ends it with fail (Karta.Auth.ARC.Result says why):

  1. Collect the ARC header fields. None: none. More than 150 fields, or an instance above 50: fail (at most 50 sets), before anything else is parsed.
  2. The ARC-Seal of the highest instance says cv=fail: fail.
  3. The structure: every field parses (Karta.Auth.ARC.Signature); instances 1 to N without a gap; exactly one ARC-Authentication- Results, ARC-Message-Signature and ARC-Seal per instance; the seal of instance 1 says cv=none, every later one cv=pass.
  4. The newest ARC-Message-Signature (instance N) verifies, as a DKIM signature does (Karta.Auth.DKIM.Canonical), on the whole message without itself. One whose l= leaves part of the body unsigned does not verify.
  5. Every ARC-Seal verifies, from N down to 1: the seal of instance i signs, with relaxed canonicalisation, the ARC-Authentication- Results, ARC-Message-Signature and ARC-Seal fields of instances 1 to i, in that order, its own without the b= value.
  6. pass; then the oldest instance whose ARC-Message-Signature still verifies (oldest_pass, the optional step 5 of §5.2), going down from N - 1: the first one that does not verify, or cannot be checked (a lookup error, the deadline), ends the walk.

Bounded work. At most 50 sets: at most 100 key lookups (each key name is looked up once per validation) and 100 signature checks, and the body is canonicalised at most twice (once per body canonicalisation). Keys are DKIM key records (Karta.Auth.DKIM.KeyRecord: RSA of 1024 to 8192 bits, or Ed25519); a key whose type differs from the signature's algorithm does not verify. With a :deadline, no lookup starts after it: the chain fails with :timeout.

Every error, a DNS failure included, makes the chain fail (§5.2.1).

Options: :dns (options for Karta.DNS.lookup/3), :deadline (a System.monotonic_time(:millisecond) value), :header_limits (options for Karta.Mail.Headers.split/2).

Summary

Functions

The kind of an ARC header field (:results, :message_signature or :seal), or nil.

Validates the ARC chain of message.

Functions

kind(header)

@spec kind(Karta.Mail.Header.t()) :: :results | :message_signature | :seal | nil

The kind of an ARC header field (:results, :message_signature or :seal), or nil.

validate(message, opts \\ [])

@spec validate(binary(), keyword()) :: Karta.Auth.ARC.Result.t()

Validates the ARC chain of message.