SaltDns.Auth.TsigPolicy (Salt v1.0.0)

Which TSIG algorithms Salt DNS accepts, and how a mismatch is handled.

Allowed: hmac-sha256, hmac-sha384, hmac-sha512, spelled as dns_erlang spells them (?DNS_TSIG_ALG_SHA256 and friends in dns_terms.hrl: lower case, no trailing dot). hmac-md5.sig-alg.reg.int, hmac-sha1 and hmac-sha224 are never allowed.

Each key is pinned to one algorithm. A request signed with any other algorithm is BADKEY, even when that algorithm is itself allowed; this stops algorithm downgrades. Names from the wire are compared case-insensitively with one trailing dot removed.

Summary

Functions

The allowed algorithm names.

True when algorithm (any case, optional trailing dot) is allowed.

A one-line explanation for the BADKEY log entry. Many clients default to a weak algorithm (certbot-dns-rfc2136 to HMAC-MD5, lego to HMAC-SHA1).

Checks the algorithm a request presented against the one the key is pinned to. Any mismatch is {:error, :badkey}, as is a stored algorithm that is not allowed (a legacy or corrupt record).

A random shared secret for algorithm: as many random bytes as the hash output, base64-encoded (standard alphabet, padded, as in named.conf).

The normalised form of an algorithm name: lower case, no trailing dot.

Functions

algorithms()

@spec algorithms() :: [String.t()]

The allowed algorithm names.

allowed?(algorithm)

@spec allowed?(term()) :: boolean()

True when algorithm (any case, optional trailing dot) is allowed.

badkey_hint(stored, presented)

@spec badkey_hint(term(), term()) :: String.t()

A one-line explanation for the BADKEY log entry. Many clients default to a weak algorithm (certbot-dns-rfc2136 to HMAC-MD5, lego to HMAC-SHA1).

check(stored, presented)

@spec check(term(), term()) :: :ok | {:error, :badkey}

Checks the algorithm a request presented against the one the key is pinned to. Any mismatch is {:error, :badkey}, as is a stored algorithm that is not allowed (a legacy or corrupt record).

generate_secret(algorithm)

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

A random shared secret for algorithm: as many random bytes as the hash output, base64-encoded (standard alphabet, padded, as in named.conf).

Raises ArgumentError for an algorithm that is not allowed.

normalize(algorithm)

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

The normalised form of an algorithm name: lower case, no trailing dot.