1 1.1 christos # Copyright (C) Internet Systems Consortium, Inc. ("ISC") 2 1.1 christos # 3 1.1 christos # SPDX-License-Identifier: MPL-2.0 4 1.1 christos # 5 1.1 christos # This Source Code Form is subject to the terms of the Mozilla Public 6 1.1 christos # License, v. 2.0. If a copy of the MPL was not distributed with this 7 1.1 christos # file, you can obtain one at https://mozilla.org/MPL/2.0/. 8 1.1 christos # 9 1.1 christos # See the COPYRIGHT file distributed with this work for additional 10 1.1 christos # information regarding copyright ownership. 11 1.1 christos 12 1.1 christos from datetime import timedelta 13 1.1 christos import os 14 1.1 christos 15 1.1 christos import pytest 16 1.1 christos 17 1.1 christos from isctest.kasp import Ipub, IpubC, Iret 18 1.1 christos from isctest.vars.algorithms import Algorithm 19 1.1 christos 20 1.1 christos pytestmark = pytest.mark.extra_artifacts( 21 1.1 christos [ 22 1.1 christos "*.axfr*", 23 1.1 christos "dig.out*", 24 1.1 christos "K*.key*", 25 1.1 christos "K*.private*", 26 1.1 christos "ns*/*.db", 27 1.1 christos "ns*/*.db.infile", 28 1.1 christos "ns*/*.db.jnl", 29 1.1 christos "ns*/*.db.jbk", 30 1.1 christos "ns*/*.db.signed", 31 1.1 christos "ns*/*.db.signed.jnl", 32 1.1 christos "ns*/*.conf", 33 1.1 christos "ns*/dsset-*", 34 1.1 christos "ns*/K*.key", 35 1.1 christos "ns*/K*.private", 36 1.1 christos "ns*/K*.state", 37 1.1 christos "ns*/keygen.out.*", 38 1.1 christos "ns*/managed-keys.**", 39 1.1 christos "ns*/settime.out.*", 40 1.1 christos "ns*/signer.out.*", 41 1.1 christos "ns*/zones", 42 1.1 christos "ns1/root.db.in", 43 1.1 christos ] 44 1.1 christos ) 45 1.1 christos 46 1.1 christos 47 1.1 christos TIMEDELTA = { 48 1.1 christos 0: timedelta(seconds=0), 49 1.1 christos "PT5M": timedelta(minutes=5), 50 1.1 christos "PT20M": timedelta(minutes=20), 51 1.1 christos "PT1H": timedelta(hours=1), 52 1.1 christos "PT2H": timedelta(hours=2), 53 1.1 christos "PT6H": timedelta(hours=6), 54 1.1 christos "PT12H": timedelta(hours=12), 55 1.1 christos "P1D": timedelta(days=1), 56 1.1 christos "P2D": timedelta(days=2), 57 1.1 christos "P5D": timedelta(days=5), 58 1.1 christos "P7D": timedelta(days=7), 59 1.1 christos "P10D": timedelta(days=10), 60 1.1 christos "P14D": timedelta(days=14), 61 1.1 christos "P30D": timedelta(days=30), 62 1.1 christos "P60D": timedelta(days=60), 63 1.1 christos "P90D": timedelta(days=90), 64 1.1 christos "P6M": timedelta(days=31 * 6), 65 1.1 christos "P1Y": timedelta(days=365), 66 1.1 christos } 67 1.1 christos DURATION = {isoname: int(delta.total_seconds()) for isoname, delta in TIMEDELTA.items()} 68 1.1 christos CDSS = ["CDNSKEY", "CDS (SHA-256)"] 69 1.1 christos DEFAULT_CONFIG = { 70 1.1 christos "dnskey-ttl": TIMEDELTA["PT1H"], 71 1.1 christos "ds-ttl": TIMEDELTA["P1D"], 72 1.1 christos "max-zone-ttl": TIMEDELTA["P1D"], 73 1.1 christos "parent-propagation-delay": TIMEDELTA["PT1H"], 74 1.1 christos "publish-safety": TIMEDELTA["PT1H"], 75 1.1 christos "purge-keys": TIMEDELTA["P90D"], 76 1.1 christos "retire-safety": TIMEDELTA["PT1H"], 77 1.1 christos "signatures-refresh": TIMEDELTA["P5D"], 78 1.1 christos "signatures-validity": TIMEDELTA["P14D"], 79 1.1 christos "zone-propagation-delay": TIMEDELTA["PT5M"], 80 1.1 christos } 81 1.1 christos UNSIGNING_CONFIG = DEFAULT_CONFIG.copy() 82 1.1 christos UNSIGNING_CONFIG["dnskey-ttl"] = TIMEDELTA["PT2H"] 83 1.1 christos ALGOROLL_CONFIG = { 84 1.1 christos "dnskey-ttl": TIMEDELTA["PT1H"], 85 1.1 christos "ds-ttl": TIMEDELTA["PT2H"], 86 1.1 christos "max-zone-ttl": TIMEDELTA["PT6H"], 87 1.1 christos "parent-propagation-delay": TIMEDELTA["PT1H"], 88 1.1 christos "publish-safety": TIMEDELTA["PT1H"], 89 1.1 christos "purge-keys": TIMEDELTA["P90D"], 90 1.1 christos "retire-safety": TIMEDELTA["PT2H"], 91 1.1 christos "signatures-refresh": TIMEDELTA["P5D"], 92 1.1 christos "signatures-validity": TIMEDELTA["P30D"], 93 1.1 christos "zone-propagation-delay": TIMEDELTA["PT1H"], 94 1.1 christos } 95 1.1 christos ALGOROLL_IPUB = Ipub(ALGOROLL_CONFIG) 96 1.1 christos ALGOROLL_IPUBC = IpubC(ALGOROLL_CONFIG, rollover=False) 97 1.1 christos ALGOROLL_IRET = Iret(ALGOROLL_CONFIG, rollover=False) 98 1.1 christos ALGOROLL_IRETKSK = Iret(ALGOROLL_CONFIG, zsk=False, ksk=True, rollover=False) 99 1.1 christos ALGOROLL_KEYTTLPROP = ( 100 1.1 christos ALGOROLL_CONFIG["dnskey-ttl"] + ALGOROLL_CONFIG["zone-propagation-delay"] 101 1.1 christos ) 102 1.1 christos ALGOROLL_OFFSETS = {} 103 1.1 christos ALGOROLL_OFFSETS["step2"] = -int(ALGOROLL_IPUB.total_seconds()) 104 1.1 christos ALGOROLL_OFFSETS["step3"] = -int(ALGOROLL_IRET.total_seconds()) 105 1.1 christos ALGOROLL_OFFSETS["step4"] = ALGOROLL_OFFSETS["step3"] - int( 106 1.1 christos ALGOROLL_IRETKSK.total_seconds() 107 1.1 christos ) 108 1.1 christos ALGOROLL_OFFSETS["step5"] = ALGOROLL_OFFSETS["step4"] - int( 109 1.1 christos ALGOROLL_KEYTTLPROP.total_seconds() 110 1.1 christos ) 111 1.1 christos ALGOROLL_OFFSETS["step6"] = ALGOROLL_OFFSETS["step5"] - int( 112 1.1 christos ALGOROLL_IRET.total_seconds() 113 1.1 christos ) 114 1.1 christos ALGOROLL_OFFVAL = -DURATION["P7D"] 115 1.1 christos KSK_CONFIG = { 116 1.1 christos "dnskey-ttl": TIMEDELTA["PT2H"], 117 1.1 christos "ds-ttl": TIMEDELTA["PT1H"], 118 1.1 christos "max-zone-ttl": TIMEDELTA["P1D"], 119 1.1 christos "parent-propagation-delay": TIMEDELTA["PT1H"], 120 1.1 christos "publish-safety": TIMEDELTA["P1D"], 121 1.1 christos "purge-keys": TIMEDELTA["PT1H"], 122 1.1 christos "retire-safety": TIMEDELTA["P2D"], 123 1.1 christos "signatures-refresh": TIMEDELTA["P7D"], 124 1.1 christos "signatures-validity": TIMEDELTA["P14D"], 125 1.1 christos "zone-propagation-delay": TIMEDELTA["PT1H"], 126 1.1 christos } 127 1.1 christos KSK_LIFETIME = TIMEDELTA["P60D"] 128 1.1 christos KSK_LIFETIME_POLICY = int(KSK_LIFETIME.total_seconds()) 129 1.1 christos KSK_IPUB = Ipub(KSK_CONFIG) 130 1.1 christos KSK_IPUBC = IpubC(KSK_CONFIG) 131 1.1 christos KSK_IRET = Iret(KSK_CONFIG, zsk=False, ksk=True) 132 1.1 christos KSK_KEYTTLPROP = KSK_CONFIG["dnskey-ttl"] + KSK_CONFIG["zone-propagation-delay"] 133 1.1 christos 134 1.1 christos 135 1.1 christos @pytest.fixture 136 1.1 christos def alg(): 137 1.1 christos return os.environ["DEFAULT_ALGORITHM_NUMBER"] 138 1.1 christos 139 1.1 christos 140 1.1 christos @pytest.fixture 141 1.1 christos def size(): 142 1.1 christos return os.environ["DEFAULT_BITS"] 143 1.1 christos 144 1.1 christos 145 1.1 christos def default_algorithm(): 146 1.1 christos return Algorithm( 147 1.1 christos os.environ["DEFAULT_ALGORITHM"], 148 1.1 christos int(os.environ["DEFAULT_ALGORITHM_NUMBER"]), 149 1.1 christos int(os.environ["DEFAULT_BITS"]), 150 1.1 christos ) 151