1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import base64
17 import io
18 import struct
19
20 import dns.exception
21 import dns.rdata
22 import dns.util
23
25 """NSEC3PARAM record
26
27 @ivar algorithm: the hash algorithm number
28 @type algorithm: int
29 @ivar flags: the flags
30 @type flags: int
31 @ivar iterations: the number of iterations
32 @type iterations: int
33 @ivar salt: the salt
34 @type salt: bytes"""
35
36 __slots__ = ['algorithm', 'flags', 'iterations', 'salt']
37
38 - def __init__(self, rdclass, rdtype, algorithm, flags, iterations, salt):
44
45 - def to_text(self, origin=None, relativize=True, **kw):
46 if self.salt == b'':
47 salt = '-'
48 else:
49 salt = base64.b16encode(self.salt).decode('ascii').lower()
50 return '%u %u %u %s' % (self.algorithm, self.flags, self.iterations, salt)
51
52 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
53 algorithm = tok.get_uint8()
54 flags = tok.get_uint8()
55 iterations = tok.get_uint16()
56 salt = tok.get_string()
57 if salt == '-':
58 salt = b''
59 else:
60 salt = bytes.fromhex(salt)
61 return cls(rdclass, rdtype, algorithm, flags, iterations, salt)
62
63 from_text = classmethod(from_text)
64
65 - def to_wire(self, file, compress = None, origin = None):
70
71 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
82
83 from_wire = classmethod(from_wire)
84
85 - def _cmp(self, other):
87