From owner-svn-src-user@freebsd.org Tue May 21 02:02:10 2019 Return-Path: <owner-svn-src-user@freebsd.org> Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32003159AC8C for <svn-src-user@mailman.ysv.freebsd.org>; Tue, 21 May 2019 02:02:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C65A16EC4B; Tue, 21 May 2019 02:02:09 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 96CEE26F79; Tue, 21 May 2019 02:02:09 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4L229Yp031804; Tue, 21 May 2019 02:02:09 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4L2297K031803; Tue, 21 May 2019 02:02:09 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201905210202.x4L2297K031803@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper <ngie@FreeBSD.org> Date: Tue, 21 May 2019 02:02:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r348030 - user/ngie/bug-237403/tests/sys/opencrypto X-SVN-Group: user X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: user/ngie/bug-237403/tests/sys/opencrypto X-SVN-Commit-Revision: 348030 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C65A16EC4B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" <svn-src-user.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-user>, <mailto:svn-src-user-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user/> List-Post: <mailto:svn-src-user@freebsd.org> List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-user>, <mailto:svn-src-user-request@freebsd.org?subject=subscribe> X-List-Received-Date: Tue, 21 May 2019 02:02:10 -0000 Author: ngie Date: Tue May 21 02:02:09 2019 New Revision: 348030 URL: https://svnweb.freebsd.org/changeset/base/348030 Log: Fix remaining encoding issues with python 3 * Cast all unicode strings to bytes arrays before passing them through to `fcntl.ioctl`, as the string width of unicode strings is different and not downcast to bytes when passed to `fcntl.ioctl`. * Use `array.array(..).tobytes()` instead of `array.array(..).tostring()` in python 3.2+, per the deprecation warning printed out by python 3.6 when the code is evaluated. Modified: user/ngie/bug-237403/tests/sys/opencrypto/cryptodev.py Modified: user/ngie/bug-237403/tests/sys/opencrypto/cryptodev.py ============================================================================== --- user/ngie/bug-237403/tests/sys/opencrypto/cryptodev.py Tue May 21 01:56:26 2019 (r348029) +++ user/ngie/bug-237403/tests/sys/opencrypto/cryptodev.py Tue May 21 02:02:09 2019 (r348030) @@ -153,6 +153,11 @@ def _findop(crid, name): return fop.crid, name +def array_tobytes(array_obj): + if sys.version_info[:2] >= (3, 2): + return array_obj.tobytes() + return array_obj.tostring() + class Crypto: @staticmethod def findcrid(name): @@ -224,12 +229,13 @@ class Crypto: ivbuf = array.array('B', self._to_bytes(iv)) cop.iv = ivbuf.buffer_info()[0] - #print('cop:', cop) - ioctl(_cryptodev, CIOCCRYPT, str(cop)) + cop_b = bytes(cop) + #print('cop:', cop_b) + ioctl(_cryptodev, CIOCCRYPT, cop_b) - s = s.tostring() + s = array_tobytes(s) if self._maclen is not None: - return s, m.tostring() + return s, array_tobytes(m) return s @@ -265,11 +271,12 @@ class Crypto: caead.ivlen = len(iv) caead.iv = ivbuf.buffer_info()[0] - ioctl(_cryptodev, CIOCCRYPTAEAD, self._to_bytes(str(caead))) + caead_b = bytes(caead) + ioctl(_cryptodev, CIOCCRYPTAEAD, caead_b) - s = s.tostring() + s = array_tobytes(s) - return s, tag.tostring() + return s, array_tobytes(tag) def perftest(self, op, size, timeo=3): inp = array.array('B', (random.randint(0, 255) for x in range(size))) @@ -299,8 +306,9 @@ class Crypto: start = time.time() reps = 0 + cop_b = bytes(cop) while not exit[0]: - ioctl(_cryptodev, CIOCCRYPT, self._to_bytes(str(cop))) + ioctl(_cryptodev, CIOCCRYPT, cop_b) reps += 1 end = time.time()