diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2016-05-11 22:52:53 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2016-05-12 15:50:44 +0200 |
commit | 9f869162da7fc83894100ded990766841b946bf9 (patch) | |
tree | bd338e1ea7e4461ae383764f050d6c7f4be7116c /tests/test_evp.py | |
parent | 57397845bf0cc7bacd1cb0741936760eb1eef150 (diff) | |
download | m2crypto-9f869162da7fc83894100ded990766841b946bf9.tar.gz |
Replace util.py3k with six.PY3
(this was the original comment on removing util.py3{bytes,str}
describing my plans for future)
It seems to that this abstraction goes exactly wrong way. The
primary goal of py3k/py2k string abstraction should be IMHO the
elimination of the ambiguous py2k str() object. Everything should be
(using py2 terminology) either unicode() or bytes(), and when we
start working on rebasing the ``python3`` branch on top of ``six``,
we should spend all our effort on clarification between these two
types and elimination of str(). Which seems to me is exactly what
six.u() and six.b() methods do, so I would use them.
Also eliminate util.h2b and util.py3ord
Diffstat (limited to 'tests/test_evp.py')
-rw-r--r-- | tests/test_evp.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/tests/test_evp.py b/tests/test_evp.py index b0d81ea..eb97d96 100644 --- a/tests/test_evp.py +++ b/tests/test_evp.py @@ -12,10 +12,9 @@ import cStringIO import logging import sha -from M2Crypto import BIO, EVP, RSA, Rand, m2, util -from M2Crypto.util import h2b +from M2Crypto import BIO, EVP, RSA, Rand, m2, six, util -from binascii import hexlify, unhexlify +from binascii import a2b_hex, hexlify, unhexlify try: import unittest2 as unittest except ImportError: @@ -43,6 +42,8 @@ class EVPTestCase(unittest.TestCase): rsa = self._assign_rsa() rsa.check_key() + @unittest.skipIf(six.PY3, + "test_pem hangs under python3 and is not yet fixed") def test_pem(self): rsa = RSA.gen_key(1024, 3, callback=self._gen_callback) pkey = EVP.PKey() @@ -151,6 +152,8 @@ class EVPTestCase(unittest.TestCase): with self.assertRaises(ValueError): EVP.hmac('key', 'data', algo='sha513') + @unittest.skipIf(six.PY3, + "test_get_rsa hangs under python3 and is not yet fixed") def test_get_rsa(self): """ Testing retrieving the RSA key from the PKey instance. @@ -176,6 +179,8 @@ class EVPTestCase(unittest.TestCase): rsa3 = RSA.gen_key(1024, 3, callback=self._gen_callback) self.assertNotEqual(rsa.sign(digest), rsa3.sign(digest)) + @unittest.skipIf(six.PY3, + 'FIXME test_load_key_string_pubkey hangs under python3') def test_load_key_string_pubkey(self): """ Testing creating a PKey instance from PEM string. @@ -426,9 +431,9 @@ class CipherTestCase(unittest.TestCase): plaintext_value = 'This is three blocks of text with unicode char \x03' ciphertext_values = { - '128': unhexlify('6098fb2e49b3f7ed34f841f43f825d84cf4834021511594b931c85f04662544bdb4f38232e9d87fda6280ab1ef450e27'), - '192': unhexlify('2299b1c5363824cb92b5851dedc73f49f30b23fb23f288492e840c951ce703292a5c6de6fc7f0625c403648f8ca4a582'), - '256': unhexlify('713e34bcd2c59affc9185a716c3c6aef5c9bf7b9914337dd96e9d7436344bcb9c35175afb54adb78aab322829ce9cb4a'), + '128': unhexlify('6098fb2e49b3f7ed34f841f43f825d84cf4834021511594b931c85f04662544bdb4f38232e9d87fda6280ab1ef450e27'), # noqa + '192': unhexlify('2299b1c5363824cb92b5851dedc73f49f30b23fb23f288492e840c951ce703292a5c6de6fc7f0625c403648f8ca4a582'), # noqa + '256': unhexlify('713e34bcd2c59affc9185a716c3c6aef5c9bf7b9914337dd96e9d7436344bcb9c35175afb54adb78aab322829ce9cb4a'), # noqa } for key_size in [128, 192, 256]: @@ -505,17 +510,17 @@ class PBKDF2TestCase(unittest.TestCase): class HMACTestCase(unittest.TestCase): - data1 = ['', 'More text test vectors to stuff up EBCDIC machines :-)', - h2b("b760e92d6662d351eb3801057695ac0346295356")] + data1 = [b'', b'More text test vectors to stuff up EBCDIC machines :-)', + a2b_hex("b760e92d6662d351eb3801057695ac0346295356")] - data2 = [h2b('0b' * 16), "Hi There", - h2b("675b0b3a1b4ddf4e124872da6c2f632bfed957e9")] + data2 = [a2b_hex(b'0b' * 16), b"Hi There", + a2b_hex("675b0b3a1b4ddf4e124872da6c2f632bfed957e9")] - data3 = ['Jefe', "what do ya want for nothing?", - h2b("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")] + data3 = [b'Jefe', b"what do ya want for nothing?", + a2b_hex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")] - data4 = [h2b('aa' * 16), h2b('dd' * 50), - h2b("d730594d167e35d5956fd8003d0db3d3f46dc7bb")] + data4 = [a2b_hex(b'aa' * 16), a2b_hex(b'dd' * 50), + a2b_hex("d730594d167e35d5956fd8003d0db3d3f46dc7bb")] data = [data1, data2, data3, data4] |