+
+class TLSA:
+ class Usage:
+ CA = 0 # certificate must pass the usual CA check, with the CA specified by the TLSA record
+ EndEntity_PlusCAs = 1 # the certificate must match the TLSA record *and* pass the usual CA check
+ TrustAnchor = 2 # the certificate must pass a check with the TLSA record giving the (only) trust anchor
+ EndEntity = 3 # the certificate must match the TLSA record
+
+ class Selector:
+ Full = 0
+ SubjectPublicKeyInfo = 1
+
+ class MatchingType:
+ Exact = 0
+ SHA256 = 1
+ SHA512 = 2
+
+ def __init__(self, protocol: str, port: int, usage: int, selector: int, matching_type: int, data: str) -> None:
+ self._port = int(port)
+ self._protocol = str(protocol)
+ self._usage = int(usage)
+ self._selector = int(selector)
+ self._matching_type = int(matching_type)
+ self._data = check_hex(data)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> 'Any':
+ return zone.RR('_{0}._{1}.{2}'.format(self._port, self._protocol, owner), 'TLSA', '{0} {1} {2} {3}'.format(self._usage, self._selector, self._matching_type, self._data))
+
+
+class CNAME:
+ def __init__(self, name: str) -> None:
+ self._name = check_hostname(name)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> 'Any':
+ return zone.RR(owner, 'CNAME', zone.abs_hostname(self._name))
+
+
+class NS:
+ def __init__(self, name: str) -> None:
+ self._name = check_hostname(name)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> 'Any':
+ return zone.RR(owner, 'NS', zone.abs_hostname(self._name))
+
+
+class DS:
+ def __init__(self, tag: int, alg: int, digest: int, key: str) -> None:
+ self._tag = int(tag)
+ self._key = check_hex(key)
+ self._alg = int(alg)
+ self._digest = int(digest)
+
+ def generate_rr(self, owner: str, zone: 'Zone') -> 'Any':
+ return zone.RR(owner, 'DS', '{0} {1} {2} {3}'.format(self._tag, self._alg, self._digest, self._key))
+
+## Higher-level classes