Fix #18: Add an 'exponent' argument to key.newkeys()
Adds the possibility to create a new key using a custom exponent. Mostly
for compatibility. Also removed the unused parameter nbits from
calculate_keys(). I added a new function calculate_keys_custom_exponent()
so that people still passing a value to nbits don't accidentally use
it as the exponent.
diff --git a/tests/test_key.py b/tests/test_key.py
index df35335..0e62f55 100644
--- a/tests/test_key.py
+++ b/tests/test_key.py
@@ -2,7 +2,6 @@
Some tests for the rsa/key.py file.
"""
-
import unittest
import rsa.key
@@ -10,7 +9,6 @@
class BlindingTest(unittest.TestCase):
-
def test_blinding(self):
"""Test blinding and unblinding.
@@ -28,3 +26,17 @@
unblinded = pk.unblind(decrypted, 4134431)
self.assertEqual(unblinded, message)
+
+
+class KeyGenTest(unittest.TestCase):
+ def test_custom_exponent(self):
+ priv, pub = rsa.key.newkeys(16, exponent=3)
+
+ self.assertEqual(3, priv.e)
+ self.assertEqual(3, pub.e)
+
+ def test_default_exponent(self):
+ priv, pub = rsa.key.newkeys(16)
+
+ self.assertEqual(0x10001, priv.e)
+ self.assertEqual(0x10001, pub.e)