Sovite.DKIM.Verifier (sovite v0.6.0)

Copy Markdown View Source

Verifies the DKIM-Signature: fields of a message whose body is hashed as it streams by (RFC 6376 §6).

verifier = Sovite.DKIM.Verifier.new(fields)
body = Sovite.DKIM.Body.new(Sovite.DKIM.Verifier.body_specs(verifier))
body = Sovite.DKIM.Body.update(body, chunk)   # for each body chunk
results = Sovite.DKIM.Verifier.finish(verifier, Sovite.DKIM.Body.finish(body), resolver)

Results are in the order of the signatures in the header, top first.

Summary

Functions

The body hashes the signatures need.

Checks each signature, looking up keys with resolver.

Reads the signatures of header fields.

Types

t()

@type t() :: %Sovite.DKIM.Verifier{
  fields: [Sovite.Message.Headers.field()],
  signatures: [
    {:ok, Sovite.DKIM.Signature.t()} | {:error, String.t(), String.t()}
  ]
}

Functions

body_specs(verifier)

@spec body_specs(t()) :: [Sovite.DKIM.Body.spec()]

The body hashes the signatures need.

finish(verifier, hashes, resolver)

@spec finish(
  t(),
  %{required(Sovite.DKIM.Body.spec()) => {binary(), non_neg_integer()}},
  Sovite.DNS.resolver()
) :: [Sovite.DKIM.Result.t()]

Checks each signature, looking up keys with resolver.

new(fields, opts \\ [])

@spec new([Sovite.Message.Headers.field()], keyword()) :: t()

Reads the signatures of header fields.

Options

  • :max_signatures - signatures beyond this many are ignored, so a message cannot make the verifier do unbounded work. Defaults to 10.
  • :now - Unix seconds, for expired signatures. Defaults to now.