Python dns.hash() Examples

The following are 7 code examples of dns.hash(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module dns , or try the search function .
Example #1
Source File: tsig.py    From script.elementum.burst with Do What The F*ck You Want To Public License 6 votes vote down vote up
def get_algorithm(algorithm):
    """Returns the wire format string and the hash module to use for the
    specified TSIG algorithm

    @rtype: (string, hash constructor)
    @raises NotImplementedError: I{algorithm} is not supported
    """

    if isinstance(algorithm, string_types):
        algorithm = dns.name.from_text(algorithm)

    try:
        return (algorithm.to_digestable(), dns.hash.hashes[_hashes[algorithm]])
    except KeyError:
        raise NotImplementedError("TSIG algorithm " + str(algorithm) +
                                  " is not supported") 
Example #2
Source File: tsig.py    From luscan-devel with GNU General Public License v2.0 6 votes vote down vote up
def get_algorithm(algorithm):
    """Returns the wire format string and the hash module to use for the
    specified TSIG algorithm

    @rtype: (string, hash constructor)
    @raises NotImplementedError: I{algorithm} is not supported
    """

    global _hashes
    if _hashes is None:
        _setup_hashes()

    if isinstance(algorithm, (str, unicode)):
        algorithm = dns.name.from_text(algorithm)

    if sys.hexversion < 0x02050200 and \
       (algorithm == HMAC_SHA384 or algorithm == HMAC_SHA512):
        raise NotImplementedError("TSIG algorithm " + str(algorithm) +
                                  " requires Python 2.5.2 or later")

    try:
        return (algorithm.to_digestable(), _hashes[algorithm])
    except KeyError:
        raise NotImplementedError("TSIG algorithm " + str(algorithm) +
                                  " is not supported") 
Example #3
Source File: tsig.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def get_algorithm(algorithm):
    """Returns the wire format string and the hash module to use for the
    specified TSIG algorithm

    @rtype: (string, hash constructor)
    @raises NotImplementedError: I{algorithm} is not supported
    """

    if isinstance(algorithm, string_types):
        algorithm = dns.name.from_text(algorithm)

    try:
        return (algorithm.to_digestable(), dns.hash.hashes[_hashes[algorithm]])
    except KeyError:
        raise NotImplementedError("TSIG algorithm " + str(algorithm) +
                                  " is not supported") 
Example #4
Source File: tsig.py    From bazarr with GNU General Public License v3.0 6 votes vote down vote up
def get_algorithm(algorithm):
    """Returns the wire format string and the hash module to use for the
    specified TSIG algorithm

    @rtype: (string, hash constructor)
    @raises NotImplementedError: I{algorithm} is not supported
    """

    if isinstance(algorithm, string_types):
        algorithm = dns.name.from_text(algorithm)

    try:
        return (algorithm.to_digestable(), dns.hash.hashes[_hashes[algorithm]])
    except KeyError:
        raise NotImplementedError("TSIG algorithm " + str(algorithm) +
                                  " is not supported") 
Example #5
Source File: tsig.py    From arissploit with GNU General Public License v3.0 6 votes vote down vote up
def get_algorithm(algorithm):
    """Returns the wire format string and the hash module to use for the
    specified TSIG algorithm

    @rtype: (string, hash constructor)
    @raises NotImplementedError: I{algorithm} is not supported
    """

    if isinstance(algorithm, string_types):
        algorithm = dns.name.from_text(algorithm)

    try:
        return (algorithm.to_digestable(), dns.hash.hashes[_hashes[algorithm]])
    except KeyError:
        raise NotImplementedError("TSIG algorithm " + str(algorithm) +
                                  " is not supported") 
Example #6
Source File: tsig.py    From Tautulli with GNU General Public License v3.0 6 votes vote down vote up
def get_algorithm(algorithm):
    """Returns the wire format string and the hash module to use for the
    specified TSIG algorithm

    @rtype: (string, hash constructor)
    @raises NotImplementedError: I{algorithm} is not supported
    """

    if isinstance(algorithm, string_types):
        algorithm = dns.name.from_text(algorithm)

    try:
        return (algorithm.to_digestable(), dns.hash.hashes[_hashes[algorithm]])
    except KeyError:
        raise NotImplementedError("TSIG algorithm " + str(algorithm) +
                                  " is not supported") 
Example #7
Source File: tsig.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def _maybe_add_hash(tsig_alg, hash_alg):
    try:
        _hashes[tsig_alg] = dns.hash.get(hash_alg)
    except KeyError:
        pass