]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add a system test with one good and one bad algorithm
authorOndřej Surý <ondrej@isc.org>
Sat, 1 Nov 2025 11:00:59 +0000 (12:00 +0100)
committerOndřej Surý <ondrej@isc.org>
Wed, 5 Nov 2025 03:07:18 +0000 (04:07 +0100)
The case where there would be one supported algorithm and one already
unsupported (like RSAMD5 or RSASHA1) was missing.

(cherry picked from commit488d7bfc75f2988c6e461b8677bc0e27e58bd82e)

bin/tests/system/dnssec/ns2/example.db.in
bin/tests/system/dnssec/ns2/sign.sh
bin/tests/system/dnssec/ns3/named.conf.in
bin/tests/system/dnssec/ns3/sign.sh
bin/tests/system/dnssec/ns3/template.db.in [new file with mode: 0644]
bin/tests/system/dnssec/tests.sh
bin/tests/system/dnssec/tests_sh_dnssec.py

index 72e3c1fffafa52dadc822b57bc1e819cd0bc9b6c..78298c538d900b19112ee877a7d6a2f21931b93d 100644 (file)
@@ -180,4 +180,8 @@ ns.rsasha1          A       10.53.0.3
 rsasha1-1024           NS      ns.rsasha1-1024
 ns.rsasha1-1024                A       10.53.0.3
 
+; A secure subdomain with extra bad key
+extrabadkey            NS      ns3.extrabadkey
+ns3.extrabadkey                A       10.53.0.3
+
 dname-at-apex-nsec3    NS      ns3
index 501d6a389917b057cc3da5e6957c44e5a25fdd5e..634bbc16a80e0ad827a1e16724cdf4e398d77468 100644 (file)
@@ -63,7 +63,8 @@ for subdomain in digest-alg-unsupported ds-unsupported secure badds \
   ttlpatch split-dnssec split-smart expired expiring upper lower \
   dnskey-unknown dnskey-unsupported dnskey-unsupported-2 \
   dnskey-nsec3-unknown managed-future future revkey \
-  dname-at-apex-nsec3 occluded rsasha1 rsasha1-1024; do
+  dname-at-apex-nsec3 occluded rsasha1 rsasha1-1024 \
+  extrabadkey; do
   cp "../ns3/dsset-$subdomain.example." .
 done
 
index 5eba816b795595f05fdd8a260e37b3af41b6c579..cce50264e9288d32197c278214b0fd8f565a39a4 100644 (file)
@@ -133,6 +133,12 @@ zone "insecure2.example" {
        allow-update { any; };
 };
 
+zone "extrabadkey.example" {
+       type primary;
+       file "extrabadkey.example.db.signed";
+       allow-update { any; };
+};
+
 zone "insecure.nsec3.example" {
        type primary;
        file "insecure.nsec3.example.db";
index 350a504a13a0ea55e1ea6ff7a45fa35116d5c1f9..7488053d3c0176843bd927408600688959fb3ffb 100644 (file)
@@ -726,3 +726,34 @@ zone=rsasha1-1024.example
 zonefile=rsasha1-1024.example.db
 awk '$4 == "DNSKEY" && $5 == 257 { print }' "$zonefile" \
   | $DSFROMKEY -f - "$zone" >"dsset-${zone}."
+
+#
+#
+#
+zone=extrabadkey.example.
+infile=template.db.in
+zonefile=extrabadkey.example.db
+
+# Add KSK and ZSK that we will mangle to RSAMD5
+ksk=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -f KSK "$zone")
+zsk=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" "$zone")
+cat "$infile" "$ksk.key" "$zsk.key" >"$zonefile"
+"$SIGNER" -g -O full -o "$zone" "$zonefile" >/dev/null 2>&1
+
+# Mangle the signatures to RSAMD5 and save them for future use
+sed -ne "s/\(IN[[:space:]]*RRSIG[[:space:]]*[A-Z]*\) $DEFAULT_ALGORITHM_NUMBER /\1 1 /p" <"$zonefile.signed" >"$zonefile.signed.rsamd5"
+
+# Now add normal KSK and ZSK to the zone file
+ksk=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -f KSK "$zone")
+zsk=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" "$zone")
+cat "$infile" "$ksk.key" "$zsk.key" >"$zonefile"
+
+# Mangle the DNSKEY algorithm numbers and add them to the signed zone file
+cat "$ksk.key" "$zsk.key" | sed -e "s/\(IN[[:space:]]*DNSKEY[[:space:]]*[0-9]* 3\) $DEFAULT_ALGORITHM_NUMBER /\1 1 /" >>"$zonefile"
+
+# Sign normally
+"$SIGNER" -g -o "$zone" "$zonefile" >/dev/null 2>&1
+
+# Add the mangled signatures to signed zone file
+cat "$zonefile.signed.rsamd5" >>"$zonefile.signed"
+rm "$zonefile.signed.rsamd5"
diff --git a/bin/tests/system/dnssec/ns3/template.db.in b/bin/tests/system/dnssec/ns3/template.db.in
new file mode 100644 (file)
index 0000000..f603e44
--- /dev/null
@@ -0,0 +1,27 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; SPDX-License-Identifier: MPL-2.0
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0.  If a copy of the MPL was not distributed with this
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+$TTL 300       ; 5 minutes
+@                      IN SOA  mname1. . (
+                               2000042407 ; serial
+                               20         ; refresh (20 seconds)
+                               20         ; retry (20 seconds)
+                               1814400    ; expire (3 weeks)
+                               3600       ; minimum (1 hour)
+                               )
+                       NS      ns3
+ns3                    A       10.53.0.3
+
+a                      A       10.0.0.1
+a.b                    A       10.0.0.1
+b                      A       10.0.0.2
+d                      A       10.0.0.4
+z                      A       10.0.0.26
index 991ad54e8831a360d9634f1f0fc7380fe9f8d550..102f11384250958bd5bfe4b7ec43999265d9bc19 100644 (file)
@@ -4797,5 +4797,16 @@ n=$((n + 1))
 if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
+echo_i "checking extra-bad-algorithm positive validation ($n)"
+ret=0
+dig_with_opts +noauth a.extrabadkey.example. @10.53.0.3 A >dig.out.ns3.test$n || ret=1
+dig_with_opts +noauth a.extrabadkey.example. @10.53.0.4 A >dig.out.ns4.test$n || ret=1
+digcomp --lc dig.out.ns3.test$n dig.out.ns4.test$n || ret=1
+grep "status: NOERROR" dig.out.ns4.test$n >/dev/null || ret=1
+grep "flags:.*ad.*QUERY" dig.out.ns4.test$n >/dev/null || ret=1
+n=$((n + 1))
+test "$ret" -eq 0 || echo_i "failed"
+status=$((status + ret))
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1
index 7cd2633fe3f8c0db9edd54a8d9c821e43411d74a..a824ee7ef9e5b18317d974b0391d0ea09c2a042c 100644 (file)
@@ -100,6 +100,7 @@ pytestmark = pytest.mark.extra_artifacts(
         "ns3/example.bk",
         "ns3/expired.example.db",
         "ns3/expiring.example.db",
+        "ns3/extrabadkey.example.db",
         "ns3/future.example.db",
         "ns3/keyless.example.db",
         "ns3/kskonly.example.db",