Speed

An RRSIG Names Its Signer

An RRSIG's RDATA carries the type covered, algorithm, labels, original TTL, validity period, key tag, signer name and signature; the first RFC 8080 record names key tag 3613.

The question

A validator that has an RRSIG record must decide which DNSKEY to try. What does the RRSIG say about its signer, and what else is in its RDATA besides the signature?

The records here are published or constructed. The first one is the RRSIG of RFC 8080, section 6.1, the first Ed25519 example; the exercise reads other ones. They are public test material and protect nothing. Names are wire bytes, as in Names Are a Hierarchy, and the page prints them as labels separated by spaces.

Work it by hand

The RDATA of an RRSIG has these fields in order (RFC 4034, 3.1.1 to 3.1.8): the type covered (2 bytes), the algorithm (1), the labels (1), the original TTL (4), the signature expiration (4), the signature inception (4), the key tag (2), the signer's name (wire format, ending with the root label) and the signature. The signer's name and the key tag say which DNSKEY to try; the algorithm says how.

Expiration and inception are seconds since 1 January 1970 UTC. In the first published record they are 1440021600 and 1438207200, which are 2015-08-19 22:00 UTC and 2015-07-29 22:00 UTC (converted outside the page). A validator compares them with serial number arithmetic (RFC 4034, 3.1.5, citing RFC 1982), which this page states and does not run.

The Labels field counts the labels of the owner name without the root label and without a wildcard label (RFC 4034, 3.1.3). A name of two labels should give 2, and one with a www in front 3. The published RRSIG for a two-label owner name prints a single number, 3, where the presentation format has the algorithm and the Labels field; this page reads the algorithm as 15, the algorithm of the key, and the Labels field as 3, the only values under which the published signature verifies.

Its signature verifies with the value 3, and, as the next chapter shows, the published signature does not verify over the data built with 2. The page reports this and does not guess why.

Run it

The program takes the RDATA of that first published RRSIG as hex in rrsig. Lines 2 to 8 read the fixed fields by position. The loop of lines 11 to 16 walks the signer's name label by label (line 15 moves over one label) and the signature length follows from what is left (line 18). Line 19 returns the rows.

A table of nine rows: type covered 15, algorithm 15, labels 3, original ttl 3600, expiration 1440021600, inception 1438207200, key tag 3613, signer example com and signature bytes 64.
Watch the steps (recorded video)

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

let rows = str_list();
rows.add("type covered|" + str(hex_u16(rrsig, 0)));
rows.add("algorithm|" + str(hex_u8(rrsig, 2)));
rows.add("labels|" + str(hex_u8(rrsig, 3)));
rows.add("original ttl|" + str(hex_u32(rrsig, 4)));
rows.add("expiration|" + str(hex_u32(rrsig, 8)));
rows.add("inception|" + str(hex_u32(rrsig, 12)));
rows.add("key tag|" + str(hex_u16(rrsig, 16)));
let pos = 18;
let signer = "";
while (hex_u8(rrsig, pos) != 0) {
  let n = hex_u8(rrsig, pos);
  if (signer != "") { signer = signer + " "; }
  signer = signer + ssl.unhex(hex_slice(rrsig, pos + 1, n));
  pos = pos + 1 + n;
}
rows.add("signer|" + signer);
rows.add("signature bytes|" + str(hex_len(rrsig) - pos - 1));
let answer = rows;
{
  "answer": [
    "type covered|15",
    "algorithm|15",
    "labels|3",
    "original ttl|3600",
    "expiration|1440021600",
    "inception|1438207200",
    "key tag|3613",
    "signer|example com",
    "signature bytes|64"
  ]
}

You can change the RDATA freely if the signer's name ends with the root label before the data ends: the program reads the fields where a real RRSIG has them, and it does not check the signature. An RDATA of 24 bytes, cut inside the name, stops the run with "bytes 19 to 25 are past the end of the data".

Your turn

A tool lists the facts of an RRSIG. The program below is meant to return a list of seven texts for the RDATA in rrsig: the type covered, the algorithm, the labels, the original TTL and the key tag, each as a decimal number, then the signer's name as its labels separated by single spaces, then the length of the signature in bytes.

Decide whether it does, and find the candidates that do. Check runs each candidate on the RDATA shown and on four others. Two are published (RFC 8080, section 6) and the rest are constructed for this page, with names under .test.

The first 16 bytes of an RRSIG RDATA in hex, with its total number of bytes.

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

let pos = 18;
let name = "";
while (hex_u8(rrsig, pos) != 0) {
  let n = hex_u8(rrsig, pos);
  if (name != "") { name = name + " "; }
  name = name + ssl.unhex(hex_slice(rrsig, pos + 1, n));
  pos = pos + 1 + n;
}
let answer = str_list();
answer.add(str(hex_u16(rrsig, 0))); answer.add(str(hex_u8(rrsig, 2)));
answer.add(str(hex_u8(rrsig, 3))); answer.add(str(hex_u16(rrsig, 4)));
answer.add(str(hex_u16(rrsig, 16))); answer.add(name);
answer.add(str(hex_len(rrsig) - pos - 1));
{
  "answer": [
    "15",
    "15",
    "3",
    "0",
    "35217",
    "example com",
    "64"
  ]
}

Return a list of seven texts for an RRSIG RDATA: the type covered, the algorithm, the labels, the original TTL and the key tag as decimal numbers, the signer's name with its labels separated by single spaces, and the length of the signature in bytes as a decimal number.

Read the result carefully

The fields say who signed and when. They do not say that the signature is good: nothing here verifies anything. The signature bytes of the published records are copied from the RFCs, the constructed records carry copies of them and are not signed by anyone, and the page does not show how a validator finds the DNSKEY.

The Labels value of the first published record is a property of that published example and nothing the page can explain. The dates are in seconds and are not related to the TTL, which only says how long a cache may keep the record.

Recap

  • An RRSIG's RDATA is the type covered, algorithm, labels, original TTL, expiration, inception, key tag, signer name and signature.
  • The signer's name and the key tag point to the DNSKEY to try.
  • Expiration and inception are seconds since 1970 and are compared with serial number arithmetic.
  • The Labels field counts the labels of the owner name without the root.