From 38740f9a0483ac20691c9809670a1d3238c709af Mon Sep 17 00:00:00 2001 From: Tatiana Leon Date: Fri, 24 Mar 2017 19:37:24 +0100 Subject: [PATCH] trustfence: get bytes from the console passphrase to feed the hash method In Python 3, feeding string objects into hash method is not supported. Hashes work on bytes, not on characters. So we use 'encode()' on the passphrase to get the bytes object. See: * https://docs.python.org/3/howto/pyporting.html#text-versus-binary-data * https://docs.python.org/3/library/hashlib.html#module-hashlib This commit fixes build failures as: Exception: TypeError: Unicode-objects must be encoded before hashing https://jira.digi.com/browse/DEL-3984 Signed-off-by: Tatiana Leon --- meta-digi-dey/classes/trustfence.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-digi-dey/classes/trustfence.bbclass b/meta-digi-dey/classes/trustfence.bbclass index d86f3dcfc..9f1606cc2 100644 --- a/meta-digi-dey/classes/trustfence.bbclass +++ b/meta-digi-dey/classes/trustfence.bbclass @@ -40,7 +40,7 @@ python () { if (d.getVar("TRUSTFENCE_CONSOLE_DISABLE", True) == "1"): d.appendVar("UBOOT_EXTRA_CONF", "CONFIG_CONSOLE_DISABLE=y ") if d.getVar("TRUSTFENCE_CONSOLE_PASSPHRASE_ENABLE", True): - passphrase_hash = hashlib.sha256(d.getVar("TRUSTFENCE_CONSOLE_PASSPHRASE_ENABLE", True)).hexdigest() + passphrase_hash = hashlib.sha256(d.getVar("TRUSTFENCE_CONSOLE_PASSPHRASE_ENABLE", True).encode()).hexdigest() d.appendVar("UBOOT_EXTRA_CONF", 'CONFIG_CONSOLE_ENABLE_PASSPHRASE=y CONFIG_CONSOLE_ENABLE_PASSPHRASE_KEY=\\"%s\\" ' % passphrase_hash) elif d.getVar("TRUSTFENCE_CONSOLE_GPIO_ENABLE", True): d.appendVar("UBOOT_EXTRA_CONF", " CONFIG_CONSOLE_ENABLE_GPIO=y CONFIG_CONSOLE_ENABLE_GPIO_NR=%s " % d.getVar("TRUSTFENCE_CONSOLE_GPIO_ENABLE", True))