Speed

A DS Digests the DNSKEY

A DS record holds a SHA-256 digest of the canonical owner name and the DNSKEY RDATA; the first Ed25519 key of RFC 8080 has the digest 3aa5ab37efce57f7 and tag 3613.

The question

A zone does not publish its key's whole text in the parent. The parent holds a DS record instead. What is in it, and how is its digest made, so that a validator can check a DNSKEY against it?

The numbers here are the published test material of RFC 8080, section 6, RFC 4034, section 5.4, and RFC 4509, section 2.3: public records for the standards that protect nothing. The DS is the link by which trust moves from the parent zone to the child's DNSKEY; it is not a keyed check like the one in HMAC Uses Two Pads, because nobody keeps a secret: the digest is public and anyone can recompute it.

Work it by hand

A DS record carries the key tag of the DNSKEY, its algorithm, a digest type and a digest. The digest is the hash of the owner name of the DNSKEY in canonical form followed by the DNSKEY RDATA (RFC 4034, 5.1.4). Digest type 2 means SHA-256 (RFC 4509, section 2).

The canonical form of the owner name is the wire format, fully expanded, with every upper-case US-ASCII letter replaced by the lower-case letter (RFC 4034, 6.2, item 2). For the name with the labels example and com that is 07 example 03 com 00: 13 bytes. The hash input is those 13 bytes followed by the 36 bytes of the first Ed25519 key of RFC 8080, section 6.1: 49 bytes in all.

Run it

The program takes the labels of the owner name as text in names, separated by spaces, and the DNSKEY RDATA as hex in rdata. Line 1 splits the lower-cased labels at the spaces; the loop of lines 3 to 8 writes each non-empty label as its length byte and its letters (line 4 takes one label); line 9 adds the root label; line 10 hashes the wire name and the RDATA with SHA-256. The wire name is returned as wire, and line 12 returns the digest.

The labels example com, their 13 wire bytes starting 07 65 78 61, the first 16 bytes of the RDATA 01 01 03 0f and the first 16 bytes of the digest 3a a5 ab 37.

Public test material, generated for this lesson. Never use it for anything real.

let labels = str_split(str_lower(names), " ");
let wire = "";
for (i in range(0, labels.len())) {
  let part = labels.at(i);
  if (str_len(part) > 0) {
    wire = wire + hex_byte(str_len(part)) + ssl.hex(part);
  }
}
wire = wire + "00";
let digest = ssl.digest("SHA256", ssl.unhex(wire + rdata));
lmcode_return_put("wire", wire);
let answer = digest;
{
  "answer": "3aa5ab37efce57f737fc1627013fee07bdf241bd10f3b1964ab55c78e79a304b",
  "wire": "076578616d706c6503636f6d00"
}

The digest is 3aa5ab37efce57f737fc1627013fee07bdf241bd10f3b1964ab55c78e79a304b, the value RFC 8080 publishes in the DS of this key. You can change the labels (separate them by single spaces; an empty text is the root; a label longer than 63 characters is not a DNS label, and from 256 characters the length byte no longer fits: one such label stops the run with "Ssl.unhex: odd number of hex digits") and the RDATA freely; any bytes give a digest, but only the published RDATA gives the published one.

Your turn

A resolver tool wants the SHA-256 digest of a DNSKEY for its DS. The program below is meant to return it, as 64 hex digits, for an owner name given as wire bytes in hex in owner (the name as it appears in the zone data) and the RDATA in rdata. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on five others. The keys and their digests are published test material.

The first 16 bytes of an owner name in wire format and the first 16 bytes of a DNSKEY RDATA.

Public test material, generated for this lesson. Never use it for anything real.

let canon = owner;
let input = canon + rdata;
let answer = ssl.digest("SHA256", ssl.unhex(input));
{
  "answer": "6af2047c3ae650138574ff380c8de3b31cc907f9cdf05efec0ae6d11b76b4e00"
}

Return the DS digest of type 2 (SHA-256) as 64 lower-case hex digits for a DNSKEY, from its owner name as wire bytes in owner and its RDATA in rdata (RFC 4034, 5.1.4 and RFC 4509, section 2).

Read the result carefully

A DS digest shows that a DNSKEY is the one the parent named; it does not show that the parent is genuine, and nothing here follows a chain of parents to a trust anchor. The digest of the published keys is a public number: anyone can recompute it, which is the point.

The page never queries a zone. The keys are test material that protect nothing, the Ed448 keys are used only for their digests (RFC 8080, section 6.2), and the page makes no claim about the strength of any algorithm.

Recap

  • A DS record holds the key tag, the algorithm, a digest type and a digest of the DNSKEY.
  • The digest is SHA-256 (type 2) of the owner name in canonical form followed by the DNSKEY RDATA.
  • The owner name enters the digest in canonical form.
  • A DS is an unkeyed digest: anyone can recompute it.