]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Alter autosign system test
authorMatthijs Mekking <matthijs@isc.org>
Fri, 16 Jun 2023 11:52:14 +0000 (13:52 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Thu, 20 Jul 2023 09:04:23 +0000 (11:04 +0200)
The autosign system test mainly tests the auto-dnssec configuration
option. Since this option is going to be removed, update the system
test so that it uses dnssec-policy.

We could remove the complete system test, but keeping an altered
version of the system test may still be useful to detect unexpected
behavior after code changes.

Change the ns1 (test root server) to use manual signing. This zone
has some weird corner cases that do not fit the dnssec-policy model
very well.

The ns2 bar zone also needs to use manual signing, because it revokes
its key, and RFC 5011 key revocation is not supported with
dnssec-policy.

There are also a couple of weird corner test cases that can be removed:
- Inactive KSK or ZSK. With dnssec-policy there is no such thing as
  ZSK taking over the role of a KSK when the KSK is deleted, or vice
  versa.
- The CDS and CDNSKEY DELETE records are now automated with
  dnssec-policy and so the tests for persistence are no longer required.

In tests.sh, bump the expected number of root DNSKEY records to 11,
because with manual signing the activation before publication is
actually honored.

Also remove any 'rndc signing -nsec3param' commands because with
dnssec-policy you set the NSEC3 parameters in the configuration.

Remove any check interval tests, these "next key event" times are
now calculated and tested in the kasp system test.

17 files changed:
bin/tests/system/autosign/clean.sh
bin/tests/system/autosign/ns1/keygen.sh
bin/tests/system/autosign/ns1/named.conf.in
bin/tests/system/autosign/ns2/child.nsec3.example.db.in [moved from bin/tests/system/autosign/ns2/child.nsec3.example.db with 100% similarity]
bin/tests/system/autosign/ns2/child.optout.example.db.in [moved from bin/tests/system/autosign/ns2/child.optout.example.db with 100% similarity]
bin/tests/system/autosign/ns2/insecure.secure.example.db.in [moved from bin/tests/system/autosign/ns2/insecure.secure.example.db with 100% similarity]
bin/tests/system/autosign/ns2/keygen.sh
bin/tests/system/autosign/ns2/named.conf.in
bin/tests/system/autosign/ns3/cdnskey-delete.example.db.in [deleted file]
bin/tests/system/autosign/ns3/cds-delete.example.db.in [deleted file]
bin/tests/system/autosign/ns3/delay.example.db.in [moved from bin/tests/system/autosign/ns3/delay.example.db with 100% similarity]
bin/tests/system/autosign/ns3/inacksk2.example.db.in [deleted file]
bin/tests/system/autosign/ns3/inacksk3.example.db.in [deleted file]
bin/tests/system/autosign/ns3/inaczsk3.example.db.in [deleted file]
bin/tests/system/autosign/ns3/keygen.sh
bin/tests/system/autosign/ns3/named.conf.in
bin/tests/system/autosign/tests.sh

index 81589d78851265bd009526a6f1335c0ebb0212b0..dc379c0ebc5727dee9fcfb9d2fc1593f8e58bfd5 100644 (file)
@@ -11,6 +11,7 @@
 # See the COPYRIGHT file distributed with this work for additional
 # information regarding copyright ownership.
 
+rm -f ./dsset-*
 rm -f */K* */dsset-* */*.signed */tmp* */*.jnl */*.bk
 rm -f */core
 rm -f */example.bk
@@ -18,30 +19,34 @@ rm -f */named.conf
 rm -f */named.memstats
 rm -f */named.run*
 rm -f */trusted.conf */private.conf
-rm -f activate-now-publish-1day.key
-rm -f active.key inact.key del.key delzsk.key unpub.key standby.key rev.key
-rm -f delayksk.key delayzsk.key autoksk.key autozsk.key
 rm -f dig.out.*
 rm -f digcomp.out.test*
+rm -f activate-now-publish-1day.key prepub.key
+rm -f active.key inact.key del.key delzsk.key unpub.key standby.key rev.key
+rm -f delayksk.key delayzsk.key autoksk.key autozsk.key
 rm -f noksk-ksk.key nozsk-ksk.key nozsk-zsk.key inaczsk-zsk.key inaczsk-ksk.key
 rm -f nopriv.key vanishing.key del1.key del2.key
+rm -f ns*/inactive/*
+rmdir ns*/inactive
 rm -f ns*/managed-keys.bind*
 rm -f ns*/named.lock
-rm -f ns1/root.db
+rm -f ns1/root.db ns1/root.db.1 ns1/root.db.2 ns1/root.db.3
+rm -f ns1/signing.out
+rm -f ns2/bar.db
+rm -f ns2/child.nsec3.example.db
+rm -f ns2/child.optout.example.db
 rm -f ns2/example.db
+rm -f ns2/insecure.secure.example.db
 rm -f ns2/optout-with-ent.db
-rm -f ns2/private.secure.example.db ns2/bar.db
+rm -f ns2/private.secure.example.db
+rm -f ns2/signing.*
 rm -f ns3/*.nzd ns3/*.nzd-lock ns3/*.nzf
 rm -f ns3/*.nzf
 rm -f ns3/autonsec3.example.db
-rm -f ns3/cdnskey-delete.example.db
-rm -f ns3/cds-delete.example.db
+rm -f ns3/delay.example.db ns3/delay.example.1 ns3/delay.example.2
 rm -f ns3/delzsk.example.db
 rm -f ns3/dname-at-apex-nsec3.example.db
-rm -f ns3/inacksk2.example.db
-rm -f ns3/inacksk3.example.db
 rm -f ns3/inaczsk2.example.db
-rm -f ns3/inaczsk3.example.db
 rm -f ns3/jitter.nsec3.example.db
 rm -f ns3/kg.out ns3/s.out ns3/st.out
 rm -f ns3/kskonly.example.db
@@ -53,7 +58,7 @@ rm -f ns3/nsec3-to-nsec.example.db
 rm -f ns3/nsec3.example.db
 rm -f ns3/nsec3.nsec3.example.db
 rm -f ns3/nsec3.optout.example.db
-rm -f ns3/oldsigs.example.db
+rm -f ns3/oldsigs.example.db ns3/oldsigs.example.db.bak
 rm -f ns3/optout.example.db
 rm -f ns3/optout.nsec3.example.db
 rm -f ns3/optout.optout.example.db
@@ -68,5 +73,5 @@ rm -f ns3/sync.example.db
 rm -f ns3/ttl*.db
 rm -f nsupdate.out
 rm -f settime.out.*
-rm -f signing.out.*
+rm -f signing.*
 rm -f sync.key
index 6b969c317812675eef8fc206b34e6eca8dd73c20..bc4836e87633f9343fa58f88122192b93946b344 100644 (file)
@@ -31,8 +31,8 @@ zskactnowpub1d=$($KEYGEN -3 -a ${DEFAULT_ALGORITHM} -q -A now -P +1d $zone)
 zsknopriv=$($KEYGEN -3 -a ${DEFAULT_ALGORITHM} -q $zone)
 rm $zsknopriv.private
 
-ksksby=$($KEYGEN -3 -a ${DEFAULT_ALGORITHM} -q -P now -A now+15s -fk $zone)
-kskrev=$($KEYGEN -3 -a ${DEFAULT_ALGORITHM} -q -R now+15s -fk $zone)
+ksksby=$($KEYGEN -3 -a ${DEFAULT_ALGORITHM} -q -P now -A now -fk $zone)
+kskrev=$($KEYGEN -3 -a ${DEFAULT_ALGORITHM} -q -R now -fk $zone)
 
 keyfile_to_static_ds $ksksby > trusted.conf
 cp trusted.conf ../ns2/trusted.conf
@@ -51,3 +51,5 @@ echo $zsknopriv > ../nopriv.key
 echo $zsksby > ../standby.key
 echo $zskactnowpub1d > ../activate-now-publish-1day.key
 $REVOKE -R $kskrev > ../rev.key
+
+$SIGNER -S -o . -O full root.db > signing.out 2>&1
index 2a5548349ff85a4c7728526f22894c02fdc7aa11..64214825954a2fea3c68d6e497ec4b79c71556bb 100644 (file)
@@ -37,12 +37,10 @@ controls {
 
 zone "." {
        type primary;
-       file "root.db";
+       file "root.db.signed";
        allow-transfer { any; };
-       allow-query { any; };
        allow-update { any; };
-       auto-dnssec maintain;
-       dnssec-dnskey-kskonly no;
+       allow-query { any; };
 };
 
 include "trusted.conf";
index 8061adb6a543cd7ca79da890143a98518b13aca7..f9aa3bcdf13fd87b3435b1f3751a3879e03d313a 100644 (file)
@@ -40,7 +40,7 @@ ksk=$($KEYGEN -a ${DEFAULT_ALGORITHM} -3 -q -fk $zone)
 $KEYGEN -a ${DEFAULT_ALGORITHM} -3 -q $zone > /dev/null
 keyfile_to_static_ds $ksk > private.conf
 cp private.conf ../ns4/private.conf
-$SIGNER -S -3 beef -A -o $zone -f $zonefile $infile > /dev/null
+$SIGNER -S -3 beef -A -o $zone -f $zonefile $infile > signing.privsec.out 2>&1
 
 # Extract saved keys for the revoke-to-duplicate-key test
 zone=bar
@@ -54,6 +54,7 @@ do
 done
 $KEYGEN -a ECDSAP256SHA256 -q $zone > /dev/null
 $DSFROMKEY Kbar.+013+60101.key > dsset-bar.
+$SIGNER -S -o bar. -O full $zonefile > signing.bar.out 2>&1
 
 # a zone with empty non-terminals.
 zone=optout-with-ent
@@ -62,3 +63,8 @@ infile=optout-with-ent.db.in
 cat $infile > $zonefile
 kskname=$($KEYGEN -a ${DEFAULT_ALGORITHM} -3 -q -fk $zone)
 $KEYGEN -a ${DEFAULT_ALGORITHM} -3 -q $zone > /dev/null
+
+# Copy zone input files
+cp child.nsec3.example.db.in child.nsec3.example.db
+cp child.optout.example.db.in child.optout.example.db
+cp insecure.secure.example.db.in insecure.secure.example.db
index c155a3bb7de03e446cbfdbbe2f4dab0e7c8e4b66..caf2ab83ded074d41552194c1244eda26e843037 100644 (file)
@@ -36,6 +36,40 @@ controls {
        inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
 };
 
+dnssec-policy "autosign" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+};
+
+dnssec-policy "private" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+
+       nsec3param iterations 0 optout no salt-length 2;
+};
+
+dnssec-policy "nsec3" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+
+       nsec3param iterations 0 optout no salt-length 0;
+};
+
+dnssec-policy "optout" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+
+       nsec3param iterations 1 optout yes salt-length 0;
+};
+
 zone "." {
        type hint;
        file "../../common/root.hint";
@@ -47,18 +81,16 @@ zone "example" {
        allow-query { any; };
        allow-transfer { any; };
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
        sig-signing-type 65280;
 };
 
 zone "bar" {
        type primary;
-       file "bar.db";
+       file "bar.db.signed";
        allow-query { any; };
        allow-transfer { any; };
        allow-update { any; };
-       auto-dnssec maintain;
-       dnssec-dnskey-kskonly yes;
 };
 
 zone "private.secure.example" {
@@ -67,7 +99,7 @@ zone "private.secure.example" {
        allow-query { any; };
        allow-transfer { any; };
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy private;
 };
 
 zone "insecure.secure.example" {
@@ -76,7 +108,7 @@ zone "insecure.secure.example" {
        allow-query { any; };
        allow-transfer { any; };
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "child.nsec3.example" {
@@ -85,7 +117,7 @@ zone "child.nsec3.example" {
        allow-query { any; };
        allow-transfer { any; };
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 zone "child.optout.example" {
@@ -94,7 +126,7 @@ zone "child.optout.example" {
        allow-query { any; };
        allow-transfer { any; };
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy optout;
 };
 
 zone "optout-with-ent" {
@@ -103,7 +135,7 @@ zone "optout-with-ent" {
        allow-query { any; };
        allow-transfer { any; };
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy optout;
 };
 
 include "trusted.conf";
diff --git a/bin/tests/system/autosign/ns3/cdnskey-delete.example.db.in b/bin/tests/system/autosign/ns3/cdnskey-delete.example.db.in
deleted file mode 100644 (file)
index 3083a79..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-; 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 http://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. . (
-                               2009102722 ; serial
-                               20         ; refresh (20 seconds)
-                               20         ; retry (20 seconds)
-                               1814400    ; expire (3 weeks)
-                               3600       ; minimum (1 hour)
-                               )
-                       NS      ns
-ns                     A       10.53.0.3
-
-a                      A       10.0.0.1
-b                      A       10.0.0.2
-d                      A       10.0.0.4
-z                      A       10.0.0.26
-a.a.a.a.a.a.a.a.a.a.e  A       10.0.0.27
-x                      CNAME   a
diff --git a/bin/tests/system/autosign/ns3/cds-delete.example.db.in b/bin/tests/system/autosign/ns3/cds-delete.example.db.in
deleted file mode 100644 (file)
index 3083a79..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-; 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 http://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. . (
-                               2009102722 ; serial
-                               20         ; refresh (20 seconds)
-                               20         ; retry (20 seconds)
-                               1814400    ; expire (3 weeks)
-                               3600       ; minimum (1 hour)
-                               )
-                       NS      ns
-ns                     A       10.53.0.3
-
-a                      A       10.0.0.1
-b                      A       10.0.0.2
-d                      A       10.0.0.4
-z                      A       10.0.0.26
-a.a.a.a.a.a.a.a.a.a.e  A       10.0.0.27
-x                      CNAME   a
diff --git a/bin/tests/system/autosign/ns3/inacksk2.example.db.in b/bin/tests/system/autosign/ns3/inacksk2.example.db.in
deleted file mode 100644 (file)
index 1376922..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-; 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. . (
-                               1          ; serial
-                               20         ; refresh (20 seconds)
-                               20         ; retry (20 seconds)
-                               1814400    ; expire (3 weeks)
-                               3600       ; minimum (1 hour)
-                               )
-                       NS      ns
-ns                     A       10.53.0.3
-
-a                      A       10.0.0.1
-b                      A       10.0.0.2
-d                      A       10.0.0.4
-x                      CNAME   a
diff --git a/bin/tests/system/autosign/ns3/inacksk3.example.db.in b/bin/tests/system/autosign/ns3/inacksk3.example.db.in
deleted file mode 100644 (file)
index 1376922..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-; 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. . (
-                               1          ; serial
-                               20         ; refresh (20 seconds)
-                               20         ; retry (20 seconds)
-                               1814400    ; expire (3 weeks)
-                               3600       ; minimum (1 hour)
-                               )
-                       NS      ns
-ns                     A       10.53.0.3
-
-a                      A       10.0.0.1
-b                      A       10.0.0.2
-d                      A       10.0.0.4
-x                      CNAME   a
diff --git a/bin/tests/system/autosign/ns3/inaczsk3.example.db.in b/bin/tests/system/autosign/ns3/inaczsk3.example.db.in
deleted file mode 100644 (file)
index 1376922..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-; 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. . (
-                               1          ; serial
-                               20         ; refresh (20 seconds)
-                               20         ; retry (20 seconds)
-                               1814400    ; expire (3 weeks)
-                               3600       ; minimum (1 hour)
-                               )
-                       NS      ns
-ns                     A       10.53.0.3
-
-a                      A       10.0.0.1
-b                      A       10.0.0.2
-d                      A       10.0.0.4
-x                      CNAME   a
index 89c76723543009abb0af637026b88d5be0dcccb5..fac4fc5811ae711d726e0ad471e50f5b74ec107e 100644 (file)
@@ -29,6 +29,8 @@ setup () {
        n=$((${n:-0} + 1))
 }
 
+mkdir inactive
+
 setup secure.example
 cp $infile $zonefile
 ksk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -fk $zone 2> kg.out) || dumpit kg.out
@@ -181,7 +183,8 @@ do
 done
 $KEYGEN -q -a $DEFAULT_ALGORITHM -fk $zone > kg.out 2>&1 || dumpit kg.out
 $KEYGEN -q -a $DEFAULT_ALGORITHM $zone > kg.out 2>&1 || dumpit kg.out
-$SIGNER -PS -s now-1y -e now-6mo -o $zone -f $zonefile.signed $zonefile > s.out || dumpit s.out
+$SIGNER -PS -x -s now-1y -e now-6mo -o $zone -f $zonefile.signed $zonefile > s.out || dumpit s.out
+cp $zonefile.signed $zonefile.bak
 mv $zonefile.signed $zonefile
 
 #
@@ -198,7 +201,8 @@ $SIGNER -S -3 beef -A -o $zone -f $zonefile $infile > s.out || dumpit s.out
 setup prepub.example
 infile="prepub.example.db.in"
 $KEYGEN -a $DEFAULT_ALGORITHM -3 -q -fk $zone > kg.out 2>&1 || dumpit kg.out
-$KEYGEN -a $DEFAULT_ALGORITHM -3 -q $zone > kg.out 2>&1 || dumpit kg.out
+zsk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q $zone 2> kg.out) || dumpit kg.out
+echo $zsk > ../prepub.key
 $SIGNER -S -3 beef -o $zone -f $zonefile $infile > s.out || dumpit s.out
 
 #
@@ -237,6 +241,7 @@ ksk=$($KEYGEN -G -q -a $DEFAULT_ALGORITHM -3 -fk $zone 2> kg.out) || dumpit kg.o
 echo $ksk > ../delayksk.key
 zsk=$($KEYGEN -G -q -a $DEFAULT_ALGORITHM -3 $zone 2> kg.out) || dumpit kg.out
 echo $zsk > ../delayzsk.key
+cp delay.example.db.in delay.example.db
 
 #
 # A zone with signatures that are already expired, and the private KSK
@@ -274,7 +279,7 @@ echo $zsk > ../inaczsk-zsk.key
 $SETTIME -I now $zsk > st.out 2>&1 || dumpit st.out
 
 #
-# A zone that is set to 'auto-dnssec maintain' during a reconfig
+# A zone that is set to 'dnssec-policy' during a reconfig
 #
 setup reconf.example
 cp secure.example.db.in $zonefile
@@ -282,7 +287,7 @@ $KEYGEN -q -a $DEFAULT_ALGORITHM -3 -fk $zone > kg.out 2>&1 || dumpit kg.out
 $KEYGEN -q -a $DEFAULT_ALGORITHM -3 $zone > kg.out 2>&1 || dumpit kg.out
 
 #
-# A zone which generates CDS and CDNSEY RRsets automatically
+# A zone which generates CDS and CDNSEY RRsets automatically (with an additional CSK)
 #
 setup sync.example
 cp $infile $zonefile
@@ -292,7 +297,7 @@ $DSFROMKEY $ksk.key > dsset-${zone}.
 echo ns3/$ksk > ../sync.key
 
 #
-# A zone that generates CDS and CDNSKEY and uses dnssec-dnskey-kskonly
+# A zone that generates CDS and CDNSKEY automatically
 #
 setup kskonly.example
 cp $infile $zonefile
@@ -300,15 +305,6 @@ ksk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -fk -P sync now $zone 2> kg.out) || du
 $KEYGEN -a $DEFAULT_ALGORITHM -3 -q $zone > kg.out 2>&1 || dumpit kg.out
 $DSFROMKEY $ksk.key > dsset-${zone}.
 
-#
-# A zone that has a published inactive key that is autosigned.
-#
-setup inacksk2.example
-cp $infile $zonefile
-ksk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -Pnow -A now+3600 -fk $zone 2> kg.out) || dumpit kg.out
-$KEYGEN -a $DEFAULT_ALGORITHM -3 -q $zone > kg.out 2>&1 || dumpit kg.out
-$DSFROMKEY $ksk.key > dsset-${zone}.
-
 #
 # A zone that has a published inactive key that is autosigned.
 #
@@ -318,26 +314,6 @@ ksk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -fk $zone 2> kg.out) || dumpit kg.out
 $KEYGEN -a $DEFAULT_ALGORITHM -3 -q -P now -A now+3600 $zone > kg.out 2>&1 || dumpit kg.out
 $DSFROMKEY $ksk.key > dsset-${zone}.
 
-#
-# A zone that starts with a active KSK + ZSK and a inactive ZSK.
-#
-setup inacksk3.example
-cp $infile $zonefile
-$KEYGEN -a $DEFAULT_ALGORITHM -3 -q -P now -A now+3600 -fk $zone > kg.out 2>&1 || dumpit kg.out
-ksk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -fk $zone 2> kg.out) || dumpit kg.out
-$KEYGEN -a $DEFAULT_ALGORITHM -3 -q $zone > kg.out 2>&1 || dumpit kg.out
-$DSFROMKEY $ksk.key > dsset-${zone}.
-
-#
-# A zone that starts with a active KSK + ZSK and a inactive ZSK.
-#
-setup inaczsk3.example
-cp $infile $zonefile
-ksk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -fk $zone 2> kg.out) || dumpit kg.out
-$KEYGEN -a $DEFAULT_ALGORITHM -3 -q $zone > kg.out 2>&1 || dumpit kg.out
-$KEYGEN -a $DEFAULT_ALGORITHM -3 -q -P now -A now+3600 $zone > kg.out 2>&1 || dumpit kg.out
-$DSFROMKEY $ksk.key > dsset-${zone}.
-
 #
 # A zone that starts with an active KSK + ZSK and an inactive ZSK, with the
 # latter getting deleted during the test.
@@ -347,6 +323,9 @@ cp $infile $zonefile
 ksk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -fk $zone 2> kg.out) || dumpit kg.out
 $KEYGEN -a $DEFAULT_ALGORITHM -3 -q $zone > kg.out 2>&1 || dumpit kg.out
 zsk=$($KEYGEN -a $DEFAULT_ALGORITHM -3 -q -I now-1w $zone 2>kg.out) || dumpit kg.out
+cat $zsk.key >> $zonefile
+mv $zsk.key inactive/
+mv $zsk.private inactive/
 echo $zsk > ../delzsk.key
 
 #
@@ -357,22 +336,3 @@ cp $infile $zonefile
 ksk=$($KEYGEN -q -a $DEFAULT_ALGORITHM -3 -fk $zone 2> kg.out) || dumpit kg.out
 $KEYGEN -q -a $DEFAULT_ALGORITHM -3 $zone > kg.out 2>&1 || dumpit kg.out
 $DSFROMKEY $ksk.key > dsset-${zone}.
-
-#
-# Check that dynamically added CDS (DELETE) is kept in the zone after signing.
-#
-setup cds-delete.example
-cp $infile $zonefile
-ksk=$($KEYGEN -q -a $DEFAULT_ALGORITHM -3 -fk $zone 2> kg.out) || dumpit kg.out
-$KEYGEN -q -a $DEFAULT_ALGORITHM -3 $zone > kg.out 2>&1 || dumpit kg.out
-$DSFROMKEY $ksk.key > dsset-${zone}.
-
-#
-# Check that dynamically added CDNSKEY (DELETE) is kept in the zone after
-# signing.
-#
-setup cdnskey-delete.example
-cp $infile $zonefile
-ksk=$($KEYGEN -q -a $DEFAULT_ALGORITHM -3 -fk $zone 2> kg.out) || dumpit kg.out
-$KEYGEN -q -a $DEFAULT_ALGORITHM -3 $zone > kg.out 2>&1 || dumpit kg.out
-$DSFROMKEY $ksk.key > dsset-${zone}.
index d529440ad8c2fdfe505a77dfdb9f4af953af50d1..7111515be555fc5626db17a344350c603691203d 100644 (file)
@@ -40,6 +40,86 @@ controls {
        inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
 };
 
+# The default
+dnssec-policy "autosign" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+};
+
+# Additional CSK
+dnssec-policy "sync" {
+       keys {
+               csk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+};
+
+# NSEC3
+dnssec-policy "nsec3" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+
+       nsec3param iterations 0 optout no salt-length 0;
+};
+
+# NSEC3 opt-out
+dnssec-policy "optout" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+
+       nsec3param iterations 0 optout yes salt-length 0;
+};
+
+# Jitter
+dnssec-policy "jitter" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+
+       signatures-validity P10D;
+       signatures-validity-dnskey P10D;
+       signatures-refresh P2D;
+};
+
+# Jitter, NSEC3
+dnssec-policy "jitter-nsec3" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+               zsk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
+       };
+
+       nsec3param iterations 0 optout no salt-length 0;
+
+       signatures-validity P10D;
+       signatures-validity-dnskey P10D;
+       signatures-refresh P2D;
+
+};
+
+# RSASHA256
+dnssec-policy "rsasha256" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm RSASHA256 2048;
+               zsk key-directory lifetime unlimited algorithm RSASHA256 2048;
+       };
+};
+
+# RSASHA512
+dnssec-policy "rsasha512" {
+       keys {
+               ksk key-directory lifetime unlimited algorithm RSASHA512 2048;
+               zsk key-directory lifetime unlimited algorithm RSASHA512 2048;
+       };
+};
+
 zone "." {
        type hint;
        file "../../common/root.hint";
@@ -61,48 +141,48 @@ zone "secure.example" {
        type primary;
        file "secure.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "insecure.example" {
        type primary;
        file "insecure.example.db";
+       dnssec-policy none;
 };
 
 zone "nsec3.example" {
        type primary;
        file "nsec3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 zone "autonsec3.example" {
        type primary;
        file "autonsec3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 zone "optout.nsec3.example" {
        type primary;
        file "optout.nsec3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy optout;
 };
 
 zone "nsec3.nsec3.example" {
        type primary;
        file "nsec3.nsec3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 zone "jitter.nsec3.example" {
        type primary;
        file "jitter.nsec3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
-       sig-validity-interval 10 2;
+       dnssec-policy jitter-nsec3;
        sig-signing-nodes 1000;
        sig-signing-signatures 100;
 };
@@ -111,71 +191,70 @@ zone "secure.nsec3.example" {
        type primary;
        file "secure.nsec3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 zone "optout.example" {
        type primary;
        file "optout.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy optout;
 };
 
 zone "secure.optout.example" {
        type primary;
        file "secure.optout.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy optout;
 };
 
 zone "nsec3.optout.example" {
        type primary;
        file "nsec3.optout.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy optout;
 };
 
 zone "optout.optout.example" {
        type primary;
        file "optout.optout.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy optout;
 };
 
 zone "rsasha256.example" {
        type primary;
        file "rsasha256.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy rsasha256;
 };
 
 zone "rsasha512.example" {
        type primary;
        file "rsasha512.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy rsasha512;
 };
 
 zone "nsec-only.example" {
        type primary;
        file "nsec-only.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "nsec3-to-nsec.example" {
        type primary;
        file "nsec3-to-nsec.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 zone "oldsigs.example" {
        type primary;
        file "oldsigs.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
-       sig-validity-interval 10 2;
+       dnssec-policy jitter;
        sig-signing-nodes 1000;
        sig-signing-signatures 100;
 };
@@ -184,137 +263,96 @@ zone "prepub.example" {
        type primary;
        file "prepub.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "ttl1.example" {
        type primary;
        file "ttl1.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "ttl2.example" {
        type primary;
        file "ttl2.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "ttl3.example" {
        type primary;
        file "ttl3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "ttl4.example" {
        type primary;
        file "ttl4.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "delay.example" {
        type primary;
        file "delay.example.db";
-       allow-update { any; };
-       auto-dnssec maintain;
 };
 
 zone "nozsk.example" {
        type primary;
        file "nozsk.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "inaczsk.example" {
        type primary;
        file "inaczsk.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "noksk.example" {
        type primary;
        file "noksk.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "sync.example" {
        type primary;
        file "sync.example.db";
        allow-update { any; };
-       dnssec-dnskey-kskonly no;
-       auto-dnssec maintain;
+       dnssec-policy sync;
 };
 
 zone "kskonly.example" {
        type primary;
        file "kskonly.example.db";
        allow-update { any; };
-       dnssec-dnskey-kskonly yes;
-       auto-dnssec maintain;
-};
-
-zone "inacksk2.example" {
-       type primary;
-       file "inacksk2.example.db";
-       allow-update { any; };
-       dnssec-dnskey-kskonly yes;
-       auto-dnssec maintain;
-};
-
-zone "inacksk3.example" {
-       type primary;
-       file "inacksk3.example.db";
-       allow-update { any; };
-       dnssec-dnskey-kskonly yes;
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "inaczsk2.example" {
        type primary;
        file "inaczsk2.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
-};
-
-zone "inaczsk3.example" {
-       type primary;
-       file "inaczsk3.example.db";
-       allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy autosign;
 };
 
 zone "delzsk.example." {
        type primary;
        file "delzsk.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 zone "dname-at-apex-nsec3.example" {
        type primary;
        file "dname-at-apex-nsec3.example.db";
        allow-update { any; };
-       auto-dnssec maintain;
-};
-
-zone "cds-delete.example" {
-       type primary;
-       file "cds-delete.example.db";
-       allow-update { any; };
-       auto-dnssec maintain;
-};
-
-zone "cdnskey-delete.example" {
-       type primary;
-       file "cdnskey-delete.example.db";
-       allow-update { any; };
-       auto-dnssec maintain;
+       dnssec-policy nsec3;
 };
 
 include "trusted.conf";
index 40136edafdca12ea72bc2c031b6910133ed2cf11..5a31e29ee356ea619dbb0bf788fd67d49fe27d02 100755 (executable)
@@ -155,23 +155,22 @@ do
        #
        # Wait for the root DNSKEY RRset to be fully signed.
        #
-       $DIG $DIGOPTS . @10.53.0.1 dnskey > dig.out.ns1.test$n || ret=1
-       grep "ANSWER: 10," dig.out.ns1.test$n > /dev/null || ret=1
+       $DIG $DIGOPTS . @10.53.0.1 dnskey > dig.out.ns1.test$n.dnskey || ret=1
+       grep "ANSWER: 11," dig.out.ns1.test$n.dnskey > /dev/null || ret=1
        for z in .
        do
-               $DIG $DIGOPTS $z @10.53.0.1 nsec > dig.out.ns1.test$n || ret=1
-               grep "NS SOA" dig.out.ns1.test$n > /dev/null || ret=1
+               $DIG $DIGOPTS $z @10.53.0.1 nsec > dig.out.ns1.test$n.nsec || ret=1
+               grep "NS SOA" dig.out.ns1.test$n.nsec > /dev/null || ret=1
        done
-       for z in bar. example. private.secure.example. optout-with-ent.
+       for z in bar. example. # skip NSEC3 signed zones
        do
-               $DIG $DIGOPTS $z @10.53.0.2 nsec > dig.out.ns2.test$n || ret=1
-               grep "NS SOA" dig.out.ns2.test$n > /dev/null || ret=1
+               $DIG $DIGOPTS $z @10.53.0.2 nsec > dig.out.ns2.test$n.$z || ret=1
+               grep "NS SOA" dig.out.ns2.test$n.$z > /dev/null || ret=1
        done
-       for z in bar. example. inacksk2.example. inacksk3.example \
-                inaczsk2.example. inaczsk3.example noksk.example nozsk.example
+       for z in bar. example. inaczsk2.example. noksk.example nozsk.example
        do
-               $DIG $DIGOPTS $z @10.53.0.3 nsec > dig.out.ns3.test$n || ret=1
-               grep "NS SOA" dig.out.ns3.test$n > /dev/null || ret=1
+               $DIG $DIGOPTS $z @10.53.0.3 nsec > dig.out.ns3.test$n.$z || ret=1
+               grep "NS SOA" dig.out.ns3.test$n.$z > /dev/null || ret=1
        done
        i=$((i + 1))
        if [ $ret = 0 ]; then break; fi
@@ -179,12 +178,9 @@ do
        sleep 2
 done
 n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "done"; fi
+if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "Convert optout-with-ent from nsec to nsec3"
-($RNDCCMD 10.53.0.2 signing -nsec3param 1 1 1 - optout-with-ent 2>&1 | sed 's/^/ns2 /' | cat_i) || ret=1
-
 echo_i "Initial counts of RRSIG expiry fields values for auto signed zones"
 for z in .
 do
@@ -196,7 +192,7 @@ do
        echo_i zone $z
        $DIG $DIGOPTS $z @10.53.0.2 axfr | awk '$4 == "RRSIG" {print $9}' | sort | uniq -c | cat_i
 done
-for z in inacksk2.example. inacksk3.example inaczsk2.example. inaczsk3.example
+for z in inaczsk2.example.
 do
        echo_i zone $z
        $DIG $DIGOPTS $z @10.53.0.3 axfr | awk '$4 == "RRSIG" {print $9}' | sort | uniq -c | cat_i
@@ -205,107 +201,6 @@ done
 # Set logfile offset for wait_for_log usage.
 nextpartreset ns3/named.run
 
-#
-# Check that DNSKEY is initially signed with a KSK and not a ZSK.
-#
-echo_i "check that zone with active and inactive KSK and active ZSK is properly"
-echo_ic "resigned after the active KSK is deleted - stage 1: Verify that DNSKEY"
-echo_ic "is initially signed with a KSK and not a ZSK. ($n)"
-ret=0
-
-$DIG $DIGOPTS @10.53.0.3 axfr inacksk3.example > dig.out.ns3.test$n
-
-zskid=$(awk '$4 == "DNSKEY" && $5 == 256 { print }' dig.out.ns3.test$n |
-       $DSFROMKEY -A -2 -f - inacksk3.example | awk '{ print $4}')
-grep "DNSKEY ${DEFAULT_ALGORITHM_NUMBER} 2 " dig.out.ns3.test$n > /dev/null || ret=1
-
-pattern="DNSKEY ${DEFAULT_ALGORITHM_NUMBER} 2 [0-9]* [0-9]* [0-9]* ${zskid} "
-grep "${pattern}" dig.out.ns3.test$n > /dev/null && ret=1
-
-count=$(awk 'BEGIN { count = 0 }
-           $4 == "RRSIG" && $5 == "DNSKEY" { count++ }
-           END {print count}' dig.out.ns3.test$n)
-test $count -eq 1 || ret=1
-
-count=$(awk 'BEGIN { count = 0 }
-       $4 == "DNSKEY" { count++ }
-       END {print count}' dig.out.ns3.test$n)
-test $count -eq 3 || ret=1
-
-awk='$4 == "RRSIG" && $5 == "DNSKEY" { printf "%05u\n", $11 }'
-id=$(awk "${awk}" dig.out.ns3.test$n)
-
-keyfile=$(printf "ns3/Kinacksk3.example.+%03u+%s" "${DEFAULT_ALGORITHM_NUMBER}" "${id}")
-$SETTIME -D now+5 "${keyfile}" > settime.out.test$n || ret=1
-($RNDCCMD 10.53.0.3 loadkeys inacksk3.example 2>&1 | sed 's/^/ns3 /' | cat_i) || ret=1
-
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-#
-# Check that zone is initially signed with a ZSK and not a KSK.
-#
-echo_i "check that zone with active and inactive ZSK and active KSK is properly"
-echo_ic "resigned after the active ZSK is deleted - stage 1: Verify that zone"
-echo_ic "is initially signed with a ZSK and not a KSK. ($n)"
-ret=0
-$DIG $DIGOPTS @10.53.0.3 axfr inaczsk3.example > dig.out.ns3.test$n
-kskid=$(awk '$4 == "DNSKEY" && $5 == 257 { print }' dig.out.ns3.test$n |
-       $DSFROMKEY -2 -f - inaczsk3.example | awk '{ print $4}' )
-grep "CNAME ${DEFAULT_ALGORITHM_NUMBER} 3 " dig.out.ns3.test$n > /dev/null || ret=1
-grep "CNAME ${DEFAULT_ALGORITHM_NUMBER} 3 [0-9]* [0-9]* [0-9]* ${kskid} " dig.out.ns3.test$n > /dev/null && ret=1
-count=$(awk 'BEGIN { count = 0 }
-           $4 == "RRSIG" && $5 == "CNAME" { count++ }
-           END {print count}' dig.out.ns3.test$n)
-test $count -eq 1 || ret=1
-count=$(awk 'BEGIN { count = 0 }
-       $4 == "DNSKEY" { count++ }
-       END {print count}' dig.out.ns3.test$n)
-test $count -eq 3 || ret=1
-id=$(awk '$4 == "RRSIG" && $5 == "CNAME" { printf "%05u\n", $11 }' dig.out.ns3.test$n)
-
-keyfile=$(printf "ns3/Kinaczsk3.example.+%03u+%s" "${DEFAULT_ALGORITHM_NUMBER}" "${id}")
-$SETTIME -D now+5 "${keyfile}" > settime.out.test$n || ret=1
-($RNDCCMD 10.53.0.3 loadkeys inaczsk3.example 2>&1 | sed 's/^/ns3 /' | cat_i) || ret=1
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-echo_i "resetting nsec3param via rndc signing ($n)"
-ret=0
-$RNDCCMD 10.53.0.3 signing -clear all autonsec3.example. > /dev/null 2>&1
-$RNDCCMD 10.53.0.3 signing -nsec3param 1 1 10 beef autonsec3.example. > /dev/null 2>&1
-for i in 0 1 2 3 4 5 6 7 8 9; do
-       ret=0
-       $RNDCCMD 10.53.0.3 signing -list autonsec3.example. > signing.out.test$n 2>&1
-       grep "Pending NSEC3 chain 1 1 10 BEEF" signing.out.test$n > /dev/null || ret=1
-       num=$(grep "Pending " signing.out.test$n | wc -l)
-       [ $num -eq 1 ] || ret=1
-       [ $ret -eq 0 ] && break
-       echo_i "waiting ... ($i)"
-       sleep 2
-done
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-echo_i "setting nsec3param via rndc signing ($n)"
-ret=0
-$RNDCCMD 10.53.0.3 signing -nsec3param 1 1 10 beef optout.example. 2>&1
-for i in 0 1 2 3 4 5 6 7 8 9; do
-       ret=0
-       $DIG $DIGOPTS @10.53.0.3 nsec3param optout.example > dig.out.ns3.test$n
-       # Note that the Opt-Out flag is not used in NSEC3PARAM and is set to zero.
-       grep "NSEC3PARAM.*1.*0.*10.*BEEF" dig.out.ns3.test$n > /dev/null || ret=1
-       [ $ret -eq 0 ] && break
-       echo_i "waiting ... ($i)"
-       sleep 2
-done
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
 echo_i "signing preset nsec3 zone"
 zsk=$(cat autozsk.key)
 ksk=$(cat autoksk.key)
@@ -890,7 +785,7 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "checking that deactivated key does not sign records  ($n)"
+echo_i "checking that deactivated key does not sign records ($n)"
 ret=0
 id=$(keyfile_to_key_id "$(cat inact.key)")
 $DIG $DIGOPTS dnskey . @10.53.0.1 > dig.out.ns1.test$n || ret=1
@@ -932,10 +827,9 @@ ret=0
 $DIG $DIGOPTS +short soa prepub.example @10.53.0.3 > dig.out.ns3.test$n || ret=1
 oldserial=$(cat dig.out.ns3.test$n | awk '$0 !~ /SOA/ {print $3}')
 oldinception=$(cat dig.out.ns3.test$n | awk '/SOA/ {print $6}' | sort -u)
-
-$KEYGEN -a $DEFAULT_ALGORITHM -3 -q -K ns3 -P 0 -A +6d -I +38d -D +45d prepub.example > /dev/null
-
-($RNDCCMD 10.53.0.3 sign prepub.example 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
+id=$(keyfile_to_key_id "$(cat prepub.key)")
+echo_i "prepublish key for ZSK $id"
+($RNDCCMD 10.53.0.3 dnssec -rollover -key $id prepub.example 2>&1 | sed 's/^/ns3 /' | cat_i) || ret=1
 newserial=$oldserial
 try=0
 while [ $oldserial -eq $newserial -a $try -lt 42 ]
@@ -955,30 +849,31 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "preparing to test key change corner cases"
-echo_i "removing a private key file"
-file="ns1/$(cat vanishing.key).private"
-rm -f $file
-
 echo_i "preparing ZSK roll"
 starttime=$($PERL -e 'print time(), "\n";')
 oldfile=$(cat active.key)
 oldid=$(keyfile_to_key_id "$(cat active.key)")
 newfile=$(cat standby.key)
 newid=$(keyfile_to_key_id "$(cat standby.key)")
-$SETTIME -K ns1 -I now+2s -D now+25 $oldfile > settime.out.test$n.1 || ret=1
+$SETTIME -K ns1 -I now -D now+25 $oldfile > settime.out.test$n.1 || ret=1
 $SETTIME -K ns1 -i 0 -S $oldfile $newfile > settime.out.test$n.2 || ret=1
 
 # note previous zone serial number
 oldserial=$($DIG $DIGOPTS +short soa . @10.53.0.1 | awk '{print $3}')
 
-($RNDCCMD 10.53.0.1 loadkeys . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
+($RNDCCMD 10.53.0.1 freeze . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
+cp ns1/root.db.signed ns1/root.db.1
+$SIGNER -S -o . -O full -K ns1 -f ns1/root.db.signed ns1/root.db.1 > signing.root.out$n 2>&1 || ret=1
+($RNDCCMD 10.53.0.1 thaw . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
 sleep 4
 
 echo_i "revoking key to duplicated key ID"
 $SETTIME -R now -K ns2 Kbar.+013+59973.key > settime.out.test$n.3 || ret=1
 
-($RNDCCMD 10.53.0.2 loadkeys bar. 2>&1 | sed 's/^/ns2 /' | cat_i) || ret=1
+($RNDCCMD 10.53.0.2 freeze bar. 2>&1 | sed 's/^/ns2 /' | cat_i) || ret=1
+cp ns2/bar.db.signed ns2/bar.db
+$SIGNER -S -o bar. -O full -K ns2 ns2/bar.db > signing.bar.out$n 2>&1 || ret=1
+($RNDCCMD 10.53.0.2 thaw bar. 2>&1 | sed 's/^/ns2 /' | cat_i) || ret=1
 
 echo_i "waiting for changes to take effect"
 sleep 5
@@ -1002,7 +897,6 @@ status=$((status + ret))
 
 echo_i "checking that signing records have been marked as complete ($n)"
 ret=0
-checkprivate bar 10.53.0.2 || ret=1
 checkprivate example 10.53.0.2 0 type65280 || ret=1 # sig-signing-type 65280
 checkprivate private.secure.example 10.53.0.3 2 || ret=1 # pre-signed
 checkprivate nsec3.example 10.53.0.3 || ret=1
@@ -1017,7 +911,7 @@ checkprivate oldsigs.example 10.53.0.3 2 || ret=1 # pre-signed
 checkprivate optout.example 10.53.0.3 || ret=1
 checkprivate optout.nsec3.example 10.53.0.3 || ret=1
 checkprivate optout.optout.example 10.53.0.3 || ret=1
-checkprivate prepub.example 10.53.0.3 1 || ret=1 # expecting incomplete
+checkprivate prepub.example 10.53.0.3 2 || ret=1 # pre-signed
 checkprivate rsasha256.example 10.53.0.3 || ret=1
 checkprivate rsasha512.example 10.53.0.3 || ret=1
 checkprivate secure.example 10.53.0.3 || ret=1
@@ -1032,14 +926,17 @@ status=$((status + ret))
 
 echo_i "forcing full sign ($n)"
 ret=0
-($RNDCCMD 10.53.0.1 sign . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
+($RNDCCMD 10.53.0.1 freeze . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
+cp ns1/root.db.signed ns1/root.db.2
+$SIGNER -S -o . -O full -K ns1 -f ns1/root.db.signed ns1/root.db > signing.root.out$n 2>&1 || ret=1
+($RNDCCMD 10.53.0.1 thaw . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
 n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 
 echo_i "waiting for change to take effect"
 sleep 5
 
-echo_i "checking former standby key has now signed fully ($n)"
+echo_i "checking former standby key $newid has now signed fully ($n)"
 ret=0
 $DIG $DIGOPTS txt . @10.53.0.1 > dig.out.ns1.test$n || ret=1
 grep 'RRSIG.*'" $newid "'\. ' dig.out.ns1.test$n > /dev/null || ret=1
@@ -1055,6 +952,11 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
+echo_i "preparing to test key change corner cases"
+echo_i "removing a private key file"
+file="ns1/$(cat vanishing.key).private"
+rm -f $file
+
 echo_i "checking delayed key publication/activation ($n)"
 ret=0
 zsk=$(cat delayzsk.key)
@@ -1075,30 +977,32 @@ echo_i "checking scheduled key publication, not activation ($n)"
 ret=0
 # Ensure initial zone is loaded.
 wait_for_notifies "delay.example" "ns3" || ret=1
-$SETTIME -K ns3 -P now+3s -A none $zsk > settime.out.test$n.zsk || ret=1
-$SETTIME -K ns3 -P now+3s -A none $ksk > settime.out.test$n.ksk || ret=1
-($RNDCCMD 10.53.0.3 loadkeys delay.example. 2>&1 | sed 's/^/ns2 /' | cat_i) || ret=1
-echo_i "waiting for changes to take effect"
-sleep 3
-wait_for_notifies "delay.example" "ns3" || ret=1
-
-$DIG $DIGOPTS +noall +answer dnskey delay.example. @10.53.0.3 > dig.out.ns3.test$n || ret=1
-# DNSKEY expected:
-awk 'BEGIN {r=1} $4=="DNSKEY" {r=0} END {exit r}' dig.out.ns3.test$n || ret=1
-# RRSIG not expected:
-awk 'BEGIN {r=1} $4=="RRSIG" {r=0} END {exit r}' dig.out.ns3.test$n && ret=1
+$SETTIME -K ns3 -P now -A none $zsk > settime.out.test$n.zsk || ret=1
+$SETTIME -K ns3 -P now -A none $ksk > settime.out.test$n.ksk || ret=1
+cp ns3/delay.example.db ns3/delay.example.1
+# This will create a non valid DNSSEC zone, disable post-sign verification
+$SIGNER -P -S -o delay.example. -O full -N increment -K ns3 -f ns3/delay.example.db ns3/delay.example.1 > signing.delay.out.$n 2>&1 || ret=1
+($RNDCCMD 10.53.0.3 reload delay.example | sed 's/^/ns3 /' | cat_i) || ret=1
+check_has_dnskey() {
+  $DIG $DIGOPTS +noall +answer dnskey delay.example. @10.53.0.3 > dig.out.ns3.test$n || return 1
+  # DNSKEY expected:
+  awk 'BEGIN {r=1} $4=="DNSKEY" {r=0} END {exit r}' dig.out.ns3.test$n || return 1
+  # RRSIG not expected:
+  awk 'BEGIN {r=1} $4=="RRSIG" {r=0} END {exit r}' dig.out.ns3.test$n && return 1
+  return 0
+}
+retry_quiet 5 check_has_dnskey || ret=1
 n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
 echo_i "checking scheduled key activation ($n)"
 ret=0
-$SETTIME -K ns3 -A now+3s $zsk > settime.out.test$n.zsk || ret=1
-$SETTIME -K ns3 -A now+3s $ksk > settime.out.test$n.ksk || ret=1
-($RNDCCMD 10.53.0.3 loadkeys delay.example. 2>&1 | sed 's/^/ns2 /' | cat_i) || ret=1
-echo_i "waiting for changes to take effect"
-sleep 3
-wait_for_log_re 10 "add delay\.example\..*NSEC.a\.delay\.example\. NS SOA RRSIG NSEC DNSKEY" ns3/named.run
+$SETTIME -K ns3 -A now $zsk > settime.out.test$n.zsk || ret=1
+$SETTIME -K ns3 -A now $ksk > settime.out.test$n.ksk || ret=1
+cp ns3/delay.example.db ns3/delay.example.2
+$SIGNER -S -o delay.example. -O full -N increment -K ns3 -f ns3/delay.example.db ns3/delay.example.2 > signing.delay.out.$n 2>&1 || ret=1
+($RNDCCMD 10.53.0.3 reload delay.example | sed 's/^/ns3 /' | cat_i) || ret=1
 check_is_signed() {
   $DIG $DIGOPTS +noall +answer dnskey delay.example. @10.53.0.3 > dig.out.ns3.1.test$n || return 1
   # DNSKEY expected:
@@ -1126,19 +1030,24 @@ now=$($PERL -e 'print time(), "\n";')
 sleep=$((starttime + 29 - now))
 case $sleep in
 -*|0);;
-*) echo_i "waiting for timer to have activated"; sleep $sleep;;
+*) echo_i "waiting $sleep seconds for timer to have activated"; sleep $sleep;;
 esac
 ret=0
+($RNDCCMD 10.53.0.1 freeze . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
+cp ns1/root.db.signed ns1/root.db.3
+$SIGNER -v 3 -S -o . -O full -K ns1 -f ns1/root.db.signed ns1/root.db.3 > signing.root.out$n 2>&1 || ret=1
+($RNDCCMD 10.53.0.1 thaw . 2>&1 | sed 's/^/ns1 /' | cat_i) || ret=1
 $DIG $DIGOPTS +multi dnskey . @10.53.0.1 > dig.out.ns1.test$n || ret=1
 grep '; key id = '"$oldid"'$' dig.out.ns1.test$n > /dev/null && ret=1
 n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "checking private key file removal caused no immediate harm ($n)"
+id=$(keyfile_to_key_id "$(cat vanishing.key)")
+echo_i "checking private key file $id removal caused no immediate harm ($n)"
 ret=0
 id=$(keyfile_to_key_id "$(cat vanishing.key)")
-$DIG $DIGOPTS dnskey . @10.53.0.1 > dig.out.ns1.test$n || ret=1
+$DIG $DIGOPTS soa . @10.53.0.1 > dig.out.ns1.test$n || ret=1
 grep 'RRSIG.*'" $id "'\. ' dig.out.ns1.test$n > /dev/null || ret=1
 n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -1168,52 +1077,6 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-# this confirms that key events are never scheduled more than
-# 'dnssec-loadkeys-interval' minutes in the future, and that the
-# event scheduled is within 10 seconds of expected interval.
-check_interval () {
-        awk '/next key event/ {print $2 ":" $9}' $1/named.run |
-       sed -e 's/\.//g' -e 's/:0\{1,4\}/:/g' |
-            awk -F: '
-                     {
-                       x = ($6+ $5*60000 + $4*3600000) - ($3+ $2*60000 + $1*3600000);
-                      # abs(x) < 1000 ms treat as 'now'
-                      if (x < 1000 && x > -1000)
-                         x = 0;
-                      # convert to seconds
-                      x = x/1000;
-                      # handle end of day roll over
-                      if (x < 0)
-                        x = x + 24*3600;
-                      # handle log timestamp being a few milliseconds later
-                       if (x != int(x))
-                         x = int(x + 1);
-                       if (int(x) > int(interval))
-                         exit (1);
-                     }
-                     END { if (int(x) > int(interval) || int(x) < int(interval-10)) exit(1) }' interval=$2 || return $?
-        return 0
-}
-
-echo_i "checking automatic key reloading interval ($n)"
-ret=0
-check_interval ns1 3600 || ret=1
-check_interval ns2 1800 || ret=1
-check_interval ns3 600 || ret=1
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-echo_i "checking for key reloading loops ($n)"
-ret=0
-# every key event should schedule a successor, so these should be equal
-rekey_calls=$(grep "reconfiguring zone keys" ns*/named.run | wc -l)
-rekey_events=$(grep "next key event" ns*/named.run | wc -l)
-[ "$rekey_calls" = "$rekey_events" ] || ret=1
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
 echo_i "forcing full sign with unreadable keys ($n)"
 ret=0
 chmod 0 ns1/K.+*+*.key ns1/K.+*+*.private || ret=1
