diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2017-10-03 18:45:28 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2018-02-05 22:27:07 +0100 |
commit | eb7ece6cf3b287c3a2d28af0454482e473e07e4f (patch) | |
tree | 7992033f547e671c073d35bd8225551140ccf1ca /tests/test_bio.py | |
parent | 58986b62898d86b1808bde46c991546b7ed5d437 (diff) | |
download | m2crypto-eb7ece6cf3b287c3a2d28af0454482e473e07e4f.tar.gz |
Add longer IV to the cipher test.
Diffstat (limited to 'tests/test_bio.py')
-rw-r--r-- | tests/test_bio.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/test_bio.py b/tests/test_bio.py index f8460cf..447df67 100644 --- a/tests/test_bio.py +++ b/tests/test_bio.py @@ -21,25 +21,26 @@ from tests.fips import fips_mode log = logging.getLogger('test_bio') + class CipherStreamTestCase(unittest.TestCase): def try_algo(self, algo): data = b'123456789012345678901234' - my_key = 3 * 15 * b"key" # DES requires larger key + my_key = 3 * 15 * b"key" + my_IV = 3 * 16 * b'IV' # Encrypt. mem = BIO.MemoryBuffer() cf = BIO.CipherStream(mem) - cf.set_cipher(algo, my_key, 'iv', 1) + cf.set_cipher(algo, my_key, my_IV, 1) cf.write(data) cf.flush() cf.write_close() cf.close() ciphertext = mem.read() - # Decrypt. mem = BIO.MemoryBuffer(ciphertext) cf = BIO.CipherStream(mem) - cf.set_cipher(algo, my_key, 'iv', 0) + cf.set_cipher(algo, my_key, my_IV, 0) cf.write_close() data2 = cf.read() cf.close() |