]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix key algorithm checks
authorBrian Wellington <source@isc.org>
Fri, 3 Aug 2001 18:12:08 +0000 (18:12 +0000)
committerBrian Wellington <source@isc.org>
Fri, 3 Aug 2001 18:12:08 +0000 (18:12 +0000)
bin/named/config.c
bin/named/controlconf.c
bin/named/include/named/config.h
bin/named/tsigconf.c

index ed6c2582ce978aebd69ec74a6f79691f2fbd205d..4b8e3d704eaba4ff29cf1fea0ca91239d991828a 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: config.c,v 1.9 2001/06/04 21:51:23 bwelling Exp $ */
+/* $Id: config.c,v 1.10 2001/08/03 18:12:04 bwelling Exp $ */
 
 #include <config.h>
 
@@ -35,6 +35,7 @@
 #include <dns/fixedname.h>
 #include <dns/name.h>
 #include <dns/rdataclass.h>
+#include <dns/tsig.h>
 #include <dns/zone.h>
 
 #include <named/config.h>
@@ -435,3 +436,17 @@ ns_config_getport(cfg_obj_t *config, in_port_t *portp) {
        *portp = (in_port_t)cfg_obj_asuint32(portobj);
        return (ISC_R_SUCCESS);
 }
+
+isc_result_t
+ns_config_getkeyalgorithm(const char *str, dns_name_t **name)
+{
+       if (strcasecmp(str, "hmac-md5") == 0 ||
+           strcasecmp(str, "hmac-md5.sig-alg.reg.int") == 0 ||
+           strcasecmp(str, "hmac-md5.sig-alg.reg.int.") == 0)
+       {
+               if (name != NULL)
+                       *name = dns_tsig_hmacmd5_name;
+               return (ISC_R_SUCCESS);
+       }
+       return (ISC_R_NOTFOUND);
+}
index 6fd629f757a2e531663e2270d2ee8c2392d50dd7..ed9e24b0fe29fbf5744b44b3b4afa9e641a11558 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: controlconf.c,v 1.20 2001/08/03 18:03:02 gson Exp $ */
+/* $Id: controlconf.c,v 1.21 2001/08/03 18:12:05 bwelling Exp $ */
 
 #include <config.h>
 
@@ -51,6 +51,7 @@
 
 #include <dst/dst.h>
 
+#include <named/config.h>
 #include <named/control.h>
 #include <named/log.h>
 #include <named/server.h>
@@ -672,7 +673,9 @@ register_keys(cfg_obj_t *control, cfg_obj_t *keylist,
                        algstr = cfg_obj_asstring(algobj);
                        secretstr = cfg_obj_asstring(secretobj);
 
-                       if (strcasecmp(algstr, "hmac-md5") != 0) {
+                       if (ns_config_getkeyalgorithm(algstr, NULL) !=
+                           ISC_R_SUCCESS)
+                       {
                                cfg_obj_log(control, ns_g_lctx,
                                            ISC_LOG_WARNING,
                                            "unsupported algorithm '%s' in "
@@ -760,7 +763,7 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
        algstr = cfg_obj_asstring(algobj);
        secretstr = cfg_obj_asstring(secretobj);
 
-       if (strcasecmp(algstr, "hmac-md5") != 0) {
+       if (ns_config_getkeyalgorithm(algstr, NULL) != ISC_R_SUCCESS) {
                cfg_obj_log(key, ns_g_lctx,
                            ISC_LOG_WARNING,
                            "unsupported algorithm '%s' in "
index 78c21084cb21898b9a99e84bf58bd093aca74b43..8c0f3c3eece62324ba29bfe221cdb65705150c5b 100644 (file)
@@ -15,9 +15,9 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: config.h,v 1.1 2001/03/04 21:21:32 bwelling Exp $ */
+/* $Id: config.h,v 1.2 2001/08/03 18:12:08 bwelling Exp $ */
 
-/* $Id: config.h,v 1.1 2001/03/04 21:21:32 bwelling Exp $ */
+/* $Id: config.h,v 1.2 2001/08/03 18:12:08 bwelling Exp $ */
 
 #ifndef NAMED_CONFIG_H
 #define NAMED_CONFIG_H 1
@@ -63,4 +63,7 @@ ns_config_putipandkeylist(isc_mem_t *mctx, isc_sockaddr_t **addrsp,
 isc_result_t
 ns_config_getport(cfg_obj_t *config, in_port_t *portp);
 
+isc_result_t
+ns_config_getkeyalgorithm(const char *str, dns_name_t **name);
+
 #endif /* NAMED_CONFIG_H */
index 0976ebc725192d25067cff9bc5a12d960dc7f090..f988f0784e15ae0ba572a4f2fd84961599ad00eb 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: tsigconf.c,v 1.19 2001/07/26 20:54:34 bwelling Exp $ */
+/* $Id: tsigconf.c,v 1.20 2001/08/03 18:12:06 bwelling Exp $ */
 
 #include <config.h>
 
@@ -83,11 +83,7 @@ add_initial_keys(cfg_obj_t *list, dns_tsig_keyring_t *ring, isc_mem_t *mctx) {
                 * Create the algorithm.
                 */
                algstr = cfg_obj_asstring(algobj);
-               if (strcasecmp(algstr, "hmac-md5") == 0 ||
-                   strcasecmp(algstr, "hmac-md5.sig-alg.reg.int") ||
-                   strcasecmp(algstr, "hmac-md5.sig-alg.reg.int."))
-                       alg = dns_tsig_hmacmd5_name;
-               else {
+               if (ns_config_getkeyalgorithm(algstr, &alg) != ISC_R_SUCCESS) {
                        cfg_obj_log(algobj, ns_g_lctx, ISC_LOG_ERROR,
                                    "key '%s': the only supported algorithm "
                                    "is hmac-md5", keyid);