summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYi Zhao <yi.zhao@windriver.com>2021-08-20 17:42:36 +0800
committerJia Zhang <zhang.jia@linux.alibaba.com>2021-08-20 18:36:08 +0800
commitb988150cf341cdcad4d6eee7c3648666996867b4 (patch)
tree1e765f178d395244408fb185d210087407180b2d
parent62b388cf72d90bef74f08fbfdd40acdf1f3d56f3 (diff)
downloadmeta-secure-core-b988150cf341cdcad4d6eee7c3648666996867b4.tar.gz
cryptfs-tpm2: fix encrypt_secret.py for python3
Fixes: encrypt_secret.py -i "H31i05" > "primary_key.secret" || exit 1 ERROR: Unable to encrypt the secret Suggested-by: Kai Kang <kai.kang@windriver.com> Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
-rw-r--r--meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2/0001-encrypt_secret.py-fix-for-python3.patch56
-rw-r--r--meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2_git.bb1
2 files changed, 57 insertions, 0 deletions
diff --git a/meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2/0001-encrypt_secret.py-fix-for-python3.patch b/meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2/0001-encrypt_secret.py-fix-for-python3.patch
new file mode 100644
index 0000000..c029e26
--- /dev/null
+++ b/meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2/0001-encrypt_secret.py-fix-for-python3.patch
@@ -0,0 +1,56 @@
1From bfdfa6aea6f0c4ca5b075d172ef510899af01962 Mon Sep 17 00:00:00 2001
2From: Yi Zhao <yi.zhao@windriver.com>
3Date: Fri, 20 Aug 2021 17:34:42 +0800
4Subject: [PATCH] encrypt_secret.py: fix for python3
5
6Fixes:
7encrypt_secret.py -i "H31i05" > "primary_key.secret" || exit 1
8ERROR: Unable to encrypt the secret
9
10Upstream-Status: Pending
11
12Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
13---
14 scripts/encrypt_secret.py.in | 16 +++++++++-------
15 1 file changed, 9 insertions(+), 7 deletions(-)
16
17diff --git a/scripts/encrypt_secret.py.in b/scripts/encrypt_secret.py.in
18index ffd3213..e739183 100755
19--- a/scripts/encrypt_secret.py.in
20+++ b/scripts/encrypt_secret.py.in
21@@ -15,23 +15,25 @@ class Secret():
22 def encrypt(self, input):
23 _ = SECRET_XOR_BYTE_CODE
24
25- input = bytes(input)
26+ input = bytes(input, 'utf-8')
27 out = str()
28- for b in input:
29+ for i in input:
30+ b = bytes([i])
31 b = struct.unpack('<1B', b)[0]
32 _ = b ^ _
33- out = out + struct.pack('<1B', _)
34+ out = out + struct.pack('<1B', _).decode('utf-8')
35
36 return out
37-
38+
39 def decrypt(self, input):
40 _ = SECRET_XOR_BYTE_CODE
41
42- input = bytes(input)
43+ input = bytes(input, 'utf-8')
44 out = str()
45- for b in input:
46+ for i in input:
47+ b = bytes([i])
48 b = struct.unpack('<1B', b)[0]
49- out = out + struct.pack('<1B', b ^ _)
50+ out = out + struct.pack('<1B', b ^ _).decode('utf-8')
51 _ = b
52
53 return out
54--
552.25.1
56
diff --git a/meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2_git.bb b/meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2_git.bb
index e0ba90c..f80880f 100644
--- a/meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2_git.bb
+++ b/meta-encrypted-storage/recipes-tpm/cryptfs-tpm2/cryptfs-tpm2_git.bb
@@ -27,6 +27,7 @@ SRC_URI = "\
27 file://0001-lib-Makefile-set-correct-soname-for-libcryptfs-tpm2.patch \ 27 file://0001-lib-Makefile-set-correct-soname-for-libcryptfs-tpm2.patch \
28 file://0001-Remove-build-time-from-show_banner.patch \ 28 file://0001-Remove-build-time-from-show_banner.patch \
29 file://0001-env.mk-fix-LDFLAGS-expansion.patch \ 29 file://0001-env.mk-fix-LDFLAGS-expansion.patch \
30 file://0001-encrypt_secret.py-fix-for-python3.patch \
30" 31"
31SRCREV = "87c35c63090a33d4de437f518b8da9f2d1f1d828" 32SRCREV = "87c35c63090a33d4de437f518b8da9f2d1f1d828"
32 33