Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable python 3 testing #328

Merged
merged 2 commits into from
Nov 27, 2019

Conversation

williamcroberts
Copy link
Member

Figured out the issue, for details see commit messages and etingof/pyasn1#185

Copy link
Member

@diabonas diabonas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For full Python 3 compatibility, you also need the following two changes:

diff --git a/tools/tpm2_pkcs11/commandlets_keys.py b/tools/tpm2_pkcs11/commandlets_keys.py
index d9b6c4b..066a67d 100644
--- a/tools/tpm2_pkcs11/commandlets_keys.py
+++ b/tools/tpm2_pkcs11/commandlets_keys.py
@@ -518,7 +518,7 @@ class AddCert(Command):
 
         path = args['path']
         label = args['label']
-        keylabel = args['key_label']
+        keylabel = args['key_label'].encode()
         certpath = args['cert']
 
         # rather than use pycryptography x509 parser, which gives native type access to certficiate
@@ -531,7 +531,7 @@ class AddCert(Command):
 
         # print(cert.prettyPrint())
 
-        h = binascii.hexlify
+        h = lambda b : binascii.hexlify(b).decode()
         b = berenc.encode
         d = derenc.encode
 

python2 and python3 differ in behavior on reading from a file that was
opened with the binary flag. In python2 the read data is a str, in
python3 its bytes. This is posing an issue in the asn1 calls as outlined
in bug:
  - etingof/pyasn1#185

We can work around this for now, since pem files are always string,
remove the binary flag and open pem w/o binary mode flag

Additionally, python3 and python 2 differe in handling str and bytes and
python3 requires more type correctness. Fix all this in a way that works
with python2 and python3

Releates to bug tpm2-software#327

Signed-off-by: William Roberts <william.c.roberts@intel.com>
@williamcroberts
Copy link
Member Author

Yeah I go those today

This reverts commit 0d92fce.

Fixes: tpm2-software#327
Signed-off-by: William Roberts <william.c.roberts@intel.com>
@codecov
Copy link

codecov bot commented Nov 27, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@3bdeb65). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #328   +/-   ##
=========================================
  Coverage          ?   76.81%           
=========================================
  Files             ?       25           
  Lines             ?     4921           
  Branches          ?        0           
=========================================
  Hits              ?     3780           
  Misses            ?     1141           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3bdeb65...b478853. Read the comment docs.

@williamcroberts williamcroberts merged commit b3976db into tpm2-software:master Nov 27, 2019
@williamcroberts williamcroberts deleted the cert-support branch December 9, 2019 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants