Properly generate salt in rpcauth.py, update tests
Previously, when iterating over bytes of the generated salt to construct a hex string, only one character would be outputted when the byte is less than 0x10. Meaning that for a 16 byte salt, the hex string might be less than 32 characters and collisions would occur.
This commit is contained in:
parent
35739976c1
commit
6be7d14d24
2 changed files with 9 additions and 12 deletions
test/util
|
@ -24,8 +24,8 @@ class TestRPCAuth(unittest.TestCase):
|
|||
self.rpcauth = importlib.import_module('rpcauth')
|
||||
|
||||
def test_generate_salt(self):
|
||||
self.assertLessEqual(len(self.rpcauth.generate_salt()), 32)
|
||||
self.assertGreaterEqual(len(self.rpcauth.generate_salt()), 16)
|
||||
for i in range(16, 32 + 1):
|
||||
self.assertEqual(len(self.rpcauth.generate_salt(i)), i * 2)
|
||||
|
||||
def test_generate_password(self):
|
||||
password = self.rpcauth.generate_password()
|
||||
|
@ -34,7 +34,7 @@ class TestRPCAuth(unittest.TestCase):
|
|||
self.assertEqual(expected_password, password)
|
||||
|
||||
def test_check_password_hmac(self):
|
||||
salt = self.rpcauth.generate_salt()
|
||||
salt = self.rpcauth.generate_salt(16)
|
||||
password = self.rpcauth.generate_password()
|
||||
password_hmac = self.rpcauth.password_to_hmac(salt, password)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue