]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Optimize TSIG digest function name compariso
authorWillem Toorop <willem@nlnetlabs.nl>
Mon, 11 Nov 2013 15:10:34 +0000 (16:10 +0100)
committerWillem Toorop <willem@nlnetlabs.nl>
Mon, 11 Nov 2013 15:10:34 +0000 (16:10 +0100)
Changelog
tsig.c

index 7b88f0457c0cd67c435895896659106050600e9c..4016336e93e1ac96e8290b1398fb922e9a452ddb 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -50,6 +50,7 @@
        * Configure option to build perl bindings: --with-p5-net-ldns
          (Net::LDNS is a contribution from Erik Ostlyngen)
        * bugfix #527: Move -lssl before -lcrypto when linking
+       * Optimize TSIG digest function name comparison (Thanks Marc Buijsman)
 
 1.6.16 2012-11-13
        * Fix Makefile to build pyldns with BSD make
diff --git a/tsig.c b/tsig.c
index afc2590231f123e82f76d7579d0a9724a77f99f7..53aa85ecb46ab74145e543a65bd181649b46251a 100644 (file)
--- a/tsig.c
+++ b/tsig.c
@@ -134,19 +134,15 @@ ldns_digest_function(char *name)
 {
        /* these are the mandatory algorithms from RFC4635 */
        /* The optional algorithms are not yet implemented */
-       if (strlen(name) == 12 
-                       && strncasecmp(name, "hmac-sha256.", 11) == 0) {
+       if (strcasecmp(name, "hmac-sha256.") == 0) {
 #ifdef HAVE_EVP_SHA256
                return EVP_sha256();
 #else
                return NULL;
 #endif
-       } else if (strlen(name) == 10
-                       && strncasecmp(name, "hmac-sha1.", 9) == 0) {
+       } else if (strcasecmp(name, "hmac-sha1.") == 0) {
                return EVP_sha1();
-       } else if (strlen(name) == 25 
-                       && strncasecmp(name, "hmac-md5.sig-alg.reg.int.", 25) 
-                       == 0) {
+       } else if (strcasecmp(name, "hmac-md5.sig-alg.reg.int.") == 0) {
                return EVP_md5();
        } else {
                return NULL;