package/python-pycryptodomex: add host variant
PATCH 1/6 package/python-pycryptodomex: add host variant
Adding a host variant allow to replace host-python-pycrypto by host-python-pycryptodomex for crda and optee-os packages.
From [1]:
"PyCryptodome is a fork of PyCrypto, which is not maintained any more (the last release dates back to 2013 [2]). It exposes almost the same API, but there are a few incompatibilities [3]."
[1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0
[2] https://pypi.org/project/pycrypto/#history
[3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.html
---
For master and 2020.02.x.
--- package/python-pycryptodomex/python-pycryptodomex.mk | 1 + 1 file changed, 1 insertion(+)
package/python-pycryptodomex/python-pycryptodomex.mk +1 -0
@@ -15,3 +15,4 @@ PYTHON_PYCRYPTODOMEX_LICENSE = \ PYTHON_PYCRYPTODOMEX_LICENSE_FILES = LICENSE.rst Doc/LEGAL/COPYRIGHT.pycrypto $(eval $(python-package)) +$(eval $(host-python-package))
Signature · 1 line
2.25.3
PATCH 2/6 package/crda: replace pycrypto by pycryptodomex
From [1]:
"PyCryptodome is a fork of PyCrypto, which is not maintained any more (the last release dates back to 2013 [2]). It exposes almost the same API, but there are a few incompatibilities [3]."
[1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0
[2] https://pypi.org/project/pycrypto/#history
[3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.html
Update the patch 0001-crda-support-python-3-in-utils-key2pub.py.patch since it add pycrypto.
From [4]
"CRDA is no longer needed as of kernel v4.15 since commit 007f6c5e6eb45 ("cfg80211: support loading regulatory database as firmware file") added support to use the kernel's firmware request API which looks for the firmware on /lib/firmware. Because of this CRDA is legacy software for older kernels. It will continue to be maintained."
--- ...support-python-3-in-utils-key2pub.py.patch | 32 ++++++++++++------- package/crda/crda.mk | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-)
package/crda/0001-crda-support-python-3-in-utils-key2pub.py.patch +21 -11
@@ -1,11 +1,11 @@ -From 4c346aa9e816bddfedc8ac99809fd1ed91bfc8ee Mon Sep 17 00:00:00 2001 +From 8228c484a1533ff904b276c342adcb6310abe272 Mon Sep 17 00:00:00 2001 From: Taahir Ahmed <[email protected]> Date: Wed, 30 Mar 2016 11:23:54 -0300 Subject: [PATCH] crda: support python 3 in utils/key2pub.py utils/key2pub.py can now be run under either python 2.7 or python 3.x. This required some minor syntactical changes as well as switching from -M2Crypto to pycrypto, since M2Crypto doesn't support python 3.x. +M2Crypto to pycryptodomex, since M2Crypto doesn't support python 3.x. In addition, some errors in the generated source file keys-ssl.h are fixed:
@@ -17,12 +17,22 @@ fixed: [Gustavo: don't call /utils/key2pub.py since that doesn't compute] +Use pycryptodomex insdead of pycrypto + +From [1]: +"PyCryptodome is a fork of PyCrypto, which is not maintained any more +(the last release dates back to 2013 [2]). It exposes almost the same +API, but there are a few incompatibilities [3]." + +[1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0 +[2] https://pypi.org/project/pycrypto/#history +[3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.html + Signed-off-by: Gustavo Zacarias <[email protected]> [Rebased against crda-4.14] Signed-off-by: Peter Seiderer <[email protected]> ---- -Status: submitted upstream by author but not (yet) accepted -URL: http://www.spinics.net/lists/linux-wireless/msg138936.html +[Romain: Use pycryptodomex] +Signed-off-by: Romain Naour <[email protected]> --- Makefile | 2 +- utils/key2pub.py | 146 ++++++++++++++++++++++++-----------------------
@@ -42,7 +52,7 @@ index a3ead30..8da38d0 100644 $(LIBREG): regdb.h reglib.h reglib.c $(NQ) ' CC ' $@ diff --git a/utils/key2pub.py b/utils/key2pub.py -index 9bb04cd..9f92ebd 100755 +index 9bb04cd..8a0ba2a 100755 --- a/utils/key2pub.py +++ b/utils/key2pub.py @@ -1,126 +1,128 @@
@@ -57,11 +67,11 @@ index 9bb04cd..9f92ebd 100755 - sys.stderr.write('Please install the "M2Crypto" Python module.\n') - sys.stderr.write('On Debian GNU/Linux the package is called "python-m2crypto".\n') - sys.exit(1) -+ from Crypto.PublicKey import RSA ++ from Cryptodome.PublicKey import RSA +except ImportError as e: -+ sys.stderr.write('ERROR: Failed to import the "Crypto.PublicKey" module: %s\n' % e.message) -+ sys.stderr.write('Please install the "Crypto.PublicKey" Python module.\n') -+ sys.stderr.write('On Debian GNU/Linux the package is called "python-crypto".\n') ++ sys.stderr.write('ERROR: Failed to import the "Cryptodome.PublicKey" module: %s\n' % e.message) ++ sys.stderr.write('Please install the "Cryptodome.PublicKey" Python module.\n') ++ sys.stderr.write('On Debian GNU/Linux the package is called "python-cryptodomex".\n') + sys.exit(1) + +def bitwise_collect(value, radix_bits):
@@ -269,5 +279,5 @@ index 9bb04cd..9f92ebd 100755 modes[mode][1](output, idx - 1) -- -2.18.0 +2.25.3
package/crda/crda.mk +1 -1
@@ -6,7 +6,7 @@ CRDA_VERSION = 4.14 CRDA_SITE = https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/crda.git/snapshot -CRDA_DEPENDENCIES = host-pkgconf host-python-pycrypto libnl libgcrypt +CRDA_DEPENDENCIES = host-pkgconf host-python-pycryptodomex libnl libgcrypt CRDA_LICENSE = ISC CRDA_LICENSE_FILES = LICENSE
Signature · 1 line
2.25.3
PATCH 2/6 package/crda: replace pycrypto by pycryptodomex
Quoted 21 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Romain" == Romain Naour <[email protected]> writes:
From [1]:
"PyCryptodome is a fork of PyCrypto, which is not maintained any more (the last release dates back to 2013 [2]). It exposes almost the same API, but there are a few incompatibilities [3]."[1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0
[2] https://pypi.org/project/pycrypto/#history
[3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.htmlUpdate the patch 0001-crda-support-python-3-in-utils-key2pub.py.patch since it add pycrypto.
From [4]
"CRDA is no longer needed as of kernel v4.15 since commit007f6c5e6eb45("cfg80211: support loading regulatory database as firmware file") added support to use the kernel's firmware request API which looks for the firmware on/lib/firmware. Because of this CRDA is legacy software for older kernels. It will continue to be maintained."
Quoted 4 lines
Signed-off-by Romain Naour <[email protected]>Cc James Hilliard <[email protected]>
Committed to 2020.02.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 3/6 boot/optee-os: replace pycrypto by pycryptodomex
In reply to Romain NaourFrom [1] included in optee-os release 3.7.0:
"PyCryptodome is a fork of PyCrypto, which is not maintained any more (the last release dates back to 2013 [2]). It exposes almost the same API, but there are a few incompatibilities [3]."
pem_to_pub_c.py/sign.py scripts still use pycrypto that is replaced by pycryptodomex. Add a patch to use pycryptodomex but don't use upstream commit since it also switches from the algorithm TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 to TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256 when replacing pycrypto to pycryptodomex [4].
[1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0
[2] https://pypi.org/project/pycrypto/#history
[3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.html
[4] https://github.com/OP-TEE/optee_os/commit/ababd72d2fd76cb2ded8e202b49db28d6545f6eb
Fixes:
https://gitlab.com/buildroot.org/buildroot/-/jobs/526035730
---
For master and 2020.02.x.
--- ...o_pub_c.py-sign.py-use-pycryptodomex.patch | 64 +++++++++++++++++++ boot/optee-os/optee-os.mk | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 boot/optee-os/0001-scripts-pem_to_pub_c.py-sign.py-use-pycryptodomex.patch
boot/optee-os/0001-scripts-pem_to_pub_c.py-sign.py-use-pycryptodomex.patch new file +64 -0
@@ -0,0 +1,64 @@ +From 06e71feaeb08349abe56b50c3dfb08a8341cf55f Mon Sep 17 00:00:00 2001 +From: Romain Naour <[email protected]> +Date: Sun, 26 Apr 2020 21:55:55 +0200 +Subject: [PATCH] scripts/pem_to_pub_c.py/sign.py: use pycryptodomex + +These scripts still use pycrypto. + +From [1]: +"PyCryptodome is a fork of PyCrypto, which is not maintained any more +(the last release dates back to 2013 [2]). It exposes almost the same +API, but there are a few incompatibilities [3]." + +Don't use upstream commit since it also switches from the algorithm +TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 to TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256 +when replacing pycrypto to pycryptodomex [4]. + +[1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0 +[2] https://pypi.org/project/pycrypto/#history +[3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.html +[4] https://github.com/OP-TEE/optee_os/commit/ababd72d2fd76cb2ded8e202b49db28d6545f6eb + +Signed-off-by: Romain Naour <[email protected]> +--- + scripts/pem_to_pub_c.py | 4 ++-- + scripts/sign.py | 8 ++++---- + 2 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/scripts/pem_to_pub_c.py b/scripts/pem_to_pub_c.py +index 3a896a39..d3f0e500 100755 +--- a/scripts/pem_to_pub_c.py ++++ b/scripts/pem_to_pub_c.py +@@ -21,8 +21,8 @@ def get_args(): + + def main(): + import array +- from Crypto.PublicKey import RSA +- from Crypto.Util.number import long_to_bytes ++ from Cryptodome.PublicKey import RSA ++ from Cryptodome.Util.number import long_to_bytes + + args = get_args() + +diff --git a/scripts/sign.py b/scripts/sign.py +index 2939c591..80ce2e9f 100755 +--- a/scripts/sign.py ++++ b/scripts/sign.py +@@ -121,10 +121,10 @@ def get_args(logger): + + + def main(): +- from Crypto.Signature import PKCS1_v1_5 +- from Crypto.Hash import SHA256 +- from Crypto.PublicKey import RSA +- from Crypto.Util.number import ceil_div ++ from Cryptodome.Signature import PKCS1_v1_5 ++ from Cryptodome.Hash import SHA256 ++ from Cryptodome.PublicKey import RSA ++ from Cryptodome.Util.number import ceil_div + import base64 + import logging + import os +-- +2.25.3 +
boot/optee-os/optee-os.mk +1 -1
@@ -21,7 +21,7 @@ else OPTEE_OS_SITE = $(call github,OP-TEE,optee_os,$(OPTEE_OS_VERSION)) endif -OPTEE_OS_DEPENDENCIES = host-openssl host-python-pycrypto host-python-pyelftools +OPTEE_OS_DEPENDENCIES = host-openssl host-python-pycryptodomex host-python-pyelftools # On 64bit targets, OP-TEE OS can be built in 32bit mode, or # can be built in 64bit mode and support 32bit and 64bit
Signature · 1 line
2.25.3
PATCH 4/6 package/python-pycrypto: remove package
In reply to Romain NaourThis package doesn't work with Python 3.8 since the code contains time.clock() that was deprecated in Python 3.3 and removed in Python 3.8.
Instead of applying non upstream patches from Fedora [1], python-pycrypto was replaced by python-pycryptodomex for crda and optee-os package. Now we can remove safely this package.
[1] http://lists.busybox.net/pipermail/buildroot/2020-April/280683.html
Fixes:
https://gitlab.com/buildroot.org/buildroot/-/jobs/498144209
--- Config.in.legacy | 7 +++ package/Config.in | 1 - .../0001-remove-incorrect-header-path.patch | 21 -------- package/python-pycrypto/Config.in | 8 --- package/python-pycrypto/python-pycrypto.hash | 7 --- package/python-pycrypto/python-pycrypto.mk | 49 ------------------- 6 files changed, 7 insertions(+), 86 deletions(-) delete mode 100644 package/python-pycrypto/0001-remove-incorrect-header-path.patch delete mode 100644 package/python-pycrypto/Config.in delete mode 100644 package/python-pycrypto/python-pycrypto.hash delete mode 100644 package/python-pycrypto/python-pycrypto.mk
Config.in.legacy +7 -0
@@ -146,6 +146,13 @@ endif comment "Legacy options removed in 2020.05" +config BR2_PACKAGE_PYTHON_PYCRYPTO + bool "python-pycrypto package removed" + select BR2_LEGACY + help + This package has been removed, use python-pycryptodomex + instead. + config BR2_PACKAGE_COLLECTD_LVM bool "lvm support in collectd was removed" select BR2_LEGACY
package/Config.in +0 -1
@@ -1074,7 +1074,6 @@ menu "External python modules" source "package/python-pycares/Config.in" source "package/python-pycli/Config.in" source "package/python-pycparser/Config.in" - source "package/python-pycrypto/Config.in" source "package/python-pycryptodomex/Config.in" source "package/python-pydal/Config.in" source "package/python-pydantic/Config.in"
package/python-pycrypto/0001-remove-incorrect-header-path.patch deleted +0 -21
@@ -1,21 +0,0 @@ -Do not use /usr/include for headers - -Using /usr/include is wrong when doing cross-compilation, so get rid -of it, and rely on the compiler to use the appropriate default paths -for headers. - -Signed-off-by: Thomas Petazzoni <[email protected]> - -Index: b/setup.py -=================================================================== ---- a/setup.py -+++ b/setup.py -@@ -370,7 +370,7 @@ - 'ext_modules': plat_ext + [ - # _fastmath (uses GNU mp library) - Extension("Crypto.PublicKey._fastmath", -- include_dirs=['src/','/usr/include/'], -+ include_dirs=['src/'], - libraries=['gmp'], - sources=["src/_fastmath.c"]), -
package/python-pycrypto/Config.in deleted +0 -8
@@ -1,8 +0,0 @@ -config BR2_PACKAGE_PYTHON_PYCRYPTO - bool "python-pycrypto" - select BR2_PACKAGE_GMP - help - PyCrypto is a collection of cryptographic algorithms and - protocols, implemented for use from Python. - - http://www.pycrypto.org/
package/python-pycrypto/python-pycrypto.hash deleted +0 -7
@@ -1,7 +0,0 @@ -# Locally calculated after checking pgp signature -sha256 f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c pycrypto-2.6.1.tar.gz -# Locally computed -sha256 15925a98d05c6d086c30943e4eacdbd361bcf76daa109b6e6dfc9d0c4ad9ed64 COPYRIGHT -sha256 10c41e1aaf84bd3546d1ff7ef89454817744fd2c18cdd80a137e802095448016 LEGAL/copy/LICENSE.libtom -sha256 253a271c681cd4b3f9503659fe754ee305efe68ebb6e8733b7f436d73845a32c LEGAL/copy/LICENSE.python-2.2 -sha256 96f9a25274a59843715a26986e4a2427c312a1d86b9207f26fcafcea47a417fe LEGAL/copy/LICENSE.original
package/python-pycrypto/python-pycrypto.mk deleted +0 -49
49 lines not on this page · raw message
Signature · 1 line
2.25.3
PATCH 4/6 package/python-pycrypto: remove package
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Romain" == Romain Naour <[email protected]> writes:
This package doesn't work with Python 3.8 since the code contains
time.clock()that was deprecated in Python 3.3 and removed in Python 3.8.Instead of applying non upstream patches from Fedora [1], python-pycrypto was replaced by python-pycryptodomex for crda and optee-os package. Now we can remove safely this package.
Quoted 7 lines
[1] http://lists.busybox.net/pipermail/buildroot/2020-April/280683.html
Fixes:
https://gitlab.com/buildroot.org/buildroot/-/jobs/498144209Signed-off-by Romain Naour <[email protected]>Cc James Hilliard <[email protected]>
Committed to 2020.02.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 5/6 board/qemu/post-image.sh: start from a shell
In reply to Romain NaourUsually the qemu command line start directly with "qemu-system-<arch> ...". But the command line for qemu_arm_vexpress_tz_defconfig start by doing "cd output/images && ../host/bin/qemu-system-arm". This is necessary since boot binaries, except BL1, are primarily loaded via semi-hosting so all binaries has to reside in the same directory as QEMU is started from [1].
The start-qemu.sh script fail to start qemu since it use exec on the "cd" command. To work around this issue, use "exec sh -c":
exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}"
--- board/qemu/post-image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/qemu/post-image.sh +1 -1
@@ -49,7 +49,7 @@ cat <<-_EOF_ > "${START_QEMU_SCRIPT}" fi export PATH="${HOST_DIR}/bin:\${PATH}" - exec ${QEMU_CMD_LINE} \${EXTRA_ARGS} + exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}" _EOF_ chmod +x "${START_QEMU_SCRIPT}"
Signature · 1 line
2.25.3
PATCH 5/6 board/qemu/post-image.sh: start from a shell
Hi Yann, All,
Le 27/04/2020 ? 00:33, Romain Naour a ?crit?:
Quoted 24 lines
Usually the qemu command line start directly with "qemu-system-<arch> ...". But the command line for
qemu_arm_vexpress_tz_defconfigstart by doing "cd output/images && ../host/bin/qemu-system-arm". This is necessary since boot binaries, except BL1, are primarily loaded via semi-hosting so all binaries has to reside in the same directory as QEMU is started from [1].The
start-qemu.shscript fail to start qemu since it use exec on the "cd" command. To work around this issue, use "exec sh -c":
exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}"Signed-off-by Romain Naour <[email protected]>Cc Yann E. MORIN <[email protected]>--- board/qemu/post-image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/qemu/post-image.sh +0
-0
board/qemu/post-image.sh cat <<-_EOF_ > "${START_QEMU_SCRIPT}" · line 52
Quoted 5 lines
board/qemu/post-image.sh +1
-1@@ -49,7 +49,7 @@ cat <<-_EOF_ > "${START_QEMU_SCRIPT}" fi export PATH="${HOST_DIR}/bin:\${PATH}" - exec ${QEMU_CMD_LINE} \${EXTRA_ARGS} + exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}"
This patch is not ok as is since we need to escape double quotes from "${QEMU_CMD_LINE}
example:
-append \"rootwait root=/dev/sda console=ttySC1,115200 noiotrap\"
Best regards,
Romain
Quoted 4 lines
board/qemu/post-image.sh +0
-0_EOF_ chmod +x "${START_QEMU_SCRIPT}"
PATCH 5/6 board/qemu/post-image.sh: start from a shell
Quoted 9 lines · Romain Naour
board/qemu/post-image.sh cat <<-_EOF_ > "${START_QEMU_SCRIPT}" · line 52
Quoted 3 lines
board/qemu/post-image.sh +1
-1export PATH="${HOST_DIR}/bin:\${PATH}" - exec ${QEMU_CMD_LINE} \${EXTRA_ARGS} + exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}"This patch is not ok as is since we need to escape double quotes from "${QEMU_CMD_LINE}
example:
-append \"rootwait root=/dev/sda console=ttySC1,115200 noiotrap\"
Maybe use something like:
CMD="${QEMU_CMD_LINE} ${EXTRA_ARGS}"
eval exec ${CMD}-Geoff
PATCH 6/6 configs/qemu_arm_vexpress_tz_defconfig: build start-qemu.sh
In reply to Romain NaourWhen tags was added by commit 011206b2bffd509b29365bc1eaa761414ee13726 to detect the qemu command line, the qemu_arm_vexpress_tz_defconfig was ignored due to a build issue.
This build issue has been fixed by previous patches, so we can enable the runtime testing by adding the tag in the readme.txt and the post-image script in the defconfig.
--- board/qemu/arm-vexpress-tz/readme.txt | 2 +- configs/qemu_arm_vexpress_tz_defconfig | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
board/qemu/arm-vexpress-tz/readme.txt +1 -1
@@ -18,7 +18,7 @@ secure and non-secure worlds. -serial stdio \ -netdev user,id=vmnic -device virtio-net-device,netdev=vmnic \ -semihosting-config enable,target=native \ - -bios bl1.bin + -bios bl1.bin # qemu_arm_vexpress_tz_defconfig The boot stage traces (if any) followed by the login prompt will appear in the terminal that started QEMU.
configs/qemu_arm_vexpress_tz_defconfig +4 -0
@@ -47,6 +47,10 @@ BR2_PACKAGE_HOST_PYTHON3=y BR2_TOOLCHAIN_BUILDROOT_WCHAR=y BR2_PACKAGE_PYTHON3=y +# Image +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)" + # U-boot for booting the dear Linux kernel BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
Signature · 1 line
2.25.3
PATCH 1/6 package/python-pycryptodomex: add host variant
In reply to Romain NaourQuoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Romain" == Romain Naour <[email protected]> writes:
Adding a host variant allow to replace host-python-pycrypto by host-python-pycryptodomex for crda and optee-os packages.
From [1]:
"PyCryptodome is a fork of PyCrypto, which is not maintained any more (the last release dates back to 2013 [2]). It exposes almost the same API, but there are a few incompatibilities [3]."
Quoted 8 lines
[1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0
[2] https://pypi.org/project/pycrypto/#history
[3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.htmlSigned-off-by Romain Naour <[email protected]>Cc James Hilliard <[email protected]>---
For master and 2020.02.x.
Committed to 2020.02.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard