Replace deprecated constant_time_compare

The method is being deprecated now[1].

[1] https://review.opendev.org/c/openstack/oslo.utils/+/930198

Closes-Bug: #2081732
Change-Id: Icf9f8086e7f413247532d3f234a036b2474b7ef3
This commit is contained in:
Takashi Kajinami
2024-10-02 18:32:34 +09:00
parent 292bf442cc
commit 119b14ed93

View File

@@ -19,7 +19,6 @@ import zlib
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import secretutils
from octavia.common import exceptions
@@ -70,7 +69,7 @@ def get_payload(envelope, key, hex=True):
payload = envelope[:-len]
expected_hmc = envelope[-len:]
calculated_hmc = get_hmac(payload, key, hex=hex)
if not secretutils.constant_time_compare(expected_hmc, calculated_hmc):
if not hmac.compare_digest(expected_hmc, calculated_hmc):
LOG.warning(
'calculated hmac(hex=%(hex)s): %(s1)s not equal to msg hmac: '
'%(s2)s dropping packet',