Date: Sat, 20 Apr 2019 09:15:55 -0700 From: Enji Cooper <yaneurabeya@gmail.com> To: Enji Cooper <ngie@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r346449 - user/ngie/bug-237403/tests/sys/opencrypto Message-ID: <D1FA77DB-4986-4096-85FF-2AEF50B89D14@gmail.com> In-Reply-To: <201904201607.x3KG7m4A051487@repo.freebsd.org> References: <201904201607.x3KG7m4A051487@repo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
> On Apr 20, 2019, at 9:07 AM, Enji Cooper <ngie@FreeBSD.org> wrote: > > Author: ngie > Date: Sat Apr 20 16:07:47 2019 > New Revision: 346449 > URL: https://svnweb.freebsd.org/changeset/base/346449 > > Log: > Replace `str.{decode,encode}("hex")` with binascii.(un)?hexlify > > Encoding/decoding base_string objects as "hex" was removed in py3 and replaced > with other methods, one being `binascii.(un)?hexlify`. I accidentally introduced other changes in this commit to cryptodev.py. Summary is as follows: Py3 changed the default text encoding from ascii strings to Unicode strings, which requires converting a number of code which working previously with ascii to use byte (ascii binary, e.g., b’' prefixed) strings. In order to convert between ascii binary and unicode strings (which some of the dpkt/crypto APIs require), one must use the .decode/.encode methods, as described in the Unicode guide: https://docs.python.org/3/howto/unicode.html. This change introduces a work-in-progress item to use .decode/.encode in cryptodev.py . It’s not 100% complete, so the tests fail when converting objects to/from str/bytes objects, like shown below. Cheers, -Enji $ sudo kyua debug -k /usr/tests/sys/opencrypto/Kyuafile runtests:main 2>&1 | less ====================================================================== ERROR: test_gcm (__main__.GenTestCase.<locals>.GendCryptoTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/tests/sys/opencrypto/cryptotest.py", line 77, in test_gcm self.runGCM(i, 'ENCRYPT') File "/usr/tests/sys/opencrypto/cryptotest.py", line 126, in runGCM rct, rtag = c.encrypt(pt, iv, aad) File "/usr/tests/sys/opencrypto/cryptodev.py", line 305, in encrypt iv) File "/usr/tests/sys/opencrypto/cryptodev.py", line 232, in _doaead s = array.array('B', src.encode("ascii")) AttributeError: 'bytes' object has no attribute ‘encode' ... ====================================================================== ERROR: test_gcm (__main__.GenTestCase.<locals>.GendCryptoTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/tests/sys/opencrypto/cryptotest.py", line 77, in test_gcm self.runGCM(i, 'ENCRYPT') File "/usr/tests/sys/opencrypto/cryptotest.py", line 126, in runGCM rct, rtag = c.encrypt(pt, iv, aad) File "/usr/tests/sys/opencrypto/cryptodev.py", line 305, in encrypt iv) File "/usr/tests/sys/opencrypto/cryptodev.py", line 232, in _doaead s = array.array('B', src.encode("ascii")) AttributeError: 'bytes' object has no attribute 'encode'help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D1FA77DB-4986-4096-85FF-2AEF50B89D14>
