Mohamed El Morabity 3f21065
%global srcname pycryptodomex
301418c
%global common_description PyCryptodome is a self-contained Python package of low-level cryptographic\
301418c
primitives. It's a fork of PyCrypto. It brings several enhancements with respect\
301418c
to the last official version of PyCrypto (2.6.1), for instance:\
Mohamed El Morabity 3f21065
\
Mohamed El Morabity 3f21065
  * Authenticated encryption modes (GCM, CCM, EAX, SIV, OCB)\
Mohamed El Morabity 3f21065
  * Accelerated AES on Intel platforms via AES-NI\
Mohamed El Morabity 3f21065
  * Elliptic curves cryptography (NIST P-256 curve only)\
301418c
  * Better and more compact API (nonce and iv attributes for ciphers, automatic\
301418c
    generation of random nonces and IVs, simplified CTR cipher mode, and more)\
Mohamed El Morabity 3f21065
  * SHA-3 (including SHAKE XOFs) and BLAKE2 hash algorithms\
Mohamed El Morabity 3f21065
  * Salsa20 and ChaCha20 stream ciphers\
Mohamed El Morabity 3f21065
  * scrypt and HKDF\
Mohamed El Morabity 3f21065
  * Deterministic (EC)DSA\
Mohamed El Morabity 3f21065
  * Password-protected PKCS#8 key containers\
6227f95
  * Shamir's Secret Sharing scheme\
301418c
  * Random numbers get sourced directly from the OS (and not from a CSPRNG in\
301418c
    userspace)\
Mohamed El Morabity 3f21065
  * Cleaner RSA and DSA key generation (largely based on FIPS 186-4)\
Mohamed El Morabity 3f21065
  * Major clean ups and simplification of the code base\
