From 96a8a1643b90219b15aa3aa83f075044e7b85c40 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Sat, 17 Aug 2013 18:33:16 -0400 Subject: [PATCH] Remove strcmp_const_time This was carried over from Nova and isn't used in Cinder. Removed in Nova via commit 08a5066d with message: "This function was used with deprecated auth and is no longer used anywhere in the code, so just remove it." Change-Id: I2b90a1a723265d9d23f89ec03246de8508d591e5 --- cinder/tests/test_utils.py | 5 ----- cinder/utils.py | 20 -------------------- 2 files changed, 25 deletions(-) diff --git a/cinder/tests/test_utils.py b/cinder/tests/test_utils.py index b7ea0729b..4468ce916 100644 --- a/cinder/tests/test_utils.py +++ b/cinder/tests/test_utils.py @@ -364,11 +364,6 @@ class GenericUtilsTestCase(test.TestCase): self.assertRaises(exception.FileNotFound, utils.read_file_as_root, 'bad') - def test_strcmp_const_time(self): - self.assertTrue(utils.strcmp_const_time('abc123', 'abc123')) - self.assertFalse(utils.strcmp_const_time('a', 'aaaaa')) - self.assertFalse(utils.strcmp_const_time('ABC123', 'abc123')) - def test_temporary_chown(self): def fake_execute(*args, **kwargs): if args[0] == 'chown': diff --git a/cinder/utils.py b/cinder/utils.py index 8942c273d..ab33463ce 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -1033,26 +1033,6 @@ def tempdir(**kwargs): LOG.debug(_('Could not remove tmpdir: %s'), str(e)) -def strcmp_const_time(s1, s2): - """Constant-time string comparison. - - :params s1: the first string - :params s2: the second string - - :return: True if the strings are equal. - - This function takes two strings and compares them. It is intended to be - used when doing a comparison for authentication purposes to help guard - against timing attacks. - """ - if len(s1) != len(s2): - return False - result = 0 - for (a, b) in zip(s1, s2): - result |= ord(a) ^ ord(b) - return result == 0 - - def walk_class_hierarchy(clazz, encountered=None): """Walk class hierarchy, yielding most derived classes first""" if not encountered: -- 2.45.2