From 5ae7d21f98bc8e6237f600f4885f94e57a2c99b1 Mon Sep 17 00:00:00 2001 From: Alfredo Moralejo Date: Wed, 21 Aug 2019 17:44:16 +0200 Subject: [PATCH] Add digestmod when using hmac Until Python 3.8 hmc.new() defaulted the digestmod argument to 'hmac-md5'. This was deperecated, to be removed in Python 3.8 [1], so let's get ready for new python. Also switching to more secure sha1 algorithm, using md5 anywhere may trigger alerts from automatic security tools. [1] https://docs.python.org/3.8/library/hmac.html Change-Id: I4b365cb05de98bdd498b3c2094e4a77ab3944b12 --- oslo_utils/tests/test_secretutils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oslo_utils/tests/test_secretutils.py b/oslo_utils/tests/test_secretutils.py index faea3dd3..87f6218d 100644 --- a/oslo_utils/tests/test_secretutils.py +++ b/oslo_utils/tests/test_secretutils.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import hashlib import hmac from oslotest import base as test_base @@ -23,7 +24,8 @@ from oslo_utils import secretutils class SecretUtilsTest(testscenarios.TestWithScenarios, test_base.BaseTestCase): - _gen_digest = lambda text: hmac.new(b'foo', text.encode('utf-8')).digest() + _gen_digest = lambda text: hmac.new(b'foo', text.encode('utf-8'), + digestmod=hashlib.sha1).digest() scenarios = [ ('binary', {'converter': _gen_digest}), ('unicode', {'converter': lambda text: text}),