From 44cf56857eccbb8fa415a1769f75ea7e23666125 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 9 Jun 2022 10:48:12 -0400 Subject: [PATCH] Add fallbacks to PyCrypto compatible names Cryptodome is not always packaged with the explicit form, fall back to the Crypto names hoping that the user wouldn't be trying to use PyCrypto is this day and age. --- confluent_server/confluent/auth.py | 5 ++++- confluent_server/confluent/config/configmanager.py | 14 ++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/auth.py b/confluent_server/confluent/auth.py index ce8cfd49..b71dbb6d 100644 --- a/confluent_server/confluent/auth.py +++ b/confluent_server/confluent/auth.py @@ -22,7 +22,10 @@ import confluent.config.configmanager as configmanager import eventlet import eventlet.tpool -import Cryptodome.Protocol.KDF as KDF +try: + import Cryptodome.Protocol.KDF as KDF +except ImportError: + import Crypto.Protocol.KDF as KDF from fnmatch import fnmatch import hashlib import hmac diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 91f48ffc..58f4bc59 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -42,10 +42,16 @@ # by passphrase and optionally TPM -import Cryptodome.Protocol.KDF as KDF -from Cryptodome.Cipher import AES -from Cryptodome.Hash import HMAC -from Cryptodome.Hash import SHA256 +try: + import Cryptodome.Protocol.KDF as KDF + from Cryptodome.Cipher import AES + from Cryptodome.Hash import HMAC + from Cryptodome.Hash import SHA256 +except ImportError: + import Crypto.Protocol.KDF as KDF + from Crypto.Cipher import AES + from Crypto.Hash import HMAC + from Crypto.Hash import SHA256 try: import anydbm as dbm except ModuleNotFoundError: