summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSybren A. St?vel <sybren@stuvel.eu>2011-07-31 20:56:13 +0200
committerSybren A. St?vel <sybren@stuvel.eu>2011-07-31 20:56:13 +0200
commitd0446bbe85d466d0e2a7b14ef784388834da36ef (patch)
tree38339c5c5121947d146cc27d655df3e3a9c0f440 /tests
parent3ad13edad1f0da543f4e7b38aff62f7c91b58052 (diff)
downloadrsa-d0446bbe85d466d0e2a7b14ef784388834da36ef.tar.gz
Added unittest for large file signing/verifying
Diffstat (limited to 'tests')
-rw-r--r--tests/test_bigfile.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_bigfile.py b/tests/test_bigfile.py
index ffca5b0..30156a1 100644
--- a/tests/test_bigfile.py
+++ b/tests/test_bigfile.py
@@ -4,7 +4,7 @@ from StringIO import StringIO
import unittest
import rsa
-from rsa import bigfile, varblock
+from rsa import bigfile, varblock, pkcs1
class BigfileTest(unittest.TestCase):
@@ -35,3 +35,22 @@ class BigfileTest(unittest.TestCase):
varblocks = list(varblock.yield_varblocks(cryptfile))
self.assertEqual(2, len(varblocks))
+
+ def test_sign_verify_bigfile(self):
+
+ # Large enough to store MD5-sum and ASN.1 code for MD5
+ pub_key, priv_key = rsa.newkeys((34 + 11) * 8)
+
+ # Sign the file
+ msgfile = StringIO('123456Sybren')
+ signature = pkcs1.sign(msgfile, priv_key, 'MD5')
+
+ # Check the signature
+ msgfile.seek(0)
+ pkcs1.verify(msgfile, signature, pub_key)
+
+ # Alter the message, re-check
+ msgfile = StringIO('123456sybren')
+ self.assertRaises(pkcs1.VerificationError,
+ pkcs1.verify, msgfile, signature, pub_key)
+