diff options
| author | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-01-27 18:12:13 +0100 |
|---|---|---|
| committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-01-27 18:12:13 +0100 |
| commit | 29feb7900fe03ca9c5771be753e4febb36e2af67 (patch) | |
| tree | bcb5aef46f2e9059c43de2946909516cd8191c66 /tests | |
| parent | 467ca03a0251390587f20918ea9118b1ac8bcbdc (diff) | |
| download | rsa-git-29feb7900fe03ca9c5771be753e4febb36e2af67.tar.gz | |
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.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_key.py | 16 |
1 files changed, 14 insertions, 2 deletions
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 @@ import rsa.core class BlindingTest(unittest.TestCase): - def test_blinding(self): """Test blinding and unblinding. @@ -28,3 +26,17 @@ class BlindingTest(unittest.TestCase): 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) |
