diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2011-07-31 20:56:13 +0200 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2011-07-31 20:56:13 +0200 |
commit | 61becf6573aee105baf866b2541cf10dffc3c820 (patch) | |
tree | 38339c5c5121947d146cc27d655df3e3a9c0f440 | |
parent | 3200f895745919a6074505dd40c8d0f88b01836a (diff) | |
download | rsa-git-61becf6573aee105baf866b2541cf10dffc3c820.tar.gz |
Added unittest for large file signing/verifying
-rw-r--r-- | tests/test_bigfile.py | 21 |
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) + |