more things are bytes

This commit is contained in:
meejah 2019-06-24 17:00:03 -06:00
parent e2717245ce
commit 609d5f255d

View File

@ -80,7 +80,7 @@ class TestRegression(unittest.TestCase):
E = fake_ecb_using_ctr E = fake_ecb_using_ctr
b = 16 b = 16
k = keysize k = keysize
S = '\x00' * (k + b) S = b'\x00' * (k + b)
for i in range(1000): for i in range(1000):
K = S[-k:] K = S[-k:]
@ -189,8 +189,8 @@ class TestRegression(unittest.TestCase):
This simply checks that keys and signatures generated using the old code are still valid This simply checks that keys and signatures generated using the old code are still valid
using the new code. using the new code.
''' '''
priv_str = 'priv-v0-lqcj746bqa4npkb6zpyc6esd74x3bl6mbcjgqend7cvtgmcpawhq' priv_str = b'priv-v0-lqcj746bqa4npkb6zpyc6esd74x3bl6mbcjgqend7cvtgmcpawhq'
pub_str = 'pub-v0-yzpqin3of3ep363lwzxwpvgai3ps43dao46k2jds5kw5ohhpcwhq' pub_str = b'pub-v0-yzpqin3of3ep363lwzxwpvgai3ps43dao46k2jds5kw5ohhpcwhq'
test_data = b'test' test_data = b'test'
sig = (b'\xde\x0e\xd6\xe2\xf5\x03]8\xfe\xa71\xad\xb4g\x03\x11\x81\x8b\x08\xffz\xf4K\xa0' sig = (b'\xde\x0e\xd6\xe2\xf5\x03]8\xfe\xa71\xad\xb4g\x03\x11\x81\x8b\x08\xffz\xf4K\xa0'
b'\x86 ier!\xe8\xe5#*\x9d\x8c\x0bI\x02\xd90\x0e7\xbeW\xbf\xa3\xfe\xc1\x1c\xf5+\xe9)' b'\x86 ier!\xe8\xe5#*\x9d\x8c\x0bI\x02\xd90\x0e7\xbeW\xbf\xa3\xfe\xc1\x1c\xf5+\xe9)'
@ -224,7 +224,7 @@ class TestRegression(unittest.TestCase):
''' '''
only bytes can be encrypted only bytes can be encrypted
''' '''
key = '\x00' * 16 key = b'\x00' * 16
encryptor = aes.create_encryptor(key) encryptor = aes.create_encryptor(key)
with self.assertRaises(ValueError) as ctx: with self.assertRaises(ValueError) as ctx:
aes.encrypt_data(encryptor, six.text_type("not bytes")) aes.encrypt_data(encryptor, six.text_type("not bytes"))
@ -237,7 +237,7 @@ class TestRegression(unittest.TestCase):
''' '''
only bytes can be encrypted only bytes can be encrypted
''' '''
key = '\x00' * 12 key = b'\x00' * 12
with self.assertRaises(ValueError) as ctx: with self.assertRaises(ValueError) as ctx:
aes.create_encryptor(key) aes.create_encryptor(key)
self.assertIn( self.assertIn(
@ -249,7 +249,7 @@ class TestRegression(unittest.TestCase):
''' '''
iv must be bytes iv must be bytes
''' '''
key = '\x00' * 16 key = b'\x00' * 16
with self.assertRaises(TypeError) as ctx: with self.assertRaises(TypeError) as ctx:
aes.create_encryptor(key, iv=six.text_type("1234567890abcdef")) aes.create_encryptor(key, iv=six.text_type("1234567890abcdef"))
self.assertIn( self.assertIn(
@ -261,9 +261,9 @@ class TestRegression(unittest.TestCase):
''' '''
iv must be 16 bytes iv must be 16 bytes
''' '''
key = '\x00' * 16 key = b'\x00' * 16
with self.assertRaises(ValueError) as ctx: with self.assertRaises(ValueError) as ctx:
aes.create_encryptor(key, iv='\x00' * 3) aes.create_encryptor(key, iv=b'\x00' * 3)
self.assertIn( self.assertIn(
"16 bytes long", "16 bytes long",
str(ctx.exception) str(ctx.exception)