1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """Common DNSSEC-related functions and constants."""
17
18 RSAMD5 = 1
19 DH = 2
20 DSA = 3
21 ECC = 4
22 RSASHA1 = 5
23 DSANSEC3SHA1 = 6
24 RSASHA1NSEC3SHA1 = 7
25 RSASHA256 = 8
26 RSASHA512 = 10
27 INDIRECT = 252
28 PRIVATEDNS = 253
29 PRIVATEOID = 254
30
31 _algorithm_by_text = {
32 'RSAMD5' : RSAMD5,
33 'DH' : DH,
34 'DSA' : DSA,
35 'ECC' : ECC,
36 'RSASHA1' : RSASHA1,
37 'DSANSEC3SHA1' : DSANSEC3SHA1,
38 'RSASHA1NSEC3SHA1' : RSASHA1NSEC3SHA1,
39 'RSASHA256' : RSASHA256,
40 'RSASHA512' : RSASHA512,
41 'INDIRECT' : INDIRECT,
42 'PRIVATEDNS' : PRIVATEDNS,
43 'PRIVATEOID' : PRIVATEOID,
44 }
45
46
47
48
49
50 _algorithm_by_value = dict([(y, x) for x, y in _algorithm_by_text.iteritems()])
51
53 """Raised if an algorithm is unknown."""
54 pass
55
57 """Convert text into a DNSSEC algorithm value
58 @rtype: int"""
59
60 value = _algorithm_by_text.get(text.upper())
61 if value is None:
62 value = int(text)
63 return value
64
66 """Convert a DNSSEC algorithm value to text
67 @rtype: string"""
68
69 text = _algorithm_by_value.get(value)
70 if text is None:
71 text = str(value)
72 return text
73