0001-scripts-pem_to_pub_c.py-sign.py-use-pycryptodomex.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From 06e71feaeb08349abe56b50c3dfb08a8341cf55f Mon Sep 17 00:00:00 2001
  2. From: Romain Naour <romain.naour@gmail.com>
  3. Date: Sun, 26 Apr 2020 21:55:55 +0200
  4. Subject: [PATCH] scripts/pem_to_pub_c.py/sign.py: use pycryptodomex
  5. These scripts still use pycrypto.
  6. From [1]:
  7. "PyCryptodome is a fork of PyCrypto, which is not maintained any more
  8. (the last release dates back to 2013 [2]). It exposes almost the same
  9. API, but there are a few incompatibilities [3]."
  10. Don't use upstream commit since it also switches from the algorithm
  11. TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 to TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256
  12. when replacing pycrypto to pycryptodomex [4].
  13. [1] https://github.com/OP-TEE/optee_os/commit/90ad2450436fdd9fc0d28a3f92f3fbcfd89a38f0
  14. [2] https://pypi.org/project/pycrypto/#history
  15. [3] https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.html
  16. [4] https://github.com/OP-TEE/optee_os/commit/ababd72d2fd76cb2ded8e202b49db28d6545f6eb
  17. Signed-off-by: Romain Naour <romain.naour@gmail.com>
  18. ---
  19. scripts/pem_to_pub_c.py | 4 ++--
  20. scripts/sign.py | 8 ++++----
  21. 2 files changed, 6 insertions(+), 6 deletions(-)
  22. diff --git a/scripts/pem_to_pub_c.py b/scripts/pem_to_pub_c.py
  23. index 3a896a39..d3f0e500 100755
  24. --- a/scripts/pem_to_pub_c.py
  25. +++ b/scripts/pem_to_pub_c.py
  26. @@ -21,8 +21,8 @@ def get_args():
  27. def main():
  28. import array
  29. - from Crypto.PublicKey import RSA
  30. - from Crypto.Util.number import long_to_bytes
  31. + from Cryptodome.PublicKey import RSA
  32. + from Cryptodome.Util.number import long_to_bytes
  33. args = get_args()
  34. diff --git a/scripts/sign.py b/scripts/sign.py
  35. index 2939c591..80ce2e9f 100755
  36. --- a/scripts/sign.py
  37. +++ b/scripts/sign.py
  38. @@ -121,10 +121,10 @@ def get_args(logger):
  39. def main():
  40. - from Crypto.Signature import PKCS1_v1_5
  41. - from Crypto.Hash import SHA256
  42. - from Crypto.PublicKey import RSA
  43. - from Crypto.Util.number import ceil_div
  44. + from Cryptodome.Signature import PKCS1_v1_5
  45. + from Cryptodome.Hash import SHA256
  46. + from Cryptodome.PublicKey import RSA
  47. + from Cryptodome.Util.number import ceil_div
  48. import base64
  49. import logging
  50. import os
  51. --
  52. 2.25.3