Sovite.DKIM.Tags (sovite v0.6.0)

Copy Markdown View Source

DKIM tag lists (RFC 6376 §3.2): tag=value pairs separated by ;, as used by DKIM-Signature: fields, key records, and the ARC fields.

iex> Sovite.DKIM.Tags.parse("v=1; a=rsa-sha256;\r\n\td=example.com;")
{:ok, %{"v" => "1", "a" => "rsa-sha256", "d" => "example.com"}}

Folding whitespace around tags and values is removed; inside values it is kept (base64 values drop it with strip_whitespace/1). Tag names are case-sensitive. A duplicate tag makes the whole list invalid.

Summary

Functions

Returns the raw field raw with the value of its b= tag emptied, whitespace around it included, as signing and verifying need (RFC 6376 §3.7). Everything else is kept byte for byte.

Parses a tag list into a map of tag names to values.

Removes all whitespace, for base64 values.

Removes folding whitespace from both ends of text.

Functions

empty_b(raw)

@spec empty_b(String.t()) :: String.t()

Returns the raw field raw with the value of its b= tag emptied, whitespace around it included, as signing and verifying need (RFC 6376 §3.7). Everything else is kept byte for byte.

iex> Sovite.DKIM.Tags.empty_b("DKIM-Signature: a=x; b=abc\r\n def; bh=y\r\n")
"DKIM-Signature: a=x; b=; bh=y\r\n"

parse(text)

@spec parse(String.t()) :: {:ok, %{required(String.t()) => String.t()}} | :error

Parses a tag list into a map of tag names to values.

strip_whitespace(text)

@spec strip_whitespace(String.t()) :: String.t()

Removes all whitespace, for base64 values.

trim(text)

@spec trim(String.t()) :: String.t()

Removes folding whitespace from both ends of text.