--- /dev/null
+/*
+ * 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.
+ */
+
+trust-anchors {
+{% for ta in trust_anchors %}
+ "@ta.domain@" @ta.type@ @ta.contents@;
+{% endfor %}
+};
from typing import Dict, List, Optional, Tuple, Union
import dns
+import dns.dnssec
+from dns.dnssectypes import DSDigest
import dns.rdatatype
import dns.rrset
import dns.tsig
import isctest.query
import isctest.util
from isctest.instance import NamedInstance
+from isctest.template import TrustAnchor
from isctest.vars.algorithms import Algorithm, ALL_ALGORITHMS_BY_NUM
DEFAULT_TTL = 300
), f"DNSKEY not found in {self.keyfile}"
return dnskey_rr
+ def into_ta(self, ta_type: str, dsdigest=DSDigest.SHA256) -> TrustAnchor:
+ dnskey = self.dnskey
+ if ta_type in ["static-ds", "initial-ds"]:
+ ds = dns.dnssec.make_ds(dnskey.name, dnskey[0], dsdigest)
+ parts = str(ds).split()
+ contents = " ".join(parts[:3]) + f' "{parts[3]}"'
+ elif ta_type in ["static-key", "initial-key"]:
+ parts = str(dnskey).split()
+ contents = " ".join(parts[4:7]) + f' "{"".join(parts[7:])}"'
+ else:
+ raise ValueError(f"invalid trust anchor type: {ta_type}")
+ return TrustAnchor(str(dnskey.name), ta_type, contents)
+
def is_ksk(self) -> bool:
return self.get_metadata("KSK") == "yes"
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
+from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, Optional, Union
]
for template in templates:
self.render(template[:-3], data)
+
+
+@dataclass
+class TrustAnchor:
+ domain: str
+ type: str
+ contents: str