Mohamed El Morabity 3f21065
\
301418c
PyCryptodome is not a wrapper to a separate C library like OpenSSL. To the\
301418c
largest possible extent, algorithms are implemented in pure Python. Only the\
301418c
pieces that are extremely critical to performance (e.g. block ciphers) are\
301418c
implemented as C extensions.\
Mohamed El Morabity 3f21065
\
301418c
Note: all modules are installed under the Cryptodome package to avoid conflicts\
301418c
with the PyCrypto library.
301418c
7002822
%global _with_python2 0%{?rhel} || 0%{?fedora}
301418c
%global _with_python3_other 0%{?rhel}
5be8808
# Tests fail on 32-bit architectures
5be8808
# TODO: report issue
5be8808
%global _with_tests 0%{?fedora} <= 29 || 0%{?rhel}
301418c
%global python_sphinx_pkg %{?rhel:python2}%{?fedora:python%{python3_pkgversion}}-sphinx
301418c
%global sphinx_build sphinx-build%{?fedora:-%{python3_version}}
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
Name:           python-%{srcname}
1ea6f76
Version:        3.8.2
1ea6f76
Release:        1%{?dist}
301418c
Summary:        A self-contained cryptographic library for Python
Mohamed El Morabity 3f21065
301418c
# PyCrypto-based code is public domain, further PyCryptodome contributions are
301418c
# BSD
Mohamed El Morabity 3f21065
License:        BSD and Public Domain
Mohamed El Morabity 3f21065
URL:            http://www.pycryptodome.org/
Mohamed El Morabity a3a7395
Source0:        https://github.com/Legrandin/pycryptodome/archive/v%{version}/%{srcname}-%{version}.tar.gz
Mohamed El Morabity 3f21065
# Use external libtomcrypt library
6227f95
Patch0:         %{name}-3.7.3-use_external_libtomcrypt.patch
301418c
# Fix documentation build with Sphinx <= 1.2, especially on EL
301418c
Patch1:         %{name}-3.7.0-sphinx.patch
6227f95
# Fix compilation flags
6227f95
Patch2:         %{name}-3.7.3-cflags.patch
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
BuildRequires:  gcc
Mohamed El Morabity 3f21065
BuildRequires:  libtomcrypt-devel
301418c
%if 0%{?_with_python2}
301418c
BuildRequires:  python2-devel
301418c
BuildRequires:  python2-setuptools
301418c
%endif
301418c
BuildRequires:  python%{python3_pkgversion}-devel
301418c
BuildRequires:  python%{python3_pkgversion}-setuptools
301418c
%if 0%{_with_python3_other}
301418c
BuildRequires:  python%{python3_other_pkgversion}-devel
301418c
BuildRequires:  python%{python3_other_pkgversion}-setuptools
301418c
%endif
Mohamed El Morabity 3f21065
# Needed for documentation
301418c
BuildRequires:  %{python_sphinx_pkg}
301418c
%if 0%{?rhel}
301418c
BuildRequires:  python-sphinxcontrib-napoleon
301418c
%endif
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
%description
Mohamed El Morabity 3f21065
%{common_description}
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
301418c
%if 0%{?_with_python2}
301418c
%package -n python2-%{srcname}
301418c
Summary:        %{summary}
301418c
# GMP library is dl-opened
301418c
Requires:       gmp%{?_isa}
301418c
%{?python_provide:%python_provide python2-%{srcname}}
301418c
301418c
%description -n python2-%{srcname}
301418c
%{common_description}
301418c
%endif
301418c
301418c
301418c
%package -n python%{python3_pkgversion}-%{srcname}
301418c
Summary:        %{summary}
301418c
# GMP library is dl-opened
301418c
Requires:       gmp%{?_isa}
301418c
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}
301418c
301418c
%description -n python%{python3_pkgversion}-%{srcname}
301418c
%{common_description}
301418c
301418c
301418c
%if 0%{?_with_python3_other}
301418c
%package -n python%{python3_other_pkgversion}-%{srcname}
301418c
Summary:        %{summary}
Mohamed El Morabity 3f21065
# GMP library is dl-opened
Mohamed El Morabity 3f21065
Requires:       gmp%{?_isa}
301418c
%{?python_provide:%python_provide python%{python3_other_pkgversion}-%{srcname}}
Mohamed El Morabity 3f21065
301418c
%description -n python%{python3_other_pkgversion}-%{srcname}
Mohamed El Morabity 3f21065
%{common_description}
301418c
%endif
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
%prep
Mohamed El Morabity a3a7395
%autosetup -n pycryptodome-%{version} -p0
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
# Drop bundled libraries
Mohamed El Morabity 3f21065
rm -r src/libtom/
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
# Remove shebang
Mohamed El Morabity 3f21065
sed '1{\@^#! /usr/bin/env python@d}' lib/Crypto/SelfTest/__main__.py >lib/Crypto/SelfTest/__main__.py.new && \
Mohamed El Morabity 3f21065
touch -r lib/Crypto/SelfTest/__main__.py lib/Crypto/SelfTest/__main__.py.new && \
Mohamed El Morabity 3f21065
mv lib/Crypto/SelfTest/__main__.py.new lib/Crypto/SelfTest/__main__.py
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
%build
Mohamed El Morabity a3a7395
touch .separate_namespace
301418c
%if 0%{?_with_python2}
301418c
%py2_build
301418c
%endif
Mohamed El Morabity 3f21065
%py3_build
301418c
%if 0%{?_with_python3_other}
301418c
%py3_other_build
301418c
%endif
301418c
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
# Build documentation
301418c
%make_build -C Doc/ man SPHINXBUILD=%{sphinx_build}
301418c
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
%install
301418c
%if 0%{?_with_python2}
301418c
%py2_install
301418c
%endif
Mohamed El Morabity 3f21065
%py3_install
301418c
%if 0%{?_with_python3_other}
301418c
%py3_other_install
301418c
%endif
301418c
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
# Install man pages
Mohamed El Morabity 3f21065
install -Dpm 0644 Doc/_build/man/pycryptodome.1 $RPM_BUILD_ROOT%{_mandir}/man1/pycryptodome.1
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
# Fix permissions
301418c
%if 0%{_with_python2}
301418c
chmod 0755 $RPM_BUILD_ROOT%{python2_sitearch}/Cryptodome/SelfTest/PublicKey/test_vectors/ECC/gen_ecc_p256.sh
301418c
%endif
Mohamed El Morabity 3f21065
chmod 0755 $RPM_BUILD_ROOT%{python3_sitearch}/Cryptodome/SelfTest/PublicKey/test_vectors/ECC/gen_ecc_p256.sh
301418c
%if 0%{_with_python3_other}
301418c
chmod 0755 $RPM_BUILD_ROOT%{python3_other_sitearch}/Cryptodome/SelfTest/PublicKey/test_vectors/ECC/gen_ecc_p256.sh
301418c
%endif
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
%check
5be8808
%if 0%{?_with_tests}
301418c
%if 0%{?_with_python2}
301418c
%{__python2} setup.py test
301418c
%endif
Mohamed El Morabity 3f21065
%{__python3} setup.py test
301418c
%if 0%{?_with_python3_other}
301418c
%{__python3_other} setup.py test
01c96f2
%endif
5be8808
%endif
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
301418c
%if 0%{?_with_python2}
301418c
%files -n python2-%{srcname}
Mohamed El Morabity 3f21065
%doc AUTHORS.rst Changelog.rst README.rst
Mohamed El Morabity 3f21065
%license LICENSE.rst
301418c
%{python2_sitearch}/Cryptodome/
301418c
%{python2_sitearch}/%{srcname}-*.egg-info/
Mohamed El Morabity 3f21065
%{_mandir}/man1/pycryptodome.1.*
301418c
%endif
Mohamed El Morabity 3f21065
Mohamed El Morabity 3f21065
301418c
%files -n python%{python3_pkgversion}-%{srcname}
301418c
%doc AUTHORS.rst Changelog.rst README.rst
301418c
%license LICENSE.rst
301418c
%{python3_sitearch}/Cryptodome/
301418c
%{python3_sitearch}/%{srcname}-*.egg-info/
301418c
%{_mandir}/man1/pycryptodome.1.*
Mohamed El Morabity ffddec7
f7e3e4c
c9476f1
301418c
%if 0%{?_with_python3_other}
301418c
%files -n python%{python3_other_pkgversion}-%{srcname}
301418c
%doc AUTHORS.rst Changelog.rst README.rst
301418c
%license LICENSE.rst
301418c
%{python3_other_sitearch}/Cryptodome/
301418c
%{python3_other_sitearch}/%{srcname}-*.egg-info/
301418c
%{_mandir}/man1/pycryptodome.1.*
301418c
%endif
Mohamed El Morabity f1f95b5
Mohamed El Morabity 3f21065
301418c
%changelog
1ea6f76
* Fri Aug 09 2019 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.8.2-1
1ea6f76
- Update to 3.8.2
1ea6f76
f55b7a3
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.8.1-3
f55b7a3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
f55b7a3
7002822
* Tue Apr 09 2019 Miro HronĨok <mhroncok@redhat.com> - 3.8.1-2
1ea6f76
- Readd python2-pycryptodomex (#1672052)
7002822
b8bf6be
* Fri Apr 05 2019 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.8.1-1
b8bf6be
- Update to 3.8.1
b8bf6be
5be8808
* Fri Mar 29 2019 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.8.0-1
9d247ff
- Update to 3.8.0
9d247ff
6227f95
* Fri Feb 15 2019 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.7.3-1
6227f95
- Update to 3.7.3
6227f95
667c0f3
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-2
667c0f3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
667c0f3
301418c
* Mon Nov 19 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.7.0-1
301418c
- Update to 3.7.0
301418c
- Use the same .spec file for all supported releases of Fedora and EL