Skip to contentSkip to conversation

Fix OpTee PyCryptodomex Python 2 vs 3 issue

Buildroot Jonatan Hatakeyama Zeidler 2 participants 3 messages Aug 6, 2020 – Aug 7, 2020

lore
Share & tools
lore
#0 lore raw

Hi there,

I am using buildroot.2020.05.1. I am building optee with these options:

BR2_TARGET_OPTEE_OS=y BR2_TARGET_OPTEE_OS_PLATFORM="k3-am65x" BR2_TARGET_OPTEE_OS_CORE_IMAGES="tee-*_v2.bin"

These leads to

Traceback (most recent call last):
File "scripts/pem_to_pub_c.py", line 61, in <module> main()
File "scripts/pem_to_pub_c.py", line 24, in main from Cryptodome.PublicKey import RSA
ModuleNotFoundError: No module named 'Cryptodome'

during build of optee-os. The script scripts/pem_to_pub_c.py is run with Python3, while optee-os has Python2 dependencies:

OPTEE_OS_DEPENDENCIES = host-openssl host-python-pycryptodomex host-python-pyelftools.

Thus, the Cryptodome module is not found.

What fixed that for me is to add a python3-pycryptodomex package and change optee-os dependencies to Python3 ones. The patches are attached.

Let me know whether adding these patches makes sense to you.

Kind regards and thanks for your great work on buildroot,

Jonatan

--
Jonatan Hatakeyama Zeidler
Software Engineer
Brainlab Robotics

T +49 89 99 15 68 ? 0
F +49 89 99 15 68 ? 5033

Medineering GmbH
Olof-Palme-Str. 1, 81829 M?nchen, Germany
Sitz d. Gesellschaft: M?nchen - Handelsregister: M?nchen HRB 212991 VAT.: DE296021936
Managing Director: Dr.-Ing. Maximilian Krinninger, Dr.-Ing. Stephan Nowatschin

This email, including its attachments, is intended only for the confidential use of the individual to whom it is addressed. If you are not the intended recipient, any use, dissemination, distribution or copying of this message or its attachments is prohibited. If you have received this message in error, please notify us immediately, and delete this message and its attachments permanently from your system. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200806/66267a25/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-package-python3-pycryptodomex-add-python3-pycryptodomex-package.patch
Type: text/x-patch
Size: 2950 bytes
Desc: 0001-package-python3-pycryptodomex-add-python3-pycryptodomex-package.patch
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200806/66267a25/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-boot-optee-os-optee-os-mk-optee-op-use-python3-dependencies.patch
Type: text/x-patch
Size: 907 bytes
Desc: 0002-boot-optee-os-optee-os-mk-optee-op-use-python3-dependencies.patch
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200806/66267a25/attachment-0001.bin>

#1 lore raw

Hello Jonatan,

Quoted 9 lines · On Thu, 6 Aug 2020 09:30:00 +0000 Jonatan Hatakeyama Zeidler…

These leads to

Traceback (most recent call last):
File "scripts/pem_to_pub_c.py", line 61, in <module> main()
File "scripts/pem_to_pub_c.py", line 24, in main from Cryptodome.PublicKey import RSA
ModuleNotFoundError: No module named 'Cryptodome'

Quoted 7 lines

during build of optee-os. The script scripts/pem_to_pub_c.py is run with Python3, while optee-os has Python2 dependencies:

OPTEE_OS_DEPENDENCIES = host-openssl host-python-pycryptodomex host-python-pyelftools.

Thus, the Cryptodome module is not found.

What fixed that for me is to add a python3-pycryptodomex package and change optee-os dependencies to Python3 ones. The patches are attached.

I haven't reviewed your patch, nor the patch series I will point, but I believe the patch series at:

https://patchwork.ozlabs.org/project/buildroot/list/?series=191437

should address this issue.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

Hello Thomas,

Quoted 7 lines · Thomas Petazzoni

I haven't reviewed your patch, nor the patch series I will point, but I believe the patch series at:

https://patchwork.ozlabs.org/project/buildroot/list/?series=191437

should address this issue.

this addresses the same issue indeed. Is there anything I can do to help get that merged?

Best regards

Jonatan

Signature · 14 lines
Jonatan Hatakeyama Zeidler
Software Engineer
Brainlab Robotics

T +49 89 99 15 68 ? 0
F +49 89 99 15 68 ? 5033

Medineering GmbH
Olof-Palme-Str. 1, 81829 M?nchen, Germany
Sitz d. Gesellschaft: M?nchen - Handelsregister: M?nchen HRB 212991
VAT.: DE296021936
Managing Director: Dr.-Ing. Maximilian Krinninger, Dr.-Ing. Stephan Nowatschin

This email, including its attachments, is intended only for the confidential use of the individual to whom it is addressed. If you are not the intended recipient, any use, dissemination, distribution or copying of this message or its attachments is prohibited. If you have received this message in error, please notify us immediately, and delete this message and its attachments permanently from your system.