# Disable failing tests on Fedora 26 (latest tests require a recent version of
# cffi)
%if 0%{?fedora} >= 27
%global _with_tests 1
%endif
%global srcname pycryptodomex
%global common_summary A self-contained cryptographic library for Python
%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.6.0
Release: 2%{?dist}
Summary: %{common_summary}
# PyCrypto-based code is public domain, futher PyCryptodome
# contributions are BSD
License: BSD and Public Domain
URL: http://www.pycryptodome.org/
Source0: https://github.com/Legrandin/pycryptodome/archive/v%{version}x/%{srcname}-%{version}.tar.gz
# Use external libtomcrypt library
Patch0: %{name}-3.4.12-use_external_libtomcrypt.patch
BuildRequires: gcc
BuildRequires: libtomcrypt-devel
BuildRequires: python2-devel
BuildRequires: python3-devel
# Needed for documentation
BuildRequires: python2-sphinx
%description
%{common_description}
%package -n python2-%{srcname}
Summary: %{common_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: %{common_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}x -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
%py2_build
%py3_build
# Build documentation
pushd Doc/
%make_build man
popd
%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
%if 0%{?_with_tests}
%{__python2} setup.py test
%{__python3} setup.py test
%endif
%files -n python2-%{srcname}
%doc AUTHORS.rst Changelog.rst README.rst
%license LICENSE.rst
%{python2_sitearch}/*
%{_mandir}/man1/pycryptodome.1.*
%files -n python3-%{srcname}
%doc AUTHORS.rst Changelog.rst README.rst
%license LICENSE.rst
%{python3_sitearch}/*
%{_mandir}/man1/pycryptodome.1.*
%changelog
* Tue Apr 10 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.6.0-2
- Disable tests on Fedora 26
* Tue Apr 10 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.6.0-1
- Update to 3.6.0
* Tue Mar 20 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.5.1-1
- Update to 3.5.1
* Thu Mar 08 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.5.0-1
- Update to 3.5.0
* Wed Mar 07 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.4.12-3
- Fix Provides in python3 subpackage
* Tue Mar 06 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.4.12-2
- Fix License tag
* Tue Mar 06 2018 Mohamed El Morabity <melmorabity@fedoraproject.org> - 3.4.12-1
- Initial RPM release