Skip to content

Commit

Permalink
Fix user_data_encrypt to UTF8 decode before print
Browse files Browse the repository at this point in the history
Reproducible on Ubuntu 20.04 (Python 3.8.5)

$ keylime_userdata_encrypt secret.bin
Writing keys to content_keys.txt
Traceback (most recent call last):
File "/usr/local/bin/keylime_userdata_encrypt", line 8, in
sys.exit(main())
File "/home/ens/.local/lib/python3.8/site-packages/keylime/cmd/user_data_encrypt.py", line 53, in main
f.write(base64.b64encode(ret['k']))
TypeError: write() argument must be str, not bytes

Patch from Ilhan Gurel ([email protected])

Signed-off-by: Michael Peters <[email protected]>
  • Loading branch information
mpeters committed Apr 26, 2021
1 parent d6cb0db commit 36ea41c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions keylime/cmd/user_data_encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ def main(argv=sys.argv):

print("Writing keys to content_keys.txt")
f = open('content_keys.txt', 'w')
f.write(base64.b64encode(ret['k']))
f.write(base64.b64encode(ret['k'].decode('utf-8')))
f.write('\n')
f.write(base64.b64encode(ret['v']))
f.write(base64.b64encode(ret['v'].decode('utf-8')))
f.write('\n')
f.write(base64.b64encode(ret['u']))
f.write(base64.b64encode(ret['u'].decode('utf-8')))
f.write('\n')
f.close()

print("Writing encrypted data to content_payload.txt")
f = open('content_payload.txt', 'w')
f.write(ret['ciphertext'])
f.write(ret['ciphertext'].decode('utf-8'))
f.close()


Expand Down

0 comments on commit 36ea41c

Please sign in to comment.