s3-auth: Added a function to get the server_info from the system user.
[Samba/ekacnet.git] / lib / dnspython / dns / dnssec.py
blobacf46535b96c65e23d86ecb9c691dc2d6e7101e6
1 # Copyright (C) 2003-2007, 2009 Nominum, Inc.
3 # Permission to use, copy, modify, and distribute this software and its
4 # documentation for any purpose with or without fee is hereby granted,
5 # provided that the above copyright notice and this permission notice
6 # appear in all copies.
8 # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
9 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
11 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
14 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 """Common DNSSEC-related functions and constants."""
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
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,
46 # We construct the inverse mapping programmatically to ensure that we
47 # cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
48 # would cause the mapping not to be true inverse.
50 _algorithm_by_value = dict([(y, x) for x, y in _algorithm_by_text.iteritems()])
52 class UnknownAlgorithm(Exception):
53 """Raised if an algorithm is unknown."""
54 pass
56 def algorithm_from_text(text):
57 """Convert text into a DNSSEC algorithm value
58 @rtype: int"""
60 value = _algorithm_by_text.get(text.upper())
61 if value is None:
62 value = int(text)
63 return value
65 def algorithm_to_text(value):
66 """Convert a DNSSEC algorithm value to text
67 @rtype: string"""
69 text = _algorithm_by_value.get(value)
70 if text is None:
71 text = str(value)
72 return text