Files
firefox/third_party/python/rsa/tests/test_integers.py
T
Andrew Halberstadt 7bb38413f2 Bug 1346025 - Move vendored python modules from /python to /third_party/python, r=ted
This commit is a simple 'hg mv' and does not contain any file modifications.

***
Bug 1346025 - Split vendored modules in python/moz.build to third_party/python/moz.build, r=ted

***
Bug 1346025 - Update references to moved python modules, r=ted

MozReview-Commit-ID: A12RnIFtXju
2017-05-25 11:48:03 -04:00

37 lines
891 B
Python

'''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)