from isctest.instance import NamedInstance
from isctest.run import EnvCmd
-from isctest.vars.algorithms import ALL_ALGORITHMS_BY_NUM, Algorithm
+from isctest.vars.algorithms import ALL_ALGORITHMS_BY_DST, ECDSAP256SHA256, Algorithm
from isctest.zone import FileZoneKey
import isctest.log
@staticmethod
def default(with_state=True) -> "KeyProperties":
metadata = {
- "Algorithm": isctest.vars.algorithms.ECDSAP256SHA256.number,
+ "Algorithm": ECDSAP256SHA256.number,
"Length": 256,
"Lifetime": 0,
"KSK": "yes",
return ksigning, zsigning
- def get_dnsalg(self) -> int:
- alg = int(self.get_metadata("Algorithm"))
- if alg == isctest.vars.algorithms.RSASHA256OID.dst:
- return isctest.vars.algorithms.RSASHA256OID.number
- if alg == isctest.vars.algorithms.RSASHA512OID.dst:
- return isctest.vars.algorithms.RSASHA512OID.number
- return alg
-
def is_ksk(self) -> bool:
# KASP role follows the .state KSK metadata, not the DNSKEY SEP flag:
# a CSK may be configured without SEP (see the csk-nosep test).
@property
def algorithm(self) -> Algorithm:
- num = int(self.get_metadata("Algorithm"))
- return ALL_ALGORITHMS_BY_NUM[num]
+ """
+ Obtain the algorithm from key metadata.
+
+ The .state Algorithm field holds the DST identifier, which (unlike the
+ on-wire DNSKEY algorithm number) distinguishes the private-OID variants
+ RSASHA256OID and RSASHA512OID, both of which appear as 254 on the wire.
+ """
+ dst = int(self.get_metadata("Algorithm"))
+ return ALL_ALGORITHMS_BY_DST[dst]
def dnskey_equals(self, value, cdnskey=False):
dnskey = value.split()
offline_ksk=offline_ksk, zsk_missing=zsk_missing, smooth=smooth
)
- alg = key.get_dnsalg()
+ alg = key.algorithm.number
rtype = dns.rdatatype.to_text(covers)
expect = rf"IN RRSIG {rtype} {alg} (\d) (\d+) (\d+) (\d+) {key.tag} {signer}"
indicating that the signing process for this key is completed.
"""
keyid = key.tag
- algorithm = key.get_dnsalg()
- secalg = int(key.get_metadata("Algorithm"))
+ wire_alg = key.algorithm.number
+ dst_alg = key.algorithm.dst
- if algorithm < 256:
- return f"{zone}. 0 IN TYPE{rrtype} \\# 5 {secalg:02x}{keyid:04x}0000"
+ if dst_alg < 256:
+ return f"{zone}. 0 IN TYPE{rrtype} \\# 5 {wire_alg:02x}{keyid:04x}0000"
- return f"{zone}. 0 IN TYPE{rrtype} \\# 7 {secalg:02x}{keyid:04x}0000{algorithm:04x}"
+ return f"{zone}. 0 IN TYPE{rrtype} \\# 7 {wire_alg:02x}{keyid:04x}0000{dst_alg:04x}"