summaryrefslogtreecommitdiffstats
path: root/python/rsa/tests/test_integers.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /python/rsa/tests/test_integers.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'python/rsa/tests/test_integers.py')
-rw-r--r--python/rsa/tests/test_integers.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/python/rsa/tests/test_integers.py b/python/rsa/tests/test_integers.py
new file mode 100644
index 000000000..0a712aa0f
--- /dev/null
+++ b/python/rsa/tests/test_integers.py
@@ -0,0 +1,36 @@
+'''Tests integer operations.'''
+
+import unittest2
+
+import rsa.core
+
+class IntegerTest(unittest2.TestCase):
+
+ def setUp(self):
+ (self.pub, self.priv) = rsa.newkeys(64)
+
+ def test_enc_dec(self):
+
+ message = 42
+ print("\tMessage: %d" % message)
+
+ encrypted = rsa.core.encrypt_int(message, self.pub.e, self.pub.n)
+ print("\tEncrypted: %d" % encrypted)
+
+ decrypted = rsa.core.decrypt_int(encrypted, self.priv.d, self.pub.n)
+ print("\tDecrypted: %d" % decrypted)
+
+ self.assertEqual(message, decrypted)
+
+ def test_sign_verify(self):
+
+ message = 42
+
+ signed = rsa.core.encrypt_int(message,self.priv.d, self.pub.n)
+ print("\tSigned: %d" % signed)
+
+ verified = rsa.core.decrypt_int(signed, self.pub.e,self.pub.n)
+ print("\tVerified: %d" % verified)
+
+ self.assertEqual(message, verified)
+