Skip to content

Commit

Permalink
Merge "Remove strcmp_const_time"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 19, 2013
2 parents 7c9817b + 96a8a16 commit 5d6c11f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
5 changes: 0 additions & 5 deletions cinder/tests/test_utils.py
Expand Up @@ -364,11 +364,6 @@ def fake_execute(*args, **kwargs):
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':
Expand Down
20 changes: 0 additions & 20 deletions cinder/utils.py
Expand Up @@ -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:
Expand Down

0 comments on commit 5d6c11f

Please sign in to comment.