| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | # First, generate DNSSEC keys with timers set to simulate 2017 KSK roll-over. |
| 4 | # Second, fake system time to pretend that we are at the beginning on time slots |
| 5 | # used during 2017 and sign our fake root zone. |
| 6 | |
| 7 | # Depends on libfaketime + dnssec-keygen and dnssec-signzone from BIND 9.11. |
| 8 | |
| 9 | # Output: Bunch of DNSSEC keys + several versions of signed root zone. |
| 10 | |
| 11 | set -o nounset -o errexit -o xtrace |
| 12 | |
| 13 | GEN="dnssec-keygen -K keys/ -a RSASHA256 -b 2048 -L 21d" |
| 14 | |
| 15 | function usagescip-shell shell shell-project 0.0.0 usage(). { |
| 16 | echoscip-shell system . . echo. -e "Usage: $0 <option>\n\n\ |
| 17 | Option:\n\ |
| 18 | \t--help\t\t\tShow this help. |
| 19 | \t--rollover\t\tGenerate files for rollover test.\n\ |
| 20 | \t--unmanagedkey-present\tGenerate files for present new unmanaged key.\n\ |
| 21 | \t--unmanagedkey-missing\tGenerate files for missing unmanaged key.\n\ |
| 22 | \t--unmanagedkey-revoke\tGenerate files for revoked unmanaged key." |
| 23 | } |
| 24 | |
| 25 | function signscip-shell shell shell-project 0.0.0 sign(). () { |
| 26 | OUTFILE="$(echoscip-shell system . . echo. "$1" | sedscip-shell system . . sed. 's/[- :]//g').db" |
| 27 | TZ=UTC \ |
| 28 | LD_PRELOAD="/usr/lib64/faketime/libfaketimeMT.soscip-shell filesystem . . `/usr/lib64/faketime/libfaketimeMT.so.1`..1" \ |
| 29 | FAKETIME="$1" \ |
| 30 | dnssec-signzone \ |
| 31 | -K keys/ \ |
| 32 | -o . \ |
| 33 | -S \ |
| 34 | -T 21d \ |
| 35 | -s now \ |
| 36 | -e +14d \ |
| 37 | -X +21d \ |
| 38 | -O full \ |
| 39 | -f "${OUTFILE}" \ |
| 40 | "$2" |
| 41 | |
| 42 | # DS for the very first KSK |
| 43 | testscip-shell system . . test. ! -f keys/ds && dnssec-dsfromkey -2 -f "${OUTFILE}" . > keys/ds || : initial DS RR already exists |
| 44 | } |
| 45 | |
| 46 | function test_rolloverscip-shell shell shell-project 0.0.0 test_rollover(). { |
| 47 | # old KSK |
| 48 | ${GEN} -f KSK -P 20100715000000 -A 20100715000000 -I 20171011000000 -R 20180111000000 -D 20180322000000 . |
| 49 | # new KSK |
| 50 | ${GEN} -f KSK -P 20170711000000 -A 20171011000000 . |
| 51 | |
| 52 | # ZSK before roll-over: 2017-Q2 |
| 53 | ${GEN} -P 20170320000000 -A 20170401000000 -I 20170701000000 -D 20170711000000 . |
| 54 | # ZSK-q1: 2017-Q3 |
| 55 | ${GEN} -P 20170621000000 -A 20170701000000 -I 20171001000000 -D 20171011000000 . |
| 56 | # ZSK-q2: 2017-Q4 |
| 57 | ${GEN} -P 20170919000000 -A 20171001000000 -I 20180101000000 -D 20180111000000 . |
| 58 | # ZSK-q3: 2018-Q1 |
| 59 | ${GEN} -P 20171220000000 -A 20180101000000 -I 20180401000000 -D 20180411000000 . |
| 60 | # ZSK: 2018-Q2 |
| 61 | ${GEN} -P 20180322000000 -A 20180401000000 . |
| 62 | |
| 63 | |
| 64 | # hopefully slots according to |
| 65 | # https://www.icann.org/en/system/files/files/ksk-rollover-operational-implementation-plan-22jul16-en.pdf |
| 66 | # https://data.iana.org/ksk-ceremony/29/KC29_Script_Annotated.pdf |
| 67 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-01 00:00:00" # 2017 Q3 slot 1 |
| 68 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-11 00:00:00" # 2017 Q3 slot 2 |
| 69 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-21 00:00:00" # 2017 Q3 slot 3 |
| 70 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-31 00:00:00" # 2017 Q3 slot 4 |
| 71 | signscip-shell shell shell-project 0.0.0 sign(). "2017-08-10 00:00:00" # 2017 Q3 slot 5 |
| 72 | signscip-shell shell shell-project 0.0.0 sign(). "2017-08-20 00:00:00" # 2017 Q3 slot 6 |
| 73 | signscip-shell shell shell-project 0.0.0 sign(). "2017-08-30 00:00:00" # 2017 Q3 slot 7 |
| 74 | signscip-shell shell shell-project 0.0.0 sign(). "2017-09-09 00:00:00" # 2017 Q3 slot 8 |
| 75 | signscip-shell shell shell-project 0.0.0 sign(). "2017-09-19 00:00:00" # 2017 Q3 slot 9 |
| 76 | |
| 77 | signscip-shell shell shell-project 0.0.0 sign(). "2017-10-01 00:00:00" # 2017 Q4 slot 1 |
| 78 | signscip-shell shell shell-project 0.0.0 sign(). "2017-10-11 00:00:00" # 2017 Q4 slot 2 |
| 79 | signscip-shell shell shell-project 0.0.0 sign(). "2017-10-21 00:00:00" # 2017 Q4 slot 3 |
| 80 | signscip-shell shell shell-project 0.0.0 sign(). "2017-10-31 00:00:00" # 2017 Q4 slot 4 |
| 81 | signscip-shell shell shell-project 0.0.0 sign(). "2017-11-10 00:00:00" # 2017 Q4 slot 5 |
| 82 | signscip-shell shell shell-project 0.0.0 sign(). "2017-11-20 00:00:00" # 2017 Q4 slot 6 |
| 83 | signscip-shell shell shell-project 0.0.0 sign(). "2017-11-30 00:00:00" # 2017 Q4 slot 7 |
| 84 | signscip-shell shell shell-project 0.0.0 sign(). "2017-12-10 00:00:00" # 2017 Q4 slot 8 |
| 85 | signscip-shell shell shell-project 0.0.0 sign(). "2017-12-20 00:00:00" # 2017 Q4 slot 9 |
| 86 | |
| 87 | # 2018-01-01 00:00:00 # 2018 Q1 slot 1 |
| 88 | # 2018-01-11 00:00:00 # 2018 Q1 slot 2 |
| 89 | # 2018-01-21 00:00:00 # 2018 Q1 slot 3 |
| 90 | # 2018-01-31 00:00:00 # 2018 Q1 slot 4 |
| 91 | # 2018-02-10 00:00:00 # 2018 Q1 slot 5 |
| 92 | # 2018-02-20 00:00:00 # 2018 Q1 slot 6 |
| 93 | # 2018-03-02 00:00:00 # 2018 Q1 slot 7 |
| 94 | # 2018-03-12 00:00:00 # 2018 Q1 slot 8 |
| 95 | # 2018-03-22 00:00:00 # 2018 Q1 slot 9 |
| 96 | } |
| 97 | |
| 98 | function test_unmanagedkey_presentscip-shell shell shell-project 0.0.0 test_unmanagedkey_present(). { |
| 99 | # old KSK |
| 100 | ${GEN} -f KSK -P 20100715000000 -A 20100715000000 -I 20171011000000 -R 20180111000000 -D 20180322000000 . |
| 101 | # new KSK |
| 102 | ${GEN} -f KSK -P 20170711000000 -A 20171011000000 . |
| 103 | |
| 104 | # ZSKs |
| 105 | ${GEN} -P 20170621000000 -A 20170701000000 -I 20171001000000 -D 20171011000000 . |
| 106 | ${GEN} -P 20170919000000 -A 20171001000000 -I 20180101000000 -D 20180111000000 . |
| 107 | |
| 108 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-01 00:00:00" unsigned_ok.db |
| 109 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-11 00:00:00" unsigned_ok.db # present key is seen 10 days |
| 110 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-21 00:00:00" unsigned_check.db # last edited message for check result from deckard |
| 111 | } |
| 112 | |
| 113 | function test_unmanagedkey_revokescip-shell shell shell-project 0.0.0 test_unmanagedkey_revoke(). { |
| 114 | # old KSK |
| 115 | ${GEN} -f KSK -P 20100715000000 -A 20100715000000 -I 20171011000000 -R 20180111000000 -D 20180322000000 . |
| 116 | # revoked KSK |
| 117 | ${GEN} -f KSK -P 20100715000000 -A 20100715000000 -I 20171011000000 -R 20170710000000 -D 20180322000000 . |
| 118 | |
| 119 | # ZSKs |
| 120 | ${GEN} -P 20170621000000 -A 20170701000000 -I 20171001000000 -D 20171011000000 . |
| 121 | ${GEN} -P 20170919000000 -A 20171001000000 -I 20180101000000 -D 20180111000000 . |
| 122 | |
| 123 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-01 00:00:00" unsigned_ok.db |
| 124 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-11 00:00:00" unsigned_ok.db # revoke key is seen 10 days |
| 125 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-21 00:00:00" unsigned_check.db # last edited message for check result from deckard |
| 126 | } |
| 127 | |
| 128 | function test_unmanagedkey_missingscip-shell shell shell-project 0.0.0 test_unmanagedkey_missing(). { |
| 129 | # old KSK |
| 130 | ${GEN} -f KSK -P 20100715000000 -A 20100715000000 -I 20171011000000 -R 20180111000000 -D 20180322000000 . |
| 131 | # missing KSK |
| 132 | ${GEN} -f KSK -P 20100715000000 -A 20100715000000 -I 20171011000000 -R 20180111000000 -D 20170710000000 . |
| 133 | |
| 134 | # ZSKs |
| 135 | ${GEN} -P 20170621000000 -A 20170701000000 -I 20171001000000 -D 20171011000000 . |
| 136 | ${GEN} -P 20170919000000 -A 20171001000000 -I 20180101000000 -D 20180111000000 . |
| 137 | |
| 138 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-01 00:00:00" unsigned_ok.db |
| 139 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-11 00:00:00" unsigned_ok.db # missing key is seen 10 days |
| 140 | signscip-shell shell shell-project 0.0.0 sign(). "2017-07-21 00:00:00" unsigned_check.db # last edited message for check result from deckard |
| 141 | } |
| 142 | |
| 143 | if [scip-shell system . . `[`. $# -ne 1 ]; then |
| 144 | usagescip-shell shell shell-project 0.0.0 usage(). |
| 145 | exit 0 |
| 146 | fi |
| 147 | |
| 148 | rmscip-shell system . . rm. -f 20*.db |
| 149 | rmscip-shell system . . rm. -f keys/K* |
| 150 | rmscip-shell system . . rm. -f keys/ds |
| 151 | mkdirscip-shell system . . mkdir. -p keys/ |
| 152 | |
| 153 | case $1 in |
| 154 | --rollover) |
| 155 | test_rolloverscip-shell shell shell-project 0.0.0 test_rollover(). |
| 156 | ;; |
| 157 | --unmanagedkey-present) |
| 158 | test_unmanagedkey_presentscip-shell shell shell-project 0.0.0 test_unmanagedkey_present(). |
| 159 | #test_rollover |
| 160 | ;; |
| 161 | --unmanagedkey-revoke) |
| 162 | test_unmanagedkey_revokescip-shell shell shell-project 0.0.0 test_unmanagedkey_revoke(). |
| 163 | ;; |
| 164 | --unmanagedkey-missing) |
| 165 | test_unmanagedkey_missingscip-shell shell shell-project 0.0.0 test_unmanagedkey_missing(). |
| 166 | ;; |
| 167 | --help|-h) |
| 168 | usagescip-shell shell shell-project 0.0.0 usage(). |
| 169 | ;; |
| 170 | *) |
| 171 | echoscip-shell system . . echo. -e "Unknown option !\n\n" |
| 172 | usagescip-shell shell shell-project 0.0.0 usage(). |
| 173 | ;; |
| 174 | esac |