Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 May 2019 00:30:29 +0000 (UTC)
From:      Enji Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348024 - head/tests/sys/opencrypto
Message-ID:  <201905210030.x4L0UTVJ079092@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Tue May 21 00:30:29 2019
New Revision: 348024
URL: https://svnweb.freebsd.org/changeset/base/348024

Log:
  Followup to r347996
  
  Replace uses of `foo.encode("hex")` with `binascii.hexlify(foo)` for forwards
  compatibility between python 2.x and python 3.
  
  PR:		237403
  MFC after:	1 week

Modified:
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptotest.py
==============================================================================
--- head/tests/sys/opencrypto/cryptotest.py	Tue May 21 00:07:53 2019	(r348023)
+++ head/tests/sys/opencrypto/cryptotest.py	Tue May 21 00:30:29 2019	(r348024)
@@ -262,7 +262,7 @@ def GenTestCase(cname):
                 out = r + tag
                 self.assertEqual(out, ct,
                     "Count " + data['Count'] + " Actual: " + \
-                    repr(out.encode("hex")) + " Expected: " + \
+                    repr(binascii.hexlify(out)) + " Expected: " + \
                     repr(data) + " on " + cname)
 
         def runCCMDecrypt(self, fname):
@@ -313,7 +313,7 @@ def GenTestCase(cname):
                     payload = payload[:plen]
                     self.assertEqual(r, payload,
                         "Count " + data['Count'] + \
-                        " Actual: " + repr(r.encode("hex")) + \
+                        " Actual: " + repr(binascii.hexlify(r)) + \
                         " Expected: " + repr(data) + \
                         " on " + cname)
 
@@ -405,7 +405,7 @@ def GenTestCase(cname):
                     _, r = c.encrypt(msg, iv="")
 
                     self.assertEqual(r, md, "Actual: " + \
-                        repr(r.encode("hex")) + " Expected: " + repr(data) + " on " + cname)
+                        repr(binascii.hexlify(r)) + " Expected: " + repr(data) + " on " + cname)
 
         @unittest.skipIf(cname not in shamodules, 'skipping SHA-HMAC on %s' % str(cname))
         def test_sha1hmac(self):
@@ -462,7 +462,7 @@ def GenTestCase(cname):
                     _, r = c.encrypt(msg, iv="")
 
                     self.assertEqual(r[:tlen], mac, "Actual: " + \
-                        repr(r.encode("hex")) + " Expected: " + repr(data))
+                        repr(binascii.hexlify(r)) + " Expected: " + repr(data))
 
     return GendCryptoTestCase
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905210030.x4L0UTVJ079092>