From: Francis Dupont Date: Tue, 25 May 2021 22:22:08 +0000 (+0000) Subject: [(no branch, rebasing 1880-implement-the-tkey-rr)] [(no branch, rebasing 1880-impleme... X-Git-Tag: Kea-1.9.9~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6efc036659e9268b019728251d02fe5d7463b80;p=thirdparty%2Fkea.git [(no branch, rebasing 1880-implement-the-tkey-rr)] [(no branch, rebasing 1880-implement-the-tkey-rr)] [(no branch, rebasing 1880-implement-the-tkey-rr)] [#1880] Checkpoint: finished UTs --- diff --git a/src/lib/dns/tests/rdata_tkey_unittest.cc b/src/lib/dns/tests/rdata_tkey_unittest.cc index 58006f196e..8592a27a01 100644 --- a/src/lib/dns/tests/rdata_tkey_unittest.cc +++ b/src/lib/dns/tests/rdata_tkey_unittest.cc @@ -276,7 +276,7 @@ TEST_F(Rdata_TKEY_Test, badFromWire) { EXPECT_THROW(rdataFactoryFromFile(RRType::TKEY(), RRClass::ANY(), "rdata_tkey_fromWire7.wire"), DNSMessageFORMERR); - // Key size is bogus: + // Key length is bogus: EXPECT_THROW(rdataFactoryFromFile(RRType::TKEY(), RRClass::ANY(), "rdata_tkey_fromWire8.wire"), InvalidBufferPosition); @@ -306,13 +306,13 @@ TEST_F(Rdata_TKEY_Test, createFromParams) { const uint8_t fake_data[] = { 0x14, 0x02, 0x84, 0x14, 0x02, 0x84, 0x14, 0x02, 0x84, 0x14, 0x02, 0x84 }; EXPECT_EQ(0, generic::TKEY(valid_text2).compare( - generic::TKEY(Name("GSS_TSIG"), 1619870400, 1619874000, - 3, 0, 12, fake_data, 0, 0))); + generic::TKEY(Name("GSS-TSIG"), 1619870400, 1619874000, + 3, 16, 12, fake_data, 0, 0))); const uint8_t fake_data2[] = { 0x14, 0x02, 0x84, 0x14, 0x02, 0x84 }; EXPECT_EQ(0, generic::TKEY(valid_text3).compare( generic::TKEY(Name("gss.tsig"), 1619870400, 1619874000, - 3, 0, 12, fake_data, 6, fake_data2))); + 3, 16, 12, fake_data, 6, fake_data2))); EXPECT_THROW(generic::TKEY(Name("gss-tsig"), 0, 0, 0, 0, 0, fake_data, 0, 0), isc::InvalidParameter); @@ -383,7 +383,7 @@ TEST_F(Rdata_TKEY_Test, toWireRenderer) { expect_data.clear(); renderer.clear(); renderer.writeName(Name("gss-tsig")); - renderer.writeUint16(42); // RDLEN + renderer.writeUint16(26); // RDLEN rdata_tkey.toWire(renderer); UnitTestUtil::readWireData("rdata_tkey_toWire4.wire", expect_data); matchWireData(&expect_data[0], expect_data.size(), @@ -392,7 +392,7 @@ TEST_F(Rdata_TKEY_Test, toWireRenderer) { // check algorithm can be used as a compression target. expect_data.clear(); renderer.clear(); - renderer.writeUint16(42); + renderer.writeUint16(26); rdata_tkey.toWire(renderer); renderer.writeName(Name("gss-tsig")); UnitTestUtil::readWireData("rdata_tkey_toWire5.wire", expect_data); @@ -412,20 +412,30 @@ TEST_F(Rdata_TKEY_Test, compare) { // "AAAA" encoded in BASE64 corresponds to 0x000000, so it should be the // smallest data of the same length. vector compare_set; - ///////////// TODO - compare_set.push_back(generic::TKEY("a.example 0 300 0 16020 0 0")); - compare_set.push_back(generic::TKEY("example 0 300 0 16020 0 0")); - compare_set.push_back(generic::TKEY("example 1 300 0 16020 0 0")); - compare_set.push_back(generic::TKEY("example 1 600 0 16020 0 0")); - compare_set.push_back(generic::TKEY("example 1 600 3 AAAA 16020 0 0")); - compare_set.push_back(generic::TKEY("example 1 600 3 FAKE 16020 0 0")); - compare_set.push_back(generic::TKEY("example 1 600 3 FAKE 16021 0 0")); - compare_set.push_back(generic::TKEY("example 1 600 3 FAKE 16021 1 0")); - compare_set.push_back(generic::TKEY("example 1 600 3 FAKE 16021 1 3 AAAA")); - compare_set.push_back(generic::TKEY("example 1 600 3 FAKE 16021 1 3 FAKE")); - - EXPECT_EQ(0, compare_set[0].compare( - generic::TKEY("A.EXAMPLE 0 300 0 16020 0 0"))); + compare_set.push_back(generic::TKEY("a.example 20210501120000 " + "20210501130000 3 0 0 0")); + compare_set.push_back(generic::TKEY("example 20210501120000 " + "20210501130000 3 0 0 0")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130000 3 0 0 0")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130001 3 0 0 0")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130001 4 0 0 0")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130001 4 1 0 0")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130001 4 1 3 AAAA 0")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130001 4 1 3 FAKE 0")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130001 4 1 3 FAKE 3 AAAA")); + compare_set.push_back(generic::TKEY("example 20210501120001 " + "20210501130001 4 1 3 FAKE 3 FAKE")); + + EXPECT_EQ(0, + compare_set[0].compare(generic::TKEY("A.EXAMPLE 20210501120000 " + "20210501130000 3 0 0 0"))); vector::const_iterator it; vector::const_iterator it_end = compare_set.end(); diff --git a/src/lib/dns/tests/testdata/rdata_tkey_fromWire5.spec b/src/lib/dns/tests/testdata/rdata_tkey_fromWire5.spec index da90b18789..6cfa4b41a9 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_fromWire5.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_fromWire5.spec @@ -1,7 +1,7 @@ # -# TSIG-like RDATA but RDLEN is too short. +# TKEY-like RDATA but RDLEN is too short. # [custom] -sections: tsig -[tsig] -rdlen: 60 +sections: tkey +[tkey] +rdlen: 57 diff --git a/src/lib/dns/tests/testdata/rdata_tkey_fromWire6.spec b/src/lib/dns/tests/testdata/rdata_tkey_fromWire6.spec index 9d2f627442..87460a278e 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_fromWire6.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_fromWire6.spec @@ -1,7 +1,7 @@ # -# TSIG-like RDATA but RDLEN is too long. +# TKEY-like RDATA but RDLEN is too long. # [custom] -sections: tsig -[tsig] -rdlen: 63 +sections: tkey +[tkey] +rdlen: 60 diff --git a/src/lib/dns/tests/testdata/rdata_tkey_fromWire7.spec b/src/lib/dns/tests/testdata/rdata_tkey_fromWire7.spec index ed7a81c882..3fc0929253 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_fromWire7.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_fromWire7.spec @@ -1,8 +1,8 @@ # -# TSIG-like RDATA but algorithm name is broken. +# TKEY-like RDATA but algorithm name is broken. # [custom] -sections: tsig -[tsig] +sections: tkey +[tkey] algorithm: "01234567890123456789012345678901234567890123456789012345678901234" -mac_size: 32 +key_len: 32 diff --git a/src/lib/dns/tests/testdata/rdata_tkey_fromWire8.spec b/src/lib/dns/tests/testdata/rdata_tkey_fromWire8.spec index 0b44f879c4..8338279d72 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_fromWire8.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_fromWire8.spec @@ -1,8 +1,8 @@ # -# TSIG-like RDATA but MAC size is bogus +# TKEY-like RDATA but Key len is bogus # [custom] -sections: tsig -[tsig] -mac_size: 65535 -mac: "dummy data" +sections: tkey +[tkey] +key_len: 65535 +key: "dummy data" diff --git a/src/lib/dns/tests/testdata/rdata_tkey_fromWire9.spec b/src/lib/dns/tests/testdata/rdata_tkey_fromWire9.spec index f512fb4389..9fb63e0ec8 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_fromWire9.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_fromWire9.spec @@ -1,8 +1,8 @@ # -# TSIG-like RDATA but Other-Data length is bogus +# TKEY-like RDATA but Other-Data length is bogus # [custom] -sections: tsig -[tsig] +sections: tkey +[tkey] other_len: 65535 otherdata: "dummy data" diff --git a/src/lib/dns/tests/testdata/rdata_tkey_toWire1.spec b/src/lib/dns/tests/testdata/rdata_tkey_toWire1.spec index eb740009b7..42521a3c75 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_toWire1.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_toWire1.spec @@ -1,11 +1,8 @@ # -# An artificial TSIG RDATA for toWire test. +# An artificial TKEY RDATA for toWire test. # [custom] -sections: tsig -[tsig] -algorithm: hmac-md5 -time_signed: 1286779327 -mac_size: 0 -original_id: 16020 -error: 17 +sections: tkey +[tkey] +algorithm: gss-tsig +key_len: 0 diff --git a/src/lib/dns/tests/testdata/rdata_tkey_toWire2.spec b/src/lib/dns/tests/testdata/rdata_tkey_toWire2.spec index b2c38e9531..25d47e5d47 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_toWire2.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_toWire2.spec @@ -1,13 +1,11 @@ # -# An artificial TSIG RDATA for toWire test. +# An artificial TKEY RDATA for toWire test. # [custom] -sections: tsig -[tsig] -algorithm: hmac-sha256 -time_signed: 1286779327 -mac_size: 12 -# 0x1402... would be FAKEFAKE... if encoded in BASE64 -mac: 0x140284140284140284140284 -original_id: 16020 +sections: tkey +[tkey] +algorithm: GSS-TSIG error: 16 +key_len: 12 +# 0x1402... would be FAKEFAKE... if encoded in BASE64 +key: 0x140284140284140284140284 diff --git a/src/lib/dns/tests/testdata/rdata_tkey_toWire3.spec b/src/lib/dns/tests/testdata/rdata_tkey_toWire3.spec index 6520a08e4e..b3ea3dbd2a 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_toWire3.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_toWire3.spec @@ -1,15 +1,13 @@ # -# An artificial TSIG RDATA for toWire test. +# An artificial TKEY RDATA for toWire test. # [custom] -sections: tsig -[tsig] -algorithm: hmac-sha1 -time_signed: 1286779327 -mac_size: 12 +sections: tkey +[tkey] +algorithm: gss.tsig +error: 16 +key_len: 12 # 0x1402... would be FAKEFAKE... if encoded in BASE64 -mac: 0x140284140284140284140284 -original_id: 16020 -error: 18 +key: 0x140284140284140284140284 other_len: 6 other_data: 0x140284140284 diff --git a/src/lib/dns/tests/testdata/rdata_tkey_toWire4.spec b/src/lib/dns/tests/testdata/rdata_tkey_toWire4.spec index d95cd23827..e403c00429 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_toWire4.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_toWire4.spec @@ -1,13 +1,10 @@ # -# An artificial TSIG RDATA for toWire test. +# An artificial TKEY RDATA for toWire test. # [custom] -sections: name:tsig +sections: name:tkey [name] -name: hmac-md5.sig-alg.reg.int. -[tsig] -algorithm: hmac-md5 -time_signed: 1286779327 -mac_size: 0 -original_id: 16020 -error: 17 +name: gss-tsig +[tkey] +algorithm: gss-tsig +key_len: 0 diff --git a/src/lib/dns/tests/testdata/rdata_tkey_toWire5.spec b/src/lib/dns/tests/testdata/rdata_tkey_toWire5.spec index 81e3a78901..b4a1bcacc9 100644 --- a/src/lib/dns/tests/testdata/rdata_tkey_toWire5.spec +++ b/src/lib/dns/tests/testdata/rdata_tkey_toWire5.spec @@ -1,13 +1,10 @@ # -# An artificial TSIG RDATA for toWire test. +# An artificial TKEY RDATA for toWire test. # [custom] -sections: tsig:name -[tsig] -algorithm: hmac-md5 -time_signed: 1286779327 -mac_size: 0 -original_id: 16020 -error: 17 +sections: tkey:name +[tkey] +algorithm: gss-tsig +key_len: 0 [name] name: ptr=2