|
@@ -19,6 +19,7 @@
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
#include <dns/nsec3hash.h>
|
|
|
+#include <dns/labelsequence.h>
|
|
|
#include <dns/rdataclass.h>
|
|
|
#include <util/encode/hex.h>
|
|
|
|
|
@@ -92,6 +93,18 @@ calculateCheck(NSEC3Hash& hash) {
|
|
|
// Check case-insensitiveness
|
|
|
EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
hash.calculate(Name("EXAMPLE")));
|
|
|
+
|
|
|
+ // Repeat for the LabelSequence variant.
|
|
|
+
|
|
|
+ // A couple of normal cases from the RFC5155 example.
|
|
|
+ EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
+ hash.calculate(LabelSequence(Name("example"))));
|
|
|
+ EXPECT_EQ("35MTHGPGCU1QG68FAB165KLNSNK3DPVL",
|
|
|
+ hash.calculate(LabelSequence(Name("a.example"))));
|
|
|
+
|
|
|
+ // Check case-insensitiveness
|
|
|
+ EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
+ hash.calculate(LabelSequence(Name("EXAMPLE"))));
|
|
|
}
|
|
|
|
|
|
TEST_F(NSEC3HashTest, calculate) {
|
|
@@ -113,13 +126,16 @@ TEST_F(NSEC3HashTest, calculate) {
|
|
|
EXPECT_EQ("CK0POJMG874LJREF7EFN8430QVIT8BSM",
|
|
|
NSEC3HashPtr(NSEC3Hash::create(generic::NSEC3PARAM("1 0 0 -")))
|
|
|
->calculate(Name("com")));
|
|
|
+ EXPECT_EQ("CK0POJMG874LJREF7EFN8430QVIT8BSM",
|
|
|
+ NSEC3HashPtr(NSEC3Hash::create(generic::NSEC3PARAM("1 0 0 -")))
|
|
|
+ ->calculate(LabelSequence(Name("com"))));
|
|
|
|
|
|
// Using unusually large iterations, something larger than the 8-bit range.
|
|
|
// (expected hash value generated by BIND 9's dnssec-signzone)
|
|
|
EXPECT_EQ("COG6A52MJ96MNMV3QUCAGGCO0RHCC2Q3",
|
|
|
NSEC3HashPtr(NSEC3Hash::create(
|
|
|
generic::NSEC3PARAM("1 0 256 AABBCCDD")))
|
|
|
- ->calculate(Name("example.org")));
|
|
|
+ ->calculate(LabelSequence(Name("example.org"))));
|
|
|
}
|
|
|
|
|
|
// Common checks for match cases
|
|
@@ -169,6 +185,9 @@ class TestNSEC3Hash : public NSEC3Hash {
|
|
|
virtual string calculate(const Name&) const {
|
|
|
return ("00000000000000000000000000000000");
|
|
|
}
|
|
|
+ virtual string calculate(const LabelSequence&) const {
|
|
|
+ return ("00000000000000000000000000000000");
|
|
|
+ }
|
|
|
virtual bool match(const generic::NSEC3PARAM&) const {
|
|
|
return (true);
|
|
|
}
|
|
@@ -207,6 +226,8 @@ TEST_F(NSEC3HashTest, setCreator) {
|
|
|
// Re-check an existing case using the default creator/hash implementation
|
|
|
EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
test_hash->calculate(Name("example")));
|
|
|
+ EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
+ test_hash->calculate(LabelSequence(Name("example"))));
|
|
|
|
|
|
// Replace the creator, and confirm the hash values are faked
|
|
|
TestNSEC3HashCreator test_creator;
|
|
@@ -215,12 +236,16 @@ TEST_F(NSEC3HashTest, setCreator) {
|
|
|
test_hash.reset(NSEC3Hash::create(generic::NSEC3PARAM("1 0 12 aabbccdd")));
|
|
|
EXPECT_EQ("00000000000000000000000000000000",
|
|
|
test_hash->calculate(Name("example")));
|
|
|
+ EXPECT_EQ("00000000000000000000000000000000",
|
|
|
+ test_hash->calculate(LabelSequence(Name("example"))));
|
|
|
// Same for hash from NSEC3 RDATA
|
|
|
test_hash.reset(NSEC3Hash::create(generic::NSEC3
|
|
|
("1 0 12 aabbccdd " +
|
|
|
string(nsec3_common))));
|
|
|
EXPECT_EQ("00000000000000000000000000000000",
|
|
|
test_hash->calculate(Name("example")));
|
|
|
+ EXPECT_EQ("00000000000000000000000000000000",
|
|
|
+ test_hash->calculate(LabelSequence(Name("example"))));
|
|
|
|
|
|
// If we set a special flag big (0x80) on creation, it will act like the
|
|
|
// default creator.
|
|
@@ -228,17 +253,23 @@ TEST_F(NSEC3HashTest, setCreator) {
|
|
|
"1 128 12 aabbccdd")));
|
|
|
EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
test_hash->calculate(Name("example")));
|
|
|
+ EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
+ test_hash->calculate(LabelSequence(Name("example"))));
|
|
|
test_hash.reset(NSEC3Hash::create(generic::NSEC3
|
|
|
("1 128 12 aabbccdd " +
|
|
|
string(nsec3_common))));
|
|
|
EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
test_hash->calculate(Name("example")));
|
|
|
+ EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
+ test_hash->calculate(LabelSequence(Name("example"))));
|
|
|
|
|
|
// Reset the creator to default, and confirm that
|
|
|
setNSEC3HashCreator(NULL);
|
|
|
test_hash.reset(NSEC3Hash::create(generic::NSEC3PARAM("1 0 12 aabbccdd")));
|
|
|
EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
test_hash->calculate(Name("example")));
|
|
|
+ EXPECT_EQ("0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM",
|
|
|
+ test_hash->calculate(LabelSequence(Name("example"))));
|
|
|
}
|
|
|
|
|
|
} // end namespace
|