@@ -1224,14 +1087,14 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "test turning on auto-dnssec during reconfig ($n)"
+echo_i "test turning on dnssec-policy during reconfig ($n)"
 ret=0
-# first create a zone that doesn't have auto-dnssec
+# first create a zone that doesn't have dnssec-policy
 ($RNDCCMD 10.53.0.3 addzone reconf.example '{ type primary; file "reconf.example.db"; };' 2>&1 | sed 's/^/ns3 /' | cat_i) || ret=1
 rekey_calls=$(grep "zone reconf.example.*next key event" ns3/named.run | wc -l)
 [ "$rekey_calls" -eq 0 ] || ret=1
-# ...then we add auto-dnssec and reconfigure
-($RNDCCMD 10.53.0.3 modzone reconf.example '{ type primary; file "reconf.example.db"; allow-update { any; }; auto-dnssec maintain; };' 2>&1 | sed 's/^/ns3 /' | cat_i) || ret=1
+# ...then we add dnssec-policy and reconfigure
+($RNDCCMD 10.53.0.3 modzone reconf.example '{ type primary; file "reconf.example.db"; allow-update { any; }; dnssec-policy default; };' 2>&1 | sed 's/^/ns3 /' | cat_i) || ret=1
 rndc_reconfig ns3 10.53.0.3
 for i in 0 1 2 3 4 5 6 7 8 9; do
     lret=0
