From d0446bbe85d466d0e2a7b14ef784388834da36ef Mon Sep 17 00:00:00 2001 From: "Sybren A. St?vel" Date: Sun, 31 Jul 2011 20:56:13 +0200 Subject: Added unittest for large file signing/verifying --- tests/test_bigfile.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests') 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) + -- cgit v1.2.1