Skip to content

Commit

Permalink
dns/server: return sig0 key in KEY rr
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Tyneway authored and tynes committed Aug 10, 2020
1 parent d06ff06 commit 04a665e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/dns/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ class RootServer extends DNSServer {
res.answer.push(key.ds.deepClone());
key.signZSK(res.answer, types.DS);
break;
case types.KEY:
res.answer.push(this.toKEY());
key.signZSK(res.answer, types.KEY);
break;
default:
// Empty Proof:
res.authority.push(this.toNSEC());
Expand Down Expand Up @@ -489,6 +493,10 @@ class RootServer extends DNSServer {
rd.typeBitmap = TYPE_MAP;
return rr;
}

toKEY() {
return hsig.makeKey(this.key);
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions test/ns-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,13 @@ describe('RootServer', function() {
// Nothing was added to the cache
assert.strictEqual(cache.size, 1);
});

it('should resolve KEY rr', async () => {
const req = {question: [{name: '.', type: wire.types.KEY}]};
const res = await ns.resolve(req);
const got = res.answer.find(rr => rr.type === wire.types.KEY);

assert(got);
assert.equal(got.name, '.');
});
});

0 comments on commit 04a665e

Please sign in to comment.