Skip to content

Commit

Permalink
as py3x base64.b64encode() returns unicode which needs to be decoded
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Mieslinger committed Jun 8, 2021
1 parent df3ec5e commit dc7124a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions dim/dim/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def generate_RSASHA256_key_pair(bits):
for field in ['n', 'e', 'd', 'p', 'q', 'u']:
f = getattr(key, field)
f = Crypto.Util.number.long_to_bytes(f)
keydata[field] = base64.b64encode(f)
keydata[field] = base64.b64encode(f).decode('utf-8')
dmp1 = Crypto.Util.number.long_to_bytes(key.d % (key.p - 1))
keydata['dmp1'] = base64.b64encode(dmp1)
keydata['dmp1'] = base64.b64encode(dmp1).decode('utf-8')
dmq1 = Crypto.Util.number.long_to_bytes(key.d % (key.q - 1))
keydata['dmq1'] = base64.b64encode(dmq1)
keydata['dmq1'] = base64.b64encode(dmq1).decode('utf-8')
# key.u == inverse(p, q), but rfc3447 needs inverse(q, p)
u = Crypto.Util.number.long_to_bytes(inverse(key.q, key.p))
keydata['u'] = base64.b64encode(u)
keydata['u'] = base64.b64encode(u).decode('utf-8')
privkey = _file_privkey_rsa % keydata
return (pubkey, privkey)
2 changes: 1 addition & 1 deletion dim/dim/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '4.0.1'
VERSION = '4.0.2'

0 comments on commit dc7124a

Please sign in to comment.