diff --git a/CHANGES b/CHANGES index de92389f67..870884704d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4688. [protocol] Check and display EDNS KEY TAG options (RFC 8145) in + messages. [RT #44804] + 4686. [bug] dnssec-settime -p could print a bogus warning about key deletion scheduled before its inactivation when a key had an inactivation date set but no deletion date diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 5ff1dade27..d168dfe7ee 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1578,6 +1578,7 @@ dig_ednsoptname_t optnames[] = { { 12, "PADDING" }, /* RFC 7830 */ { 12, "PAD" }, /* shorthand */ { 13, "CHAIN" }, /* RFC 7901 */ + { 14, "KEY-TAG" }, /* RFC 8145 */ { 26946, "DEVICEID" }, /* Brian Hartvigsen */ }; diff --git a/bin/tests/system/digdelv/tests.sh b/bin/tests/system/digdelv/tests.sh index 55a8111526..d87b008e14 100644 --- a/bin/tests/system/digdelv/tests.sh +++ b/bin/tests/system/digdelv/tests.sh @@ -280,6 +280,7 @@ if [ -x ${DIG} ] ; then echo "I:skipping 'dig +idnout' as IDN support is not enabled ($n)" fi + n=`expr $n + 1` echo "I:checking that dig warns about .local queries ($n)" ret=0 $DIG $DIGOPTS @10.53.0.3 local soa > dig.out.test$n 2>&1 || ret=1 @@ -287,6 +288,31 @@ if [ -x ${DIG} ] ; then if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` + n=`expr $n + 1` + echo "I:check that dig processes +ednsopt=key-tag and FORMERR is returned ($n)" + $DIG $DIGOPTS @10.53.0.3 +ednsopt=key-tag a.example +qr > dig.out.test$n 2>&1 || ret=1 + grep "; KEY-TAG$" dig.out.test$n > /dev/null || ret=1 + grep "status: FORMERR" dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:check that dig processes +ednsopt=key-tag: ($n)" + $DIG $DIGOPTS @10.53.0.3 +ednsopt=key-tag:00010002 a.example +qr > dig.out.test$n 2>&1 || ret=1 + grep "; KEY-TAG: 1, 2$" dig.out.test$n > /dev/null || ret=1 + grep "status: FORMERR" dig.out.test$n > /dev/null && ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + + n=`expr $n + 1` + echo "I:check that dig processes +ednsopt=key-tag: and FORMERR is returned ($n)" + ret=0 + $DIG $DIGOPTS @10.53.0.3 +ednsopt=key-tag:0001000201 a.example +qr > dig.out.test$n 2>&1 || ret=1 + grep "; KEY-TAG: 00 01 00 02 01" dig.out.test$n > /dev/null || ret=1 + grep "status: FORMERR" dig.out.test$n > /dev/null || ret=1 + if [ $ret != 0 ]; then echo "I:failed"; fi + status=`expr $status + $ret` + else echo "$DIG is needed, so skipping these dig tests" fi diff --git a/doc/arm/notes.xml b/doc/arm/notes.xml index e0ca647406..4afe714bc6 100644 --- a/doc/arm/notes.xml +++ b/doc/arm/notes.xml @@ -114,6 +114,11 @@ [RT #44696] + + + EDNS KEY TAG options are verified and printed. + + diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 3d7385b629..3327d720a0 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -107,6 +107,7 @@ #define DNS_OPT_EXPIRE 9 /*%< EXPIRE opt code */ #define DNS_OPT_COOKIE 10 /*%< COOKIE opt code */ #define DNS_OPT_PAD 12 /*%< PAD opt code */ +#define DNS_OPT_KEY_TAG 14 /*%< Key tag opt code */ /*%< The number of EDNS options we know about. */ #define DNS_EDNSOPTIONS 4 diff --git a/lib/dns/message.c b/lib/dns/message.c index 0933889549..224e57e3b1 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -3490,6 +3490,22 @@ dns_message_pseudosectiontotext(dns_message_t *msg, ADD_STRING(target, "; EXPIRE"); } else if (optcode == DNS_OPT_PAD) { ADD_STRING(target, "; PAD"); + } else if (optcode == DNS_OPT_KEY_TAG) { + ADD_STRING(target, "; KEY-TAG"); + if (optlen > 0U && (optlen % 2U) == 0U) { + const char *sep = ": "; + isc_uint16_t id; + while (optlen > 0U) { + id = isc_buffer_getuint16(&optbuf); + snprintf(buf, sizeof(buf), "%s%u", + sep, id); + ADD_STRING(target, buf); + sep = ", "; + optlen -= 2; + } + ADD_STRING(target, "\n"); + continue; + } } else { ADD_STRING(target, "; OPT="); snprintf(buf, sizeof(buf), "%u", optcode); diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index 0ed2551b9d..3abe1320bc 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -185,6 +185,11 @@ fromwire_opt(ARGS_FROMWIRE) { return (DNS_R_OPTERR); isc_region_consume(&sregion, length); break; + case DNS_OPT_KEY_TAG: + if (length == 0 || (length % 2) != 0) + return (DNS_R_OPTERR); + isc_region_consume(&sregion, length); + break; default: isc_region_consume(&sregion, length); break;