diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43b8119 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/pycryptodomex-3.9.0.tar.gz diff --git a/package.cfg b/package.cfg deleted file mode 100644 index 66ea79d..0000000 --- a/package.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[koji] -targets = epel8 epel8-playground \ No newline at end of file diff --git a/python-pycryptodomex-3.7.0-sphinx.patch b/python-pycryptodomex-3.7.0-sphinx.patch new file mode 100644 index 0000000..bc83b2c --- /dev/null +++ b/python-pycryptodomex-3.7.0-sphinx.patch @@ -0,0 +1,27 @@ +diff -up ./Doc/conf.py.bak ./Doc/conf.py +--- ./Doc/conf.py.bak 2018-10-27 23:08:03.000000000 +0200 ++++ ./Doc/conf.py 2018-11-17 15:34:58.392588884 +0100 +@@ -20,6 +20,10 @@ print sys.path + # Mock existence of native modules + from Crypto.Util import _raw_api + ++from distutils.version import LooseVersion ++ ++import sphinx ++ + class MockLib(object): + ghash_portable = None + ghash_expand_portable = None +@@ -40,7 +44,11 @@ _raw_api.load_pycryptodome_raw_lib = lam + + # Add any Sphinx extension module names here, as strings. They can be extensions + # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +-extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', ++if LooseVersion(sphinx.__version__) <= LooseVersion('1.2'): ++ napoleon_ext = 'sphinxcontrib.napoleon' ++else: ++ napoleon_ext = 'sphinx.ext.napoleon' ++extensions = [ 'sphinx.ext.autodoc', napoleon_ext, + 'sphinx.ext.mathjax' ] + + # Add any paths that contain templates here, relative to this directory. diff --git a/python-pycryptodomex-3.7.3-cflags.patch b/python-pycryptodomex-3.7.3-cflags.patch new file mode 100644 index 0000000..d5c9920 --- /dev/null +++ b/python-pycryptodomex-3.7.3-cflags.patch @@ -0,0 +1,11 @@ +diff -up ./compiler_opt.py.bak ./compiler_opt.py +--- ./compiler_opt.py.bak 2019-01-19 22:52:55.000000000 +0100 ++++ ./compiler_opt.py 2019-02-15 16:40:42.739281229 +0100 +@@ -334,7 +334,6 @@ def set_compiler_options(package_root, e + + # Options specific to GCC and CLANG + if clang or gcc: +- extra_cc_options.append('-O3') + if compiler_supports_sse2_with_x86intrin_h(): + extra_cc_options.append('-msse2') + extra_macros.append(("HAVE_X86INTRIN_H", None)) diff --git a/python-pycryptodomex-3.7.3-use_external_libtomcrypt.patch b/python-pycryptodomex-3.7.3-use_external_libtomcrypt.patch new file mode 100644 index 0000000..97bd2e6 --- /dev/null +++ b/python-pycryptodomex-3.7.3-use_external_libtomcrypt.patch @@ -0,0 +1,45 @@ +diff -up ./setup.py.bak ./setup.py +--- ./setup.py.bak 2019-01-19 22:52:55.000000000 +0100 ++++ ./setup.py 2019-02-15 15:29:46.960976879 +0100 +@@ -367,11 +367,13 @@ ext_modules = [ + include_dirs=['src/'], + sources=["src/CAST.c"]), + Extension("Crypto.Cipher._raw_des", +- include_dirs=['src/', 'src/libtom/'], +- sources=["src/DES.c"]), ++ include_dirs=['src/'], ++ sources=["src/DES.c"], ++ extra_link_args=["-ltomcrypt"]), + Extension("Crypto.Cipher._raw_des3", +- include_dirs=['src/', 'src/libtom/'], +- sources=["src/DES3.c"]), ++ include_dirs=['src/'], ++ sources=["src/DES3.c"], ++ extra_link_args=["-ltomcrypt"]), + Extension("Crypto.Util._cpuid_c", + include_dirs=['src/'], + sources=['src/cpuid.c']), +@@ -400,8 +402,9 @@ ext_modules = [ + include_dirs=['src/'], + sources=["src/ARC4.c"]), + Extension("Crypto.Cipher._Salsa20", +- include_dirs=['src/', 'src/libtom/'], +- sources=["src/Salsa20.c"]), ++ include_dirs=['src/'], ++ sources=["src/Salsa20.c"], ++ extra_link_args=["-ltomcrypt"]), + Extension("Crypto.Cipher._chacha20", + include_dirs=['src/'], + sources=["src/chacha20.c"]), +diff -up ./src/DES.c.bak ./src/DES.c +--- ./src/DES.c.bak 2019-01-19 22:52:55.000000000 +0100 ++++ ./src/DES.c 2019-02-15 15:30:27.014967034 +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..7667208 --- /dev/null +++ b/python-pycryptodomex.spec @@ -0,0 +1,138 @@ +%global srcname pycryptodomex +%global common_description 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.9.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.7.3-use_external_libtomcrypt.patch +# Fix documentation build with Sphinx <= 1.2, especially on EL +Patch1: %{name}-3.7.0-sphinx.patch +# Fix compilation flags +Patch2: %{name}-3.7.3-cflags.patch + +BuildRequires: gcc +BuildRequires: libtomcrypt-devel +BuildRequires: python2-devel +BuildRequires: python2-setuptools +BuildRequires: python3-devel +BuildRequires: python3-setuptools +# Needed for documentation +BuildRequires: python3-sphinx + +%description +%{common_description} + + +%package -n python2-%{srcname} +Summary: %{summary} +# GMP library is dl-opened +Requires: gmp%{?_isa} +%{?python_provide:%python_provide python2-%{srcname}} + +%description -n python2-%{srcname} +%{common_description} + + +%package -n python3-%{srcname} +Summary: %{summary} +# GMP library is dl-opened +Requires: gmp%{?_isa} +%{?python_provide:%python_provide python3-%{srcname}} + +%description -n python3-%{srcname} +%{common_description} + + +%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 + + +%build +touch .separate_namespace +%py2_build +%py3_build + + +# Build documentation +%make_build -C Doc/ man SPHINXBUILD=sphinx-build-3 + + +%install +%py2_install +%py3_install + + +# Install man pages +install -Dpm 0644 Doc/_build/man/pycryptodome.1 $RPM_BUILD_ROOT%{_mandir}/man1/pycryptodome.1 + +# Fix permissions +chmod 0755 $RPM_BUILD_ROOT%{python2_sitearch}/Cryptodome/SelfTest/PublicKey/test_vectors/ECC/gen_ecc_p256.sh +chmod 0755 $RPM_BUILD_ROOT%{python3_sitearch}/Cryptodome/SelfTest/PublicKey/test_vectors/ECC/gen_ecc_p256.sh + + +%check +%{__python2} setup.py test +%{__python3} setup.py test + + +%files -n python2-%{srcname} +%doc AUTHORS.rst Changelog.rst README.rst +%license LICENSE.rst +%{python2_sitearch}/Cryptodome/ +%{python2_sitearch}/%{srcname}-*.egg-info/ +%{_mandir}/man1/pycryptodome.1.* + + +%files -n python3-%{srcname} +%doc AUTHORS.rst Changelog.rst README.rst +%license LICENSE.rst +%{python3_sitearch}/Cryptodome/ +%{python3_sitearch}/%{srcname}-*.egg-info/ +%{_mandir}/man1/pycryptodome.1.* + + +%changelog +* Thu Oct 31 2019 Mohamed El Morabity - 3.9.0-1 +- Enable build for EPEL8 diff --git a/sources b/sources new file mode 100644 index 0000000..b0afd84 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (pycryptodomex-3.9.0.tar.gz) = 1f1490d2854c9f5ed0fbb4a41b63ef47758bf07610f7c6c5bab14c93c760dc2e62d38ff101956e3739a8609bcba83c73ec77c665fe847b2d317996134212ddf7