summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2016-03-17 15:04:04 +0100
committerSybren A. Stüvel <sybren@stuvel.eu>2016-03-17 15:16:23 +0100
commit83a81107342ba414064703e5919978782d6bee01 (patch)
treebb1963b7a03849ff4523accab2bbda49d0846611 /tests
parent5d6603258881710fdd7aac866f6ec7445c864d50 (diff)
downloadrsa-git-83a81107342ba414064703e5919978782d6bee01.tar.gz
Removed deprecated functionality.
The following modules have been removed: - rsa._version133 - rsa._version200 - rsa.bigfile - rsa.varblock The encrypt/decrypt-bigfile CLI commands have also been removed.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_bigfile.py73
-rw-r--r--tests/test_varblock.py88
2 files changed, 0 insertions, 161 deletions
diff --git a/tests/test_bigfile.py b/tests/test_bigfile.py
deleted file mode 100644
index 70278dc..0000000
--- a/tests/test_bigfile.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Tests block operations."""
-
-from rsa._compat import b
-
-try:
- from StringIO import StringIO as BytesIO
-except ImportError:
- from io import BytesIO
-import unittest
-
-import rsa
-from rsa import bigfile, varblock, pkcs1
-
-
-class BigfileTest(unittest.TestCase):
- def test_encrypt_decrypt_bigfile(self):
- # Expected block size + 11 bytes padding
- pub_key, priv_key = rsa.newkeys((6 + 11) * 8)
-
- # Encrypt the file
- message = b('123456Sybren')
- infile = BytesIO(message)
- outfile = BytesIO()
-
- bigfile.encrypt_bigfile(infile, outfile, pub_key)
-
- # Test
- crypto = outfile.getvalue()
-
- cryptfile = BytesIO(crypto)
- clearfile = BytesIO()
-
- bigfile.decrypt_bigfile(cryptfile, clearfile, priv_key)
- self.assertEquals(clearfile.getvalue(), message)
-
- # We have 2x6 bytes in the message, so that should result in two
- # bigfile.
- cryptfile.seek(0)
- 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 = BytesIO(b('123456Sybren'))
- signature = pkcs1.sign(msgfile, priv_key, 'MD5')
-
- # Check the signature
- msgfile.seek(0)
- self.assertTrue(pkcs1.verify(msgfile, signature, pub_key))
-
- # Alter the message, re-check
- msgfile = BytesIO(b('123456sybren'))
- self.assertRaises(pkcs1.VerificationError,
- pkcs1.verify, msgfile, signature, pub_key)
diff --git a/tests/test_varblock.py b/tests/test_varblock.py
deleted file mode 100644
index d1c3730..0000000
--- a/tests/test_varblock.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Tests varblock operations."""
-
-try:
- from StringIO import StringIO as BytesIO
-except ImportError:
- from io import BytesIO
-import unittest
-
-from rsa._compat import b
-from rsa import varblock
-
-
-class VarintTest(unittest.TestCase):
- def test_read_varint(self):
- encoded = b('\xac\x02crummy')
- infile = BytesIO(encoded)
-
- (decoded, read) = varblock.read_varint(infile)
-
- # Test the returned values
- self.assertEqual(300, decoded)
- self.assertEqual(2, read)
-
- # The rest of the file should be untouched
- self.assertEqual(b('crummy'), infile.read())
-
- def test_read_zero(self):
- encoded = b('\x00crummy')
- infile = BytesIO(encoded)
-
- (decoded, read) = varblock.read_varint(infile)
-
- # Test the returned values
- self.assertEqual(0, decoded)
- self.assertEqual(1, read)
-
- # The rest of the file should be untouched
- self.assertEqual(b('crummy'), infile.read())
-
- def test_write_varint(self):
- expected = b('\xac\x02')
- outfile = BytesIO()
-
- written = varblock.write_varint(outfile, 300)
-
- # Test the returned values
- self.assertEqual(expected, outfile.getvalue())
- self.assertEqual(2, written)
-
- def test_write_zero(self):
- outfile = BytesIO()
- written = varblock.write_varint(outfile, 0)
-
- # Test the returned values
- self.assertEqual(b('\x00'), outfile.getvalue())
- self.assertEqual(1, written)
-
-
-class VarblockTest(unittest.TestCase):
- def test_yield_varblock(self):
- infile = BytesIO(b('\x01\x0512345\x06Sybren'))
-
- varblocks = list(varblock.yield_varblocks(infile))
- self.assertEqual([b('12345'), b('Sybren')], varblocks)
-
-
-class FixedblockTest(unittest.TestCase):
- def test_yield_fixedblock(self):
- infile = BytesIO(b('123456Sybren'))
-
- fixedblocks = list(varblock.yield_fixedblocks(infile, 6))
- self.assertEqual([b('123456'), b('Sybren')], fixedblocks)