2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-02-27 15:50:24 +00:00

Fix grub hash bytes

In python3, need to coerce the strings
to str or else end up with invalid grub password.
This commit is contained in:
Jarrod Johnson 2020-06-04 10:27:55 -04:00
parent d17a2054d4
commit f505b3ad16

View File

@ -495,6 +495,10 @@ def grub_hashcrypt_value(value):
crypted = hexlify(hashlib.pbkdf2_hmac(algo, value, salt, rounds))
crypted = crypted.upper()
salt = hexlify(salt).upper()
if not isinstance(salt, str):
salt = salt.decode('utf8')
if not isinstance(crypted, str):
crypted = crypted.decode('utf8')
ret = 'grub.pbkdf2.{0}.{1}.{2}.{3}'.format(algo, rounds, salt, crypted)
return ret