From 04a665e639c2a8f6066b4fc44df53d5093ada617 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Sun, 27 Oct 2019 19:33:25 -0700 Subject: [PATCH] dns/server: return sig0 key in KEY rr --- lib/dns/server.js | 8 ++++++++ test/ns-test.js | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/dns/server.js b/lib/dns/server.js index f966044a4..3ddc651d2 100644 --- a/lib/dns/server.js +++ b/lib/dns/server.js @@ -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()); @@ -489,6 +493,10 @@ class RootServer extends DNSServer { rd.typeBitmap = TYPE_MAP; return rr; } + + toKEY() { + return hsig.makeKey(this.key); + } } /** diff --git a/test/ns-test.js b/test/ns-test.js index d56767165..0a577ec91 100644 --- a/test/ns-test.js +++ b/test/ns-test.js @@ -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, '.'); + }); });