]> granicus.if.org Git - pdns/commitdiff
Downcase algorithm names when doing TSIG. Fixes issue #1013
authorAki Tuomi <cmouse@desteem.org>
Thu, 12 Sep 2013 13:49:59 +0000 (16:49 +0300)
committerAki Tuomi <cmouse@desteem.org>
Thu, 12 Sep 2013 13:49:59 +0000 (16:49 +0300)
pdns/dnssecinfra.cc
pdns/dnssecinfra.hh

index aba1327ec2eab85b058f204f71b659540cc5ba27..1331c318ccf22b31f23947eb30ad1c7f19e643a3 100644 (file)
@@ -558,22 +558,24 @@ string makeTSIGMessageFromTSIGPacket(const string& opacket, unsigned int tsigOff
 }
 
 
-bool getTSIGHashEnum(string algoName, TSIGHashEnum& algoEnum)
+bool getTSIGHashEnum(const string &algoName, TSIGHashEnum& algoEnum)
 {
-  if (*(algoName.rbegin()) != '.')
-    algoName.append(".");
+  string normalizedName = toLower(normalizedName);
 
-  if (algoName == "hmac-md5.sig-alg.reg.int.")
+  if (*(normalizedName.rbegin()) != '.')
+    normalizedName.append(".");
+
+  if (normalizedName == "hmac-md5.sig-alg.reg.int.")
     algoEnum = TSIG_MD5;
-  else if (algoName == "hmac-sha1.")
+  else if (normalizedName == "hmac-sha1.")
     algoEnum = TSIG_SHA1;
-  else if (algoName == "hmac-sha224.")
+  else if (normalizedName == "hmac-sha224.")
     algoEnum = TSIG_SHA224;
-  else if (algoName == "hmac-sha256.")
+  else if (normalizedName == "hmac-sha256.")
     algoEnum = TSIG_SHA256;
-  else if (algoName == "hmac-sha384.")
+  else if (normalizedName == "hmac-sha384.")
     algoEnum = TSIG_SHA384;
-  else if (algoName == "hmac-sha512.")
+  else if (normalizedName == "hmac-sha512.")
     algoEnum = TSIG_SHA512;
   else {
      return false;
index da723cae102446dbf213fb88c3a8b547e37bd478..cc8746d3a23855685af41b7db5545519927dab9a 100644 (file)
@@ -135,7 +135,7 @@ string calculateSHAHMAC(const std::string& key_, const std::string& text, TSIGHa
 string calculateHMAC(const std::string& key_, const std::string& text, TSIGHashEnum hash);
 
 string makeTSIGMessageFromTSIGPacket(const string& opacket, unsigned int tsigoffset, const string& keyname, const TSIGRecordContent& trc, const string& previous, bool timersonly, unsigned int dnsHeaderOffset=0);
-bool getTSIGHashEnum(string algoName, TSIGHashEnum& algoEnum);
+bool getTSIGHashEnum(const string &algoName, TSIGHashEnum& algoEnum);
 void addTSIG(DNSPacketWriter& pw, TSIGRecordContent* trc, const string& tsigkeyname, const string& tsigsecret, const string& tsigprevious, bool timersonly);
 
 #endif