summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rsa/_compat.py5
-rw-r--r--tests/test_common.py3
2 files changed, 8 insertions, 0 deletions
diff --git a/rsa/_compat.py b/rsa/_compat.py
index 7533c36..3c4eb81 100644
--- a/rsa/_compat.py
+++ b/rsa/_compat.py
@@ -76,6 +76,11 @@ except NameError:
bytes_type = str
+# To avoid calling b() multiple times in tight loops.
+ZERO_BYTE = b('\x00')
+EMPTY_BYTE = b('')
+
+
def is_bytes(obj):
"""
Determines whether the given value is a byte string.
diff --git a/tests/test_common.py b/tests/test_common.py
index bad24f8..9980b15 100644
--- a/tests/test_common.py
+++ b/tests/test_common.py
@@ -34,6 +34,9 @@ class Test_byte_size(unittest2.TestCase):
self.assertRaises(TypeError, byte_size, None)
class Test_bit_size(unittest2.TestCase):
+ def test_zero(self):
+ self.assertEqual(bit_size(0), 0)
+
def test_values(self):
self.assertEqual(bit_size(1023), 10)
self.assertEqual(bit_size(1024), 11)