Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dnsviz/dnsviz.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Deccio <casey@deccio.net>2021-02-06 03:04:37 +0300
committerGitHub <noreply@github.com>2021-02-06 03:04:37 +0300
commitd20c99efd8ac01001a3ec47280b3f8a1ac56e5c7 (patch)
treee75e86fa3cc8fceb4fe542814b6bd36d37f025d5
parent139ab3133df996a8916063e98b9bed0d55a0ba0a (diff)
parent0707e3e0d949fcf39b5e3b05d6ff204eb488e41b (diff)
Merge pull request #72 from julianbrost/python-3.9
Add compatibility for Python 3.9
-rw-r--r--dnsviz/crypto.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/dnsviz/crypto.py b/dnsviz/crypto.py
index 0a5cc62..f44833d 100644
--- a/dnsviz/crypto.py
+++ b/dnsviz/crypto.py
@@ -83,6 +83,13 @@ if not isinstance(GOST_ENGINE_NAME, str):
GOST_ENGINE_NAME = lb2s(GOST_ENGINE_NAME)
GOST_DIGEST_NAME = lb2s(GOST_DIGEST_NAME)
+try:
+ # available from python 3.1
+ base64encodebytes = base64.encodebytes
+except AttributeError:
+ # available until python 3.8
+ base64encodebytes = base64.encodestring
+
EC_NOCOMPRESSION = b'\x04'
@@ -275,7 +282,7 @@ def _dnskey_to_rsa(key):
def _dnskey_to_gost(key):
der = GOST_PREFIX + key
- pem = b'-----BEGIN PUBLIC KEY-----\n'+base64.encodestring(der)+b'-----END PUBLIC KEY-----'
+ pem = b'-----BEGIN PUBLIC KEY-----\n'+base64encodebytes(der)+b'-----END PUBLIC KEY-----'
return EVP.load_key_string_pubkey(pem)
@@ -287,7 +294,7 @@ def _dnskey_to_ed(alg, key):
else:
raise ValueError('Algorithm not supported')
- pem = b'-----BEGIN PUBLIC KEY-----\n'+base64.encodestring(der)+b'-----END PUBLIC KEY-----'
+ pem = b'-----BEGIN PUBLIC KEY-----\n'+base64encodebytes(der)+b'-----END PUBLIC KEY-----'
return EVP.load_key_string_pubkey(pem)
def _dnskey_to_ec(alg, key):