From 14a8b2ee00797b2f92172b48965fb334a3a3ce73 Mon Sep 17 00:00:00 2001 From: Mohamed El Morabity Date: Wed, 16 Mar 2022 11:46:09 +0100 Subject: [PATCH] Initial EPEL9 release --- .gitignore | 1 + python-pycryptodomex-3.10.1-sphinx_4.patch | 21 +++ ...omex-3.10.1-use_external_libtomcrypt.patch | 43 ++++++ python-pycryptodomex.spec | 126 ++++++++++++++++++ sources | 1 + 5 files changed, 192 insertions(+) create mode 100644 .gitignore create mode 100644 python-pycryptodomex-3.10.1-sphinx_4.patch create mode 100644 python-pycryptodomex-3.10.1-use_external_libtomcrypt.patch create mode 100644 python-pycryptodomex.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5b5c6b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/pycryptodomex-3.14.0.tar.gz diff --git a/python-pycryptodomex-3.10.1-sphinx_4.patch b/python-pycryptodomex-3.10.1-sphinx_4.patch new file mode 100644 index 0000000..e817070 --- /dev/null +++ b/python-pycryptodomex-3.10.1-sphinx_4.patch @@ -0,0 +1,21 @@ +diff -up ./Doc/conf.py.bak ./Doc/conf.py +--- ./Doc/conf.py.bak 2021-07-05 08:16:40.083571171 +0000 ++++ ./Doc/conf.py 2021-07-05 08:17:17.754162806 +0000 +@@ -15,7 +15,7 @@ import sys, os + + # Modules to document with autodoc are in another directory + sys.path.insert(0, os.path.abspath('../lib')) +-print sys.path ++print(sys.path) + + # Mock existence of native modules + from Crypto.Util import _raw_api +@@ -155,7 +155,7 @@ html_static_path = ['_static'] + # Ensure that text wrapping works in a table, by overring some CSS. + # See https://github.com/rtfd/sphinx_rtd_theme/issues/117 + def setup(app): +- app.add_stylesheet('theme_overrides.css') ++ app.add_css_file('theme_overrides.css') + + # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, + # using the given strftime format. diff --git a/python-pycryptodomex-3.10.1-use_external_libtomcrypt.patch b/python-pycryptodomex-3.10.1-use_external_libtomcrypt.patch new file mode 100644 index 0000000..9e45b26 --- /dev/null +++ b/python-pycryptodomex-3.10.1-use_external_libtomcrypt.patch @@ -0,0 +1,43 @@ +diff -up ./setup.py.bak ./setup.py +--- ./setup.py.bak 2021-02-08 22:14:54.000000000 +0100 ++++ ./setup.py 2021-02-09 15:55:53.785892041 +0100 +@@ -367,12 +367,14 @@ ext_modules = [ + sources=["src/CAST.c"], + py_limited_api=True), + Extension("Crypto.Cipher._raw_des", +- include_dirs=['src/', 'src/libtom/'], ++ include_dirs=['src/'], + sources=["src/DES.c"], ++ extra_link_args=["-ltomcrypt"], + py_limited_api=True), + Extension("Crypto.Cipher._raw_des3", +- include_dirs=['src/', 'src/libtom/'], ++ include_dirs=['src/'], + sources=["src/DES3.c"], ++ extra_link_args=["-ltomcrypt"], + py_limited_api=True), + Extension("Crypto.Util._cpuid_c", + include_dirs=['src/'], +@@ -410,8 +412,9 @@ ext_modules = [ + sources=["src/ARC4.c"], + py_limited_api=True), + Extension("Crypto.Cipher._Salsa20", +- include_dirs=['src/', 'src/libtom/'], ++ include_dirs=['src/'], + sources=["src/Salsa20.c"], ++ extra_link_args=["-ltomcrypt"], + py_limited_api=True), + Extension("Crypto.Cipher._chacha20", + include_dirs=['src/'], +diff -up ./src/DES.c.bak ./src/DES.c +--- ./src/DES.c.bak 2021-02-08 22:14:54.000000000 +0100 ++++ ./src/DES.c 2021-02-09 15:55:53.785892041 +0100 +@@ -39,7 +39,7 @@ FAKE_INIT(raw_des3) + + /* Include the actial DES implementation */ + #define LTC_NO_PROTOTYPES +-#include "libtom/tomcrypt_des.c" ++#include + + struct block_state { + symmetric_key sk; diff --git a/python-pycryptodomex.spec b/python-pycryptodomex.spec new file mode 100644 index 0000000..b276c0f --- /dev/null +++ b/python-pycryptodomex.spec @@ -0,0 +1,126 @@ +%global srcname pycryptodomex +%global _description %{expand:PyCryptodome is a self-contained Python package of low-level cryptographic +primitives. It's a fork of PyCrypto. It brings several enhancements with respect +to the last official version of PyCrypto (2.6.1), for instance: + + * Authenticated encryption modes (GCM, CCM, EAX, SIV, OCB) + * Accelerated AES on Intel platforms via AES-NI + * Elliptic curves cryptography (NIST P-256 curve only) + * Better and more compact API (nonce and iv attributes for ciphers, automatic + generation of random nonces and IVs, simplified CTR cipher mode, and more) + * SHA-3 (including SHAKE XOFs) and BLAKE2 hash algorithms + * Salsa20 and ChaCha20 stream ciphers + * scrypt and HKDF + * Deterministic (EC)DSA + * Password-protected PKCS#8 key containers + * Shamir's Secret Sharing scheme + * Random numbers get sourced directly from the OS (and not from a CSPRNG in + userspace) + * Cleaner RSA and DSA key generation (largely based on FIPS 186-4) + * Major clean ups and simplification of the code base + +PyCryptodome is not a wrapper to a separate C library like OpenSSL. To the +largest possible extent, algorithms are implemented in pure Python. Only the +pieces that are extremely critical to performance (e.g. block ciphers) are +implemented as C extensions. + +Note: all modules are installed under the Cryptodome package to avoid conflicts +with the PyCrypto library.} + +Name: python-%{srcname} +Version: 3.14.0 +Release: 1%{?dist} +Summary: A self-contained cryptographic library for Python + +# PyCrypto-based code is public domain, further PyCryptodome contributions are +# BSD +License: BSD and Public Domain +URL: http://www.pycryptodome.org/ +Source0: https://github.com/Legrandin/pycryptodome/archive/v%{version}/%{srcname}-%{version}.tar.gz +# Use external libtomcrypt library +Patch0: %{name}-3.10.1-use_external_libtomcrypt.patch +# Fix build with Sphinx 4.2 +Patch1: %{name}-3.10.1-sphinx_4.patch + +BuildRequires: gcc +BuildRequires: libtomcrypt-devel +BuildRequires: make +BuildRequires: python3-devel +# Needed for documentation +BuildRequires: %{py3_dist sphinx} + +%description +%{_description} + + +%package -n python3-%{srcname} +Summary: %{summary} +# GMP library is dl-opened +Requires: gmp%{?_isa} + +%description -n python3-%{srcname} +%{_description} + + +%package -n python3-%{srcname}-selftest +Summary: PyCryptodome test suite module +Requires: python3-%{srcname}%{?_isa} + +%description -n python3-%{srcname}-selftest +%{_description} + +This package provides the PyCryptodome test suite module (Cryptodome.SelfTest). + + +%prep +%autosetup -n pycryptodome-%{version} -p0 + +# Drop bundled libraries +rm -r src/libtom/ + +# Remove shebang +sed '1{\@^#! /usr/bin/env python@d}' lib/Crypto/SelfTest/__main__.py >lib/Crypto/SelfTest/__main__.py.new && \ +touch -r lib/Crypto/SelfTest/__main__.py lib/Crypto/SelfTest/__main__.py.new && \ +mv lib/Crypto/SelfTest/__main__.py.new lib/Crypto/SelfTest/__main__.py + + +%generate_buildrequires +export PYCRYPTODOME_DEBUG=1 +%pyproject_buildrequires -r + + +%build +touch .separate_namespace +%pyproject_wheel + +# Build documentation +%make_build -C Doc/ man SPHINXBUILD=sphinx-build + + +%install +%pyproject_install +%pyproject_save_files Cryptodome + + +# Install man pages +install -Dpm 0644 Doc/_build/man/pycryptodome.1 $RPM_BUILD_ROOT%{_mandir}/man1/pycryptodome.1 + + +%check +PYTHONPATH=$RPM_BUILD_ROOT%{python3_sitearch}/ %{__python3} setup.py test + + +%files -n python3-%{srcname} -f %{pyproject_files} +%doc AUTHORS.rst Changelog.rst README.rst +%license LICENSE.rst +%exclude %{python3_sitearch}/Cryptodome/SelfTest/ +%{_mandir}/man1/pycryptodome.1.* + + +%files -n python3-%{srcname}-selftest +%{python3_sitearch}/Cryptodome/SelfTest/ + + +%changelog +* Wed Feb 02 2022 Mohamed El Morabity - 3.14.0-1 +- Initial EPEL9 release diff --git a/sources b/sources new file mode 100644 index 0000000..b03a5c8 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (pycryptodomex-3.14.0.tar.gz) = 2f20a3a2bfef14a0f4c05587d64da3a4be7303ae37aaee02e49a3c7ef69009fa958e4b7151c1441f2cc63833cc29642d6d13c1006fb0f215743178d36c9de802