Browse Source

[2762] Allow short names for HMAC-MD5

Mukund Sivaraman 11 years ago
parent
commit
6a7aa9cb23
2 changed files with 12 additions and 1 deletions
  1. 4 0
      src/lib/dns/tests/rdata_tsig_unittest.cc
  2. 8 1
      src/lib/dns/tsigkey.cc

+ 4 - 0
src/lib/dns/tests/rdata_tsig_unittest.cc

@@ -143,6 +143,10 @@ TEST_F(Rdata_TSIG_Test, fromText) {
     // multi-line rdata
     checkFromText_None("hmac-md5.sig-alg.reg.int. ( 1286779327 300 \n"
                        "0 16020 BADKEY 0 )");
+
+    // short-form HMAC-MD5 name
+    const any::TSIG tsig6("hmac-md5 1286779327 300 0 16020 BADKEY 0");
+    EXPECT_EQ(0, tsig1.compare(rdata_tsig));
 };
 
 TEST_F(Rdata_TSIG_Test, badText) {

+ 8 - 1
src/lib/dns/tsigkey.cc

@@ -31,9 +31,16 @@ using namespace isc::cryptolink;
 namespace isc {
 namespace dns {
 namespace {
+    bool
+    isHMACMD5(const isc::dns::Name& name) {
+        static const Name md5_short_name("hmac-md5");
+        return ((name == TSIGKey::HMACMD5_NAME()) ||
+                (name == md5_short_name));
+    }
+
     HashAlgorithm
     convertAlgorithmName(const isc::dns::Name& name) {
-        if (name == TSIGKey::HMACMD5_NAME()) {
+        if (isHMACMD5(name)) {
             return (isc::cryptolink::MD5);
         }
         if (name == TSIGKey::HMACSHA1_NAME()) {