@@ -1256,7 +1119,7 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "test 'dnssec-dnskey-kskonly no' affects DNSKEY/CDS/CDNSKEY ($n)"
+echo_i "test 'csk' affects DNSKEY/CDS/CDNSKEY ($n)"
 ret=0
 $DIG $DIGOPTS @10.53.0.3 sync.example dnskey > dig.out.ns3.dnskeytest$n
 $DIG $DIGOPTS @10.53.0.3 sync.example cdnskey > dig.out.ns3.cdnskeytest$n
@@ -1271,7 +1134,7 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "test 'dnssec-dnskey-kskonly yes' affects DNSKEY/CDS/CDNSKEY ($n)"
+echo_i "test 'ksk' affects DNSKEY/CDS/CDNSKEY ($n)"
 ret=0
 $DIG $DIGOPTS @10.53.0.3 kskonly.example dnskey > dig.out.ns3.dnskeytest$n
 $DIG $DIGOPTS @10.53.0.3 kskonly.example cdnskey > dig.out.ns3.cdnskeytest$n
@@ -1286,22 +1149,24 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "setting CDS and CDNSKEY deletion times and calling 'rndc loadkeys'"
-$SETTIME -D sync now $(cat sync.key) > settime.out.test$n || ret=1
-($RNDCCMD 10.53.0.3 loadkeys sync.example | sed 's/^/ns3 /' | cat_i) || ret=1
-
-echo_i "checking that the CDS and CDNSKEY are deleted ($n)"
-ret=0
-ensure_cds_and_cdnskey_are_deleted() {
-       $DIG $DIGOPTS @10.53.0.3 sync.example. CDS > dig.out.ns3.cdstest$n || return 1
-       awk '$1 == "sync.example." && $4 == "CDS" { exit 1; }' dig.out.ns3.cdstest$n || return 1
-       $DIG $DIGOPTS @10.53.0.3 sync.example. CDNSKEY > dig.out.ns3.cdnskeytest$n || return 1
-       awk '$1 == "sync.example." && $4 == "CDNSKEY" { exit 1; }' dig.out.ns3.cdnskeytest$n || return 1
-}
-retry 10 ensure_cds_and_cdnskey_are_deleted || ret=1
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
+# XXXWMM Replace this test with dnssec-policy equivalent once we have
+# implemented 'cdnskey "only-during-rollovers";'.
+#echo_i "setting CDS and CDNSKEY deletion times and calling 'rndc loadkeys'"
+#$SETTIME -D sync now $(cat sync.key) > settime.out.test$n || ret=1
+#($RNDCCMD 10.53.0.3 loadkeys sync.example | sed 's/^/ns3 /' | cat_i) || ret=1
+#
+#echo_i "checking that the CDS and CDNSKEY are deleted ($n)"
+#ret=0
+#ensure_cds_and_cdnskey_are_deleted() {
+#      $DIG $DIGOPTS @10.53.0.3 sync.example. CDS > dig.out.ns3.cdstest$n || return 1
+#      awk '$1 == "sync.example." && $4 == "CDS" { exit 1; }' dig.out.ns3.cdstest$n || return 1
+#      $DIG $DIGOPTS @10.53.0.3 sync.example. CDNSKEY > dig.out.ns3.cdnskeytest$n || return 1
+#      awk '$1 == "sync.example." && $4 == "CDNSKEY" { exit 1; }' dig.out.ns3.cdnskeytest$n || return 1
+#}
+#retry 10 ensure_cds_and_cdnskey_are_deleted || ret=1
+#n=$((n + 1))
+#if [ $ret != 0 ]; then echo_i "failed"; fi
+#status=$((status + ret))
 
 echo_i "check that dnssec-settime -p Dsync works ($n)"
 ret=0
@@ -1319,24 +1184,6 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "check that zone with inactive KSK and active ZSK is properly autosigned ($n)"
-ret=0
-$DIG $DIGOPTS @10.53.0.3 axfr inacksk2.example > dig.out.ns3.test$n
-
-zskid=$(awk '$4 == "DNSKEY" && $5 == 256 { print }' dig.out.ns3.test$n |
-       $DSFROMKEY -A -2 -f - inacksk2.example | awk '{ print $4}' )
-pattern="DNSKEY ${DEFAULT_ALGORITHM_NUMBER} 2 [0-9]* [0-9]* [0-9]* ${zskid} "
-grep "${pattern}" dig.out.ns3.test$n > /dev/null || ret=1
-
-kskid=$(awk '$4 == "DNSKEY" && $5 == 257 { print }' dig.out.ns3.test$n |
-       $DSFROMKEY -2 -f - inacksk2.example | awk '{ print $4}' )
-pattern="DNSKEY ${DEFAULT_ALGORITHM_NUMBER} 2 [0-9]* [0-9]* [0-9]* ${kskid} "
-grep "${pattern}" dig.out.ns3.test$n > /dev/null && ret=1
-
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
 echo_i "check that zone with inactive ZSK and active KSK is properly autosigned ($n)"
 ret=0
 $DIG $DIGOPTS @10.53.0.3 axfr inaczsk2.example > dig.out.ns3.test$n
@@ -1345,101 +1192,27 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-#
-# Check that DNSKEY is now signed with the ZSK.
-#
-echo_i "check that zone with active and inactive KSK and active ZSK is properly"
-echo_ic "resigned after the active KSK is deleted - stage 2: Verify that DNSKEY"
-echo_ic "is now signed with the ZSK. ($n)"
-ret=0
-
-$DIG $DIGOPTS @10.53.0.3 axfr inacksk3.example > dig.out.ns3.test$n
-
-zskid=$(awk '$4 == "DNSKEY" && $5 == 256 { print }' dig.out.ns3.test$n |
-       $DSFROMKEY -A -2 -f - inacksk3.example | awk '{ print $4}' )
-pattern="DNSKEY ${DEFAULT_ALGORITHM_NUMBER} 2 [0-9]* [0-9]* [0-9]* ${zskid} "
-grep "${pattern}" dig.out.ns3.test$n > /dev/null || ret=1
-
-count=$(awk 'BEGIN { count = 0 }
-       $4 == "RRSIG" && $5 == "DNSKEY" { count++ }
-       END {print count}' dig.out.ns3.test$n)
-test $count -eq 1 || ret=1
-
-count=$(awk 'BEGIN { count = 0 }
-       $4 == "DNSKEY" { count++ }
-       END {print count}' dig.out.ns3.test$n)
-test $count -eq 2 || ret=1
-
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-#
-# Check that zone is now signed with the KSK.
-#
-echo_i "check that zone with active and inactive ZSK and active KSK is properly"
-echo_ic "resigned after the active ZSK is deleted - stage 2: Verify that zone"
-echo_ic "is now signed with the KSK. ($n)"
-ret=0
-$DIG $DIGOPTS @10.53.0.3 axfr inaczsk3.example > dig.out.ns3.test$n
-kskid=$(awk '$4 == "DNSKEY" && $5 == 257 { print }' dig.out.ns3.test$n |
-       $DSFROMKEY -2 -f - inaczsk3.example | awk '{ print $4}' )
-grep "CNAME ${DEFAULT_ALGORITHM_NUMBER} 3 [0-9]* [0-9]* [0-9]* ${kskid} " dig.out.ns3.test$n > /dev/null || ret=1
-count=$(awk 'BEGIN { count = 0 }
-       $4 == "RRSIG" && $5 == "CNAME" { count++ }
-       END {print count}' dig.out.ns3.test$n)
-test $count -eq 1 || ret=1
-count=$(awk 'BEGIN { count = 0 }
-       $4 == "DNSKEY" { count++ }
-       END {print count}' dig.out.ns3.test$n)
-test $count -eq 2 || ret=1
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
 echo_i "checking for out-of-zone NSEC3 records after ZSK removal ($n)"
 ret=0
-# Switch the zone over to NSEC3 and wait until the transition is complete.
-$RNDCCMD 10.53.0.3 signing -nsec3param 1 1 10 12345678 delzsk.example. > signing.out.1.test$n 2>&1 || ret=1
-for i in 0 1 2 3 4 5 6 7 8 9; do
-       _ret=1
-       $DIG $DIGOPTS delzsk.example NSEC3PARAM @10.53.0.3 > dig.out.ns3.1.test$n 2>&1 || ret=1
-       { grep "NSEC3PARAM.*12345678" dig.out.ns3.1.test$n > /dev/null 2>&1; rc=$?; } || true
-       if [ $rc -eq 0 ]; then
-               $RNDCCMD 10.53.0.3 signing -list delzsk.example > signing.out.2.test$n 2>&1
-               { grep "Creating NSEC3 chain " signing.out.2.test$n > /dev/null 2>&1; rc=$?; } || true
-               if [ $rc -ne 0 ]; then
-                       _ret=0
-                       break
-               fi
-       fi
-       sleep 1
-done
-if [ $_ret -ne 0 ]; then
-       echo_i "timed out waiting for NSEC3 chain creation"
-       ret=1
-fi
-# Mark the inactive ZSK as pending removal.
-file="ns3/$(cat delzsk.key).key"
-$SETTIME -D now-1h $file > settime.out.test$n || ret=1
-# Trigger removal of the inactive ZSK and wait until its completion.
-($RNDCCMD 10.53.0.3 loadkeys delzsk.example 2>&1 | sed 's/^/ns3 /' | cat_i) || ret=1
-for i in 0 1 2 3 4 5 6 7 8 9; do
-       _ret=1
-       $RNDCCMD 10.53.0.3 signing -list delzsk.example > signing.out.3.test$n 2>&1
-       { grep "Signing " signing.out.3.test$n > /dev/null 2>&1; rc=$?; } || true
-       if [ $rc -ne 0 ]; then
-               if [ $(grep "Done signing " signing.out.3.test$n | wc -l) -eq 2 ]; then
-                       _ret=0
-                       break
-               fi
-       fi
-       sleep 1
-done
-if [ $_ret -ne 0 ]; then
+# Delete the ZSK
+file="ns3/inactive/$(cat delzsk.key).key"
+$NSUPDATE > nsupdate.out.test$n 2>&1 <<END
+server 10.53.0.3 ${PORT}
+zone delzsk.example.
+update del $(cat $file | grep -v ";.*")
+send
+END
+
+zsk_is_gone() {
+  $DIG $DIGOPTS +noall +multi +answer dnskey delzsk.example. @10.53.0.3 > dig.out.ns3.test$n || return 1
+  grep '; key id = '"$oldid"'$' dig.out.ns3.test$n > /dev/null && return 1
+  return 0
+}
+retry_quiet 5 zsk_is_gone || ret=1
+if [ $ret -ne 0 ]; then
        echo_i "timed out waiting for key removal"
-       ret=1
 fi
+
 # Check whether key removal caused NSEC3 records to be erroneously created for
 # glue records due to a secure delegation already being signed by the active key
 # (i.e. a key other than the one being removed but using the same algorithm).
@@ -1455,7 +1228,7 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
-echo_i "check that DNAME at apex with NSEC3 is correctly signed (auto-dnssec maintain) ($n)"
+echo_i "check that DNAME at apex with NSEC3 is correctly signed (dnssec-policy) ($n)"
 ret=0
 $DIG $DIGOPTS txt dname-at-apex-nsec3.example @10.53.0.3 > dig.out.ns3.test$n || ret=1
 grep "RRSIG NSEC3 ${DEFAULT_ALGORITHM_NUMBER} 3 600" dig.out.ns3.test$n > /dev/null || ret=1
@@ -1475,111 +1248,47 @@ status=$((status + ret))
 
 echo_i "checking key maintenance events were logged correctly ($n)"
 ret=0
-pub=$(grep "DNSKEY .* is now published" ns1/named.run | wc -l)
-[ "$pub" -eq 6 ] || ret=1
-act=$(grep "DNSKEY .* is now active" ns1/named.run | wc -l)
-[ "$act" -eq 5 ] || ret=1
-rev=$(grep "DNSKEY .* is now revoked" ns1/named.run | wc -l)
-[ "$rev" -eq 1 ] || ret=1
-inac=$(grep "DNSKEY .* is now inactive" ns1/named.run | wc -l)
-[ "$inac" -eq 1 ] || ret=1
-del=$(grep "DNSKEY .* is now deleted" ns1/named.run | wc -l)
-[ "$del" -eq 1 ] || ret=1
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-echo_i "checking that CDS (DELETE) persists after zone sign ($n)"
-echo_i "update add cds-delete.example. CDS 0 0 00"
-ret=0
-$NSUPDATE > nsupdate.out 2>&1 <<END
-server 10.53.0.3 ${PORT}
-zone cds-delete.example.
-update add cds-delete.example. 3600 CDS 0 0 0 00
-send
-END
-
-_cds_delete() (
-       $DIG $DIGOPTS +noall +answer $1 cds @10.53.0.3 > dig.out.ns3.test$n || return 1
-       grep "CDS.*0.*0.*0.*00" dig.out.ns3.test$n > /dev/null 2>&1 || return 1
-       return 0
-)
-_cdnskey_delete_nx() {
-       $DIG $DIGOPTS +noall +answer $1 cdnskey @10.53.0.3 > dig.out.ns3.test$n || return 1
-       grep "CDNSKEY.*0.*3.*0.*AA==" dig.out.ns3.test$n > /dev/null 2>&1 && return 1
-       return 0
-}
-
-echo_i "query cds-delete.example. CDS"
-retry_quiet 10 _cds_delete cds-delete.example. || ret=1
-echo_i "query cds-delete.example. CDNSKEY"
-retry_quiet 1 _cdnskey_delete_nx cds-delete.example. || ret=1
-
-echo_i "sign cds-delete.example."
-nextpart ns3/named.run >/dev/null
-$RNDCCMD 10.53.0.3 sign cds-delete.example > /dev/null 2>&1 || ret=1
-wait_for_log 10 "zone cds-delete.example/IN: next key event" ns3/named.run
-# The CDS (DELETE) record should still be here.
-echo_i "query cds-delete.example. CDS"
-retry_quiet 1 _cds_delete cds-delete.example. || ret=1
-# The CDNSKEY (DELETE) record should still not be added.
-echo_i "query cds-delete.example. CDNSKEY"
-retry_quiet 1 _cdnskey_delete_nx cds-delete.example. || ret=1
-
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-echo_i "checking that CDNSKEY (DELETE) persists after zone sign ($n)"
-echo_i "update add cdnskey-delete.example. CDNSKEY 0 3 0 AA=="
-ret=0
-$NSUPDATE > nsupdate.out 2>&1 <<END
-server 10.53.0.3 ${PORT}
-zone cdnskey-delete.example.
-update add cdnskey-delete.example. 3600 CDNSKEY 0 3 0 AA==
-send
-END
-
-_cds_delete_nx() (
-       $DIG $DIGOPTS +noall +answer $1 cds @10.53.0.3 > dig.out.ns3.test$n || return 1
-       grep "CDS.*0.*0.*0.*00" dig.out.ns3.test$n > /dev/null 2>&1 && return 1
-       return 0
-)
-_cdnskey_delete() {
-       $DIG $DIGOPTS +noall +answer $1 cdnskey @10.53.0.3 > dig.out.ns3.test$n || return 1
-       grep "CDNSKEY.*0.*3.*0.*AA==" dig.out.ns3.test$n > /dev/null 2>&1 || return 1
-       return 0
-}
-
-echo_i "query cdnskey-delete.example. CDNSKEY"
-retry_quiet 10 _cdnskey_delete cdnskey-delete.example. || ret=1
-echo_i "query cdnskey-delete.example. CDS"
-retry_quiet 1 _cds_delete_nx cdnskey-delete.example. || ret=1
-
-echo_i "sign cdsnskey-delete.example."
-nextpart ns3/named.run >/dev/null
-$RNDCCMD 10.53.0.3 sign cdnskey-delete.example > /dev/null 2>&1 || ret=1
-wait_for_log 10 "zone cdnskey-delete.example/IN: next key event" ns3/named.run
-# The CDNSKEY (DELETE) record should still be here.
-echo_i "query cdnskey-delete.example. CDNSKEY"
-retry_quiet 1 _cdnskey_delete cdnskey-delete.example. || ret=1
-# The CDS (DELETE) record should still not be added.
-echo_i "query cdnskey-delete.example. CDS"
-retry_quiet 1 _cds_delete_nx cdnskey-delete.example. || ret=1
-
-n=$((n + 1))
-if [ $ret != 0 ]; then echo_i "failed"; fi
-status=$((status + ret))
-
-echo_i "check removal of ENT NSEC3 records when opt out delegations are removed ($n)"
-ret=0
+pub=$(grep "DNSKEY .* is now published" ns2/named.run | wc -l)
+[ "$pub" -eq 10 ] || ret=1
+act=$(grep "DNSKEY .* is now active" ns2/named.run | wc -l)
+[ "$act" -eq 10 ] || ret=1
+rev=$(grep "DNSKEY .* is now revoked" ns2/named.run | wc -l)
+[ "$rev" -eq 0 ] || ret=1
+inac=$(grep "DNSKEY .* is now inactive" ns2/named.run | wc -l)
+[ "$inac" -eq 0 ] || ret=1
+del=$(grep "DNSKEY .* is now deleted" ns2/named.run | wc -l)
+[ "$del" -eq 0 ] || ret=1
+pub=$(grep "DNSKEY .* is now published" ns3/named.run | wc -l)
+[ "$pub" -eq 55 ] || ret=1
+act=$(grep "DNSKEY .* is now active" ns3/named.run | wc -l)
+[ "$act" -eq 53 ] || ret=1
+rev=$(grep "DNSKEY .* is now revoked" ns3/named.run | wc -l)
+[ "$rev" -eq 0 ] || ret=1
+inac=$(grep "DNSKEY .* is now inactive" ns3/named.run | wc -l)
+[ "$inac" -eq 0 ] || ret=1
+del=$(grep "DNSKEY .* is now deleted" ns3/named.run | wc -l)
+[ "$del" -eq 3 ] || ret=1
+n=$((n + 1))
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status + ret))
+
+echo_i "check removal of ENT NSEC3 records when opt out delegations are removed"
 zone=optout-with-ent
 hash=JTR8R6AVFULU0DQH9I6HNN2KUK5956EL
+
 # check that NSEC3 for ENT is present
+echo_i "check ENT NSEC3 is initially present"
+ret=0
 $DIG $DIGOPTS @10.53.0.2 a "ent.${zone}" > dig.out.pre.ns2.test$n
 grep "status: NOERROR" dig.out.pre.ns2.test$n >/dev/null || ret=1
 grep "ANSWER: 0, AUTHORITY: 4, " dig.out.pre.ns2.test$n > /dev/null || ret=1
 grep "^${hash}.${zone}." dig.out.pre.ns2.test$n > /dev/null || ret=1
+n=$((n+1))
+if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
+
+echo_i "check ENT NSEC3 is still present after removing one of two delegations ($n)"
+ret=0
 # remove first delegation of two delegations, NSEC3 for ENT should remain.
 (
 echo zone $zone
@@ -1593,6 +1302,12 @@ $DIG $DIGOPTS @10.53.0.2 a "ent.${zone}" > dig.out.mid.ns2.test$n
 grep "status: NOERROR" dig.out.mid.ns2.test$n >/dev/null || ret=1
 grep "ANSWER: 0, AUTHORITY: 4, " dig.out.mid.ns2.test$n > /dev/null || ret=1
 grep "^${hash}.${zone}." dig.out.mid.ns2.test$n > /dev/null || ret=1
+n=$((n+1))
+if [ "$ret" -ne 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
+
+echo_i "check ENT NSEC3 is gone after removing the second delegation ($n)"
+ret=0
 # remove second delegation of two delegations, NSEC3 for ENT should be deleted.
 (
 echo zone $zone
@@ -1600,7 +1315,8 @@ echo server 10.53.0.2 "$PORT"
 echo update del sub2.ent.$zone NS
 echo send
 ) | $NSUPDATE
-# check that NSEC3 for ENT is gone present
+# check that NSEC3 for ENT is gone
+echo_i "check ENT NSEC3 is gone for zone $zone hash $hash"
 $DIG $DIGOPTS @10.53.0.2 a "ent.${zone}" > dig.out.post.ns2.test$n
 grep "status: NXDOMAIN" dig.out.post.ns2.test$n >/dev/null || ret=1
 grep "ANSWER: 0, AUTHORITY: 4, " dig.out.post.ns2.test$n > /dev/null || ret=1