philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

Blame SOURCES/dhcp-4.2.5-additional_hmac_tsig.patch

22375d
commit 71c56235c6fbdeed3ba5a75bb379a34394106619
22375d
Author: Pavel Zhukov <pzhukov@redhat.com>
22375d
Date:   Mon Apr 10 12:59:07 2017 +0200
22375d
22375d
    Backported upstream commit e4a2cb79b2679738f56b3803a44c9899f6982c09
22375d
22375d
diff --git a/includes/omapip/isclib.h b/includes/omapip/isclib.h
22375d
index ddefeb5..4dffcb9 100644
22375d
--- a/includes/omapip/isclib.h
22375d
+++ b/includes/omapip/isclib.h
22375d
@@ -104,6 +104,11 @@ extern dhcp_context_t dhcp_gbl_ctx;
22375d
 #define DHCP_MAXDNS_WIRE 256
22375d
 #define DHCP_MAXNS         3
22375d
 #define DHCP_HMAC_MD5_NAME "HMAC-MD5.SIG-ALG.REG.INT."
22375d
+#define DHCP_HMAC_SHA1_NAME "HMAC-SHA1.SIG-ALG.REG.INT."
22375d
+#define DHCP_HMAC_SHA224_NAME "HMAC-SHA224.SIG-ALG.REG.INT."
22375d
+#define DHCP_HMAC_SHA256_NAME "HMAC-SHA256.SIG-ALG.REG.INT."
22375d
+#define DHCP_HMAC_SHA384_NAME "HMAC-SHA384.SIG-ALG.REG.INT."
22375d
+#define DHCP_HMAC_SHA512_NAME "HMAC-SHA512.SIG-ALG.REG.INT."
22375d
 
22375d
 isc_result_t dhcp_isc_name(unsigned char    *namestr,
22375d
 			   dns_fixedname_t  *namefix,
22375d
diff --git a/omapip/isclib.c b/omapip/isclib.c
22375d
index 1534dde..be1982e 100644
22375d
--- a/omapip/isclib.c
22375d
+++ b/omapip/isclib.c
22375d
@@ -198,21 +198,34 @@ isclib_make_dst_key(char          *inname,
22375d
 	dns_name_t *name;
22375d
 	dns_fixedname_t name0;
22375d
 	isc_buffer_t b;
22375d
+        unsigned int algorithm_code;
22375d
 
22375d
 	isc_buffer_init(&b, secret, length);
22375d
 	isc_buffer_add(&b, length);
22375d
 
22375d
-	/* We only support HMAC_MD5 currently */
22375d
-	if (strcasecmp(algorithm, DHCP_HMAC_MD5_NAME) != 0) {
22375d
+        if (strcasecmp(algorithm, DHCP_HMAC_MD5_NAME) == 0) {
22375d
+		algorithm_code =  DST_ALG_HMACMD5;
22375d
+	} else if (strcasecmp(algorithm, DHCP_HMAC_SHA1_NAME) == 0) {
22375d
+		algorithm_code =  DST_ALG_HMACSHA1;
22375d
+	} else if (strcasecmp(algorithm, DHCP_HMAC_SHA224_NAME) == 0) {
22375d
+		algorithm_code =  DST_ALG_HMACSHA224;
22375d
+	} else if (strcasecmp(algorithm, DHCP_HMAC_SHA256_NAME) == 0) {
22375d
+		algorithm_code =  DST_ALG_HMACSHA256;
22375d
+	} else if (strcasecmp(algorithm, DHCP_HMAC_SHA384_NAME) == 0) {
22375d
+		algorithm_code =  DST_ALG_HMACSHA384;
22375d
+	} else if (strcasecmp(algorithm, DHCP_HMAC_SHA512_NAME) == 0) {
22375d
+		algorithm_code =  DST_ALG_HMACSHA512;
22375d
+	} else {
22375d
 		return(DHCP_R_INVALIDARG);
22375d
 	}
22375d
 
22375d
+
22375d
 	result = dhcp_isc_name((unsigned char *)inname, &name0, &name);
22375d
 	if (result != ISC_R_SUCCESS) {
22375d
 		return(result);
22375d
 	}
22375d
 
22375d
-	return(dst_key_frombuffer(name, DST_ALG_HMACMD5, DNS_KEYOWNER_ENTITY,
22375d
+        return(dst_key_frombuffer(name, algorithm_code, DNS_KEYOWNER_ENTITY,
22375d
 				  DNS_KEYPROTO_DNSSEC, dns_rdataclass_in,
22375d
 				  &b, dhcp_gbl_ctx.mctx, dstkey));
22375d
 }
22375d
diff --git a/server/dhcpd.conf.5 b/server/dhcpd.conf.5
22375d
index 0cb50a6..74393c2 100644
22375d
--- a/server/dhcpd.conf.5
22375d
+++ b/server/dhcpd.conf.5
22375d
@@ -1398,6 +1398,18 @@ generate a key as seen above:
22375d
 	dnskeygen -H 128 -u -c -n DHCP_UPDATER
22375d
 .fi
22375d
 .PP
22375d
+The key name, algorithm, and secret must match that being used by the DNS
22375d
+server. The DHCP server currently supports the following algorithms:
22375d
+.nf
22375d
+
22375d
+        HMAC-MD5
22375d
+        HMAC-SHA1
22375d
+        HMAC-SHA224
22375d
+        HMAC-SHA256
22375d
+        HMAC-SHA384
22375d
+        HMAC-SHA512
22375d
+.fi
22375d
+.PP
22375d
 You may wish to enable logging of DNS updates on your DNS server.
22375d
 To do so, you might write a logging statement like the following:
22375d
 .PP