1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import struct
17 import binascii
18
19 import dns.exception
20 import dns.rdata
21 from dns._compat import text_type
25
26 """NSEC3PARAM record
27
28 @ivar algorithm: the hash algorithm number
29 @type algorithm: int
30 @ivar flags: the flags
31 @type flags: int
32 @ivar iterations: the number of iterations
33 @type iterations: int
34 @ivar salt: the salt
35 @type salt: string"""
36
37 __slots__ = ['algorithm', 'flags', 'iterations', 'salt']
38
39 - def __init__(self, rdclass, rdtype, algorithm, flags, iterations, salt):
48
49 - def to_text(self, origin=None, relativize=True, **kw):
50 if self.salt == b'':
51 salt = '-'
52 else:
53 salt = binascii.hexlify(self.salt).decode()
54 return '%u %u %u %s' % (self.algorithm, self.flags, self.iterations,
55 salt)
56
57 @classmethod
58 - def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
59 algorithm = tok.get_uint8()
60 flags = tok.get_uint8()
61 iterations = tok.get_uint16()
62 salt = tok.get_string()
63 if salt == '-':
64 salt = ''
65 else:
66 salt = binascii.unhexlify(salt.encode())
67 tok.get_eol()
68 return cls(rdclass, rdtype, algorithm, flags, iterations, salt)
69
70 - def to_wire(self, file, compress=None, origin=None):
75
76 @classmethod
77 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
89