summaryrefslogtreecommitdiff
path: root/dns/zonetypes.py
blob: 195ee2ec9b5f62e15d27f196d5f4244f4290f0b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license

"""Common zone-related types."""

# This is a separate file to avoid import circularity between dns.zone and
# the implementation of the ZONEMD type.

import hashlib

import dns.enum


class DigestScheme(dns.enum.IntEnum):
    """ZONEMD Scheme"""

    SIMPLE = 1

    @classmethod
    def _maximum(cls):
        return 255


class DigestHashAlgorithm(dns.enum.IntEnum):
    """ZONEMD Hash Algorithm"""

    SHA384 = 1
    SHA512 = 2

    @classmethod
    def _maximum(cls):
        return 255


_digest_hashers = {
    DigestHashAlgorithm.SHA384: hashlib.sha384,
    DigestHashAlgorithm.SHA512: hashlib.sha512,
}