DKIM signatures (RFC 6376), with the algorithm rules of RFC 8301 and Ed25519 keys (RFC 8463).
verify/2 checks every DKIM-Signature header of a message. sign/2 adds
one or more. generate_key/2 makes a key and the TXT record to publish.
Verify options
:max_signatures: how many signatures to check, in order. Default 5. The rest are:none, reason:too_many_signatures:min_key_bits: the smallest RSA key that can pass. Default 1024:allow_sha1: whentrue, anrsa-sha1signature can pass, with the warning:weak_algorithm. Defaultfalse:now: the time to checkx=against, in Unix seconds or aDateTime. Default: now:resolver,:deadline,:timeout: seeMailAuth.ResolverandMailAuth
Signer options
:domain(required): the signing domain,d=:selector(required): the selector,s=:private_key(required): PEM, a decoded:public_keyrecord, or{:ed25519, seed}:algorithm::rsa_sha256or:ed25519_sha256. Default: from the key:canonicalization: default{:relaxed, :relaxed}:headers: the header names to sign. Each is signed as many times as it appears. Default:default_headers/0:oversign: names listed once more than they appear, so no one can add another. Default["From", "Subject", "To", "Date"]:identity: thei=tag:expires_in: seconds until the signature expires, forx=:body_length: whentrue, setsl=to the length of the body. Unsafe: anyone can add text after the signed part. Defaultfalse:now: the signing time, fort=
Summary
Functions
The headers signed by default.
Generates a DKIM key: RSA (2048 bits by default) or Ed25519.
Signs raw and returns it with the new DKIM-Signature header on top.
Returns the DKIM-Signature header for raw, without a final line break.
Checks every DKIM-Signature header of raw, top to bottom.
Functions
@spec default_headers() :: [String.t()]
The headers signed by default.
@spec generate_key(:rsa | :ed25519, keyword()) :: %{ :private_key => String.t(), :dns_record => String.t(), optional(:dns_name) => String.t() }
Generates a DKIM key: RSA (2048 bits by default) or Ed25519.
Returns the private key as PEM and the TXT record to publish. With
:selector and :domain given, also returns the name to publish it at,
<selector>._domainkey.<domain>.
Options: :bits (RSA only), :selector, :domain.
Signs raw and returns it with the new DKIM-Signature header on top.
Pass a list of signer options to add several signatures at once, such as an RSA and an Ed25519 one. The first in the list ends up on top.
Returns the DKIM-Signature header for raw, without a final line break.
@spec verify(binary(), keyword()) :: [MailAuth.DKIM.Result.t()]
Checks every DKIM-Signature header of raw, top to bottom.
Returns one result per signature, in the order they appear. A message with
no signature gives [].