diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6920bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/pycryptodomex-3.4.12.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 7c51373..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# python-pycryptodomex - -The python-pycryptodomex package \ No newline at end of file diff --git a/python-pycryptodomex-3.4.12-use_external_libtomcrypt.patch b/python-pycryptodomex-3.4.12-use_external_libtomcrypt.patch new file mode 100644 index 0000000..68afa72 --- /dev/null +++ b/python-pycryptodomex-3.4.12-use_external_libtomcrypt.patch @@ -0,0 +1,68 @@ +diff -up ./setup.py.orig ./setup.py +--- ./setup.py.orig 2018-02-04 21:03:07.000000000 +0100 ++++ ./setup.py 2018-03-06 13:25:27.459746877 +0100 +@@ -204,9 +204,6 @@ class PCTBuildExt (build_ext): + return [] + + def build_extensions(self): +- # Disable any assembly in libtomcrypt files +- self.compiler.define_macro("LTC_NO_ASM") +- + # Detect which modules should be compiled + self.detect_modules() + +@@ -543,11 +540,13 @@ ext_modules = [ + include_dirs=['src/'], + sources=["src/CAST.c"]), + Extension("Crypto.Cipher._raw_des", +- include_dirs=['src/', 'src/libtom/'], ++ include_dirs=['src/'], ++ extra_link_args=['-ltomcrypt'], + sources=["src/DES.c"]), + 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._galois", + include_dirs=['src/'], + sources=['src/galois.c']), +@@ -580,8 +579,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.orig ./src/DES.c +--- ./src/DES.c.orig 2018-02-04 21:03:07.000000000 +0100 ++++ ./src/DES.c 2018-03-06 13:11:55.318990638 +0100 +@@ -39,7 +39,7 @@ FAKE_INIT(raw_des3) + + /* Include the actial DES implementation */ + #define LTC_NO_PROTOTYPES +-#include "libtom/tomcrypt_des.c" ++#include + + typedef struct { + symmetric_key sk; +diff -up ./src/Salsa20.c.orig ./src/Salsa20.c +--- ./src/Salsa20.c.orig 2018-02-04 21:03:07.000000000 +0100 ++++ ./src/Salsa20.c 2018-03-06 13:03:37.616222145 +0100 +@@ -29,9 +29,7 @@ + + FAKE_INIT(Salsa20) + +-#include "libtom/tomcrypt_cfg.h" +-#include "libtom/tomcrypt_custom.h" +-#include "libtom/tomcrypt_macros.h" ++#include + + #define ROUNDS 20 + #define MAX_KEY_SIZE 32 diff --git a/python-pycryptodomex.spec b/python-pycryptodomex.spec new file mode 100644 index 0000000..96c6e8a --- /dev/null +++ b/python-pycryptodomex.spec @@ -0,0 +1,136 @@ +%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.4.12 +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}} +Provides: %{srcname} = %{version}-%{release} + +%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 +%{__python2} setup.py test +%{__python3} setup.py test + + +%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 Mar 06 2018 Mohamed El Morabity - 3.4.12-2 +- Fix License tag + +* Tue Mar 06 2018 Mohamed El Morabity - 3.4.12-1 +- Initial RPM release diff --git a/sources b/sources new file mode 100644 index 0000000..a6ac649 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (pycryptodomex-3.4.12.tar.gz) = d8f05c16e00adb739e94c5ebb5963a61402ff550b06871ebbcf2c73344c75d249f0031b25aefb293aeb1ec3a3a8e6165f0cfc75b780922bd9423e35a840de692