Merge "fixed pep8 issue and renamed strcmp_const_time to streq_const_time"
This commit is contained in:
commit
15faa1e672
@ -110,7 +110,7 @@ from time import gmtime, strftime, time
|
||||
from time import time
|
||||
from urllib import quote, unquote
|
||||
|
||||
from swift.common.utils import get_logger, strcmp_const_time
|
||||
from swift.common.utils import get_logger, streq_const_time
|
||||
|
||||
|
||||
#: The size of data to read from the form at any given time.
|
||||
@ -442,7 +442,7 @@ class FormPost(object):
|
||||
attributes.get('expires') or '0'
|
||||
)
|
||||
sig = hmac.new(key, hmac_body, sha1).hexdigest()
|
||||
if not strcmp_const_time(sig,(attributes.get('signature') or
|
||||
if not streq_const_time(sig, (attributes.get('signature') or
|
||||
'invalid')):
|
||||
return '401 Unauthorized', 'invalid signature'
|
||||
subenv['swift.authorize'] = lambda req: None
|
||||
|
@ -1119,7 +1119,7 @@ def listdir(path):
|
||||
return []
|
||||
|
||||
|
||||
def strcmp_const_time(s1, s2):
|
||||
def streq_const_time(s1, s2):
|
||||
"""Constant-time string comparison.
|
||||
|
||||
:params s1: the first string
|
||||
|
@ -850,10 +850,10 @@ log_name = %(yarr)s'''
|
||||
for v in utils.TRUE_VALUES:
|
||||
self.assertEquals(v, v.lower())
|
||||
|
||||
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_streq_const_time(self):
|
||||
self.assertTrue(utils.streq_const_time('abc123', 'abc123'))
|
||||
self.assertFalse(utils.streq_const_time('a', 'aaaaa'))
|
||||
self.assertFalse(utils.streq_const_time('ABC123', 'abc123'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user