From 832e2c6d679d04cde07ea3a1acf626480995a00a Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 01 2017 13:06:17 +0000 Subject: import python-crypto-2.6.1-15.el7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e7fe54 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/pycrypto-2.6.1.tar.gz diff --git a/.python-crypto.metadata b/.python-crypto.metadata index 3cf42e9..492cd2e 100644 --- a/.python-crypto.metadata +++ b/.python-crypto.metadata @@ -1 +1 @@ -f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c SOURCES/pycrypto-2.6.1.tar.gz +aeda3ed41caf1766409d4efc689b9ca30ad6aeb2 SOURCES/pycrypto-2.6.1.tar.gz diff --git a/SOURCES/pycrypto-2.6.1-CVE-2013-7459.patch b/SOURCES/pycrypto-2.6.1-CVE-2013-7459.patch new file mode 100644 index 0000000..db1f740 --- /dev/null +++ b/SOURCES/pycrypto-2.6.1-CVE-2013-7459.patch @@ -0,0 +1,106 @@ +From 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4 Mon Sep 17 00:00:00 2001 +From: Legrandin +Date: Sun, 22 Dec 2013 22:24:46 +0100 +Subject: [PATCH] Throw exception when IV is used with ECB or CTR + +The IV parameter is currently ignored when initializing +a cipher in ECB or CTR mode. + +For CTR mode, it is confusing: it takes some time to see +that a different parameter is needed (the counter). + +For ECB mode, it is outright dangerous. + +This patch forces an exception to be raised. +--- + lib/Crypto/SelfTest/Cipher/common.py | 31 +++++++++++++++++++++++-------- + src/block_template.c | 11 +++++++++++ + 2 files changed, 34 insertions(+), 8 deletions(-) + +diff --git a/lib/Crypto/SelfTest/Cipher/common.py b/lib/Crypto/SelfTest/Cipher/common.py +index 420b6ff..a5f8a88 100644 +--- a/lib/Crypto/SelfTest/Cipher/common.py ++++ b/lib/Crypto/SelfTest/Cipher/common.py +@@ -239,16 +239,30 @@ class RoundtripTest(unittest.TestCase): + return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,) + + def runTest(self): +- for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB, self.module.MODE_OPENPGP): ++ ++ ## ECB mode ++ mode = self.module.MODE_ECB ++ encryption_cipher = self.module.new(a2b_hex(self.key), mode) ++ ciphertext = encryption_cipher.encrypt(self.plaintext) ++ decryption_cipher = self.module.new(a2b_hex(self.key), mode) ++ decrypted_plaintext = decryption_cipher.decrypt(ciphertext) ++ self.assertEqual(self.plaintext, decrypted_plaintext) ++ ++ ## OPENPGP mode ++ mode = self.module.MODE_OPENPGP ++ encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) ++ eiv_ciphertext = encryption_cipher.encrypt(self.plaintext) ++ eiv = eiv_ciphertext[:self.module.block_size+2] ++ ciphertext = eiv_ciphertext[self.module.block_size+2:] ++ decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv) ++ decrypted_plaintext = decryption_cipher.decrypt(ciphertext) ++ self.assertEqual(self.plaintext, decrypted_plaintext) ++ ++ ## All other non-AEAD modes (but CTR) ++ for mode in (self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB): + encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) + ciphertext = encryption_cipher.encrypt(self.plaintext) +- +- if mode != self.module.MODE_OPENPGP: +- decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) +- else: +- eiv = ciphertext[:self.module.block_size+2] +- ciphertext = ciphertext[self.module.block_size+2:] +- decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv) ++ decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) + decrypted_plaintext = decryption_cipher.decrypt(ciphertext) + self.assertEqual(self.plaintext, decrypted_plaintext) + +diff --git a/src/block_template.c b/src/block_template.c +index f940e0e..d555ceb 100644 +--- a/src/block_template.c ++++ b/src/block_template.c +@@ -170,6 +170,17 @@ ALGnew(PyObject *self, PyObject *args, PyObject *kwdict) + "Key cannot be the null string"); + return NULL; + } ++ if (IVlen != 0 && mode == MODE_ECB) ++ { ++ PyErr_Format(PyExc_ValueError, "ECB mode does not use IV"); ++ return NULL; ++ } ++ if (IVlen != 0 && mode == MODE_CTR) ++ { ++ PyErr_Format(PyExc_ValueError, ++ "CTR mode needs counter parameter, not IV"); ++ return NULL; ++ } + if (IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR) + { + PyErr_Format(PyExc_ValueError, +From 58de28a5d32bc10e15766e5a59f41b07397cc6cb Mon Sep 17 00:00:00 2001 +From: Richard Mitchell +Date: Mon, 28 Apr 2014 16:58:27 +0100 +Subject: [PATCH] Fix speedtest run for ECB modes. + +--- + pct-speedtest.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/pct-speedtest.py b/pct-speedtest.py +index 4ce18be..c7b893a 100644 +--- a/pct-speedtest.py ++++ b/pct-speedtest.py +@@ -121,6 +121,8 @@ class Benchmark: + blocks = self.random_blocks(16384, 1000) + if mode is None: + cipher = module.new(key) ++ elif mode==module.MODE_ECB: ++ cipher = module.new(key, module.MODE_ECB) + else: + cipher = module.new(key, mode, iv) + diff --git a/SOURCES/pycrypto-2.6.1-unbundle-libtomcrypt.patch b/SOURCES/pycrypto-2.6.1-unbundle-libtomcrypt.patch new file mode 100644 index 0000000..00c7676 --- /dev/null +++ b/SOURCES/pycrypto-2.6.1-unbundle-libtomcrypt.patch @@ -0,0 +1,30 @@ +--- setup.py ++++ setup.py +@@ -390,10 +390,12 @@ kw = {'name':"pycrypto", + include_dirs=['src/'], + sources=["src/CAST.c"]), + Extension("Crypto.Cipher._DES", +- include_dirs=['src/', 'src/libtom/'], ++ include_dirs=['src/'], ++ libraries=['tomcrypt'], + sources=["src/DES.c"]), + Extension("Crypto.Cipher._DES3", +- include_dirs=['src/', 'src/libtom/'], ++ include_dirs=['src/'], ++ libraries=['tomcrypt'], + sources=["src/DES3.c"]), + + # Stream ciphers +--- src/DES.c ++++ src/DES.c +@@ -28,8 +28,8 @@ + * assert-like LTC_ARGCHK macro fails. */ + #define ARGTYPE 4 + +-/* Include the actial DES implementation */ +-#include "libtom/tomcrypt_des.c" ++/* Access the actual DES implementation */ ++#include "tomcrypt.h" + + #undef DES /* this is needed because tomcrypt_custom.h defines DES to an empty string */ + diff --git a/SPECS/python-crypto.spec b/SPECS/python-crypto.spec index 3137ef5..086750d 100644 --- a/SPECS/python-crypto.spec +++ b/SPECS/python-crypto.spec @@ -1,45 +1,63 @@ -%global pythonver %(%{__python} -c "import sys; print sys.version[:3]" 2>/dev/null || echo 0.0) -%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)" 2>/dev/null)} +# Share docs between python2 and python3 packages +%global _docdir_fmt %{name} +# Single python3 version in Fedora, python3_pkgversion macro not available +%{!?python3_pkgversion:%global python3_pkgversion 3} + +# For consistency and completeness +%global python2_pkgversion 2 # Python3 introduced in Fedora 13 %global with_python3 %([ 0%{?fedora} -gt 12 ] && echo 1 || echo 0) Summary: Cryptography library for Python Name: python-crypto Version: 2.6.1 -Release: 1%{?dist} +Release: 15%{?dist} # Mostly Public Domain apart from parts of HMAC.py and setup.py, which are Python License: Public Domain and Python -Group: Development/Libraries URL: http://www.pycrypto.org/ Source0: http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-%{version}.tar.gz Patch0: python-crypto-2.4-optflags.patch Patch1: python-crypto-2.4-fix-pubkey-size-divisions.patch -Provides: pycrypto = %{version}-%{release} -BuildRequires: python2-devel >= 2.2, gmp-devel >= 4.1 +Patch2: pycrypto-2.6.1-CVE-2013-7459.patch +Patch3: pycrypto-2.6.1-unbundle-libtomcrypt.patch +BuildRequires: coreutils +BuildRequires: findutils +BuildRequires: gcc +BuildRequires: gmp-devel >= 4.1 +BuildRequires: libtomcrypt-devel >= 1.16 +BuildRequires: python%{python2_pkgversion}-devel %if %{with_python3} +BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python-tools -BuildRequires: python3-devel %endif -BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot-%(id -nu) -# Don't want provides for python shared objects -%{?filter_provides_in: %filter_provides_in %{python_sitearch}/Crypto/.*\.so} -%if %{with_python3} -%{?filter_provides_in: %filter_provides_in %{python3_sitearch}/Crypto/.*\.so} +%description +PyCrypto is a collection of both secure hash functions (such as MD5 and +SHA), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.). + +%package -n python%{python2_pkgversion}-crypto +Summary: Cryptography library for Python 2 +Provides: pycrypto = %{version}-%{release} +%if 0%{?fedora} +%{?python_provide:%python_provide python2-crypto} +%else +Obsoletes: python-crypto <= %{version}-%{release} +Provides: python-crypto = %{version}-%{release} %endif -%{?filter_setup} -%description +%description -n python%{python2_pkgversion}-crypto PyCrypto is a collection of both secure hash functions (such as MD5 and SHA), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.). +This is the Python 2 build of the package. + %if %{with_python3} -%package -n python3-crypto +%package -n python%{python3_pkgversion}-crypto Summary: Cryptography library for Python 3 -Group: Development/Libraries +%{?python_provide:%python_provide python%{python3_pkgversion}-crypto} -%description -n python3-crypto +%description -n python%{python3_pkgversion}-crypto PyCrypto is a collection of both secure hash functions (such as MD5 and SHA), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.). @@ -55,74 +73,117 @@ This is the Python 3 build of the package. # Fix divisions within benchmarking suite: %patch1 -p1 -# Prepare python3 build (setup.py doesn't run 2to3 on pct-speedtest.py) +# AES.new with invalid parameter crashes python +# https://github.com/dlitz/pycrypto/issues/176 +# CVE-2013-7459 +%patch2 -p1 + +# Unbundle libtomcrypt (#1087557) +rm -rf src/libtom +%patch3 + +# setup.py doesn't run 2to3 on pct-speedtest.py %if %{with_python3} -cp -a . %{py3dir} -2to3 -wn %{py3dir}/pct-speedtest.py +cp pct-speedtest.py pct-speedtest3.py +2to3 -wn pct-speedtest3.py %endif %build -CFLAGS="%{optflags} -fno-strict-aliasing" %{__python} setup.py build - +%global optflags %{optflags} -fno-strict-aliasing +#%%py2_build +CFLAGS="%{optflags}" %{__python2} setup.py build %if %{with_python3} -cd %{py3dir} -CFLAGS="%{optflags} -fno-strict-aliasing" %{__python3} setup.py build -cd - +%py3_build %endif %install -rm -rf %{buildroot} -%{__python} setup.py install -O1 --skip-build --root %{buildroot} +%{__python2} setup.py install -O1 --skip-build --root %{buildroot} +#%%py2_install +%if %{with_python3} +%py3_install +%endif # Remove group write permissions on shared objects -find %{buildroot}%{python_sitearch} -name '*.so' -exec chmod -c g-w {} \; - -# Build for python3 too +find %{buildroot}%{python2_sitearch} -name '*.so' -exec chmod -c g-w {} \; %if %{with_python3} -cd %{py3dir} -%{__python3} setup.py install -O1 --skip-build --root %{buildroot} -cd - find %{buildroot}%{python3_sitearch} -name '*.so' -exec chmod -c g-w {} \; %endif -# See if there's any egg-info -if [ -f %{buildroot}%{python_sitearch}/pycrypto-%{version}-py%{pythonver}.egg-info ]; then - echo %{python_sitearch}/pycrypto-%{version}-py%{pythonver}.egg-info -fi > egg-info - %check -%{__python} setup.py test - -# Benchmark uses os.urandom(), which is available from python 2.4 -%if %(%{__python} -c "import sys; print sys.hexversion >= 0x02040000 and 1 or 0" 2>/dev/null || echo 0) -PYTHONPATH=%{buildroot}%{python_sitearch} %{__python} pct-speedtest.py -%endif - -# Test the python3 build too +%{__python2} setup.py test %if %{with_python3} -cd %{py3dir} %{__python3} setup.py test -PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} pct-speedtest.py -cd - %endif -%clean -rm -rf %{buildroot} +# Benchmark +PYTHONPATH=%{buildroot}%{python2_sitearch} %{__python2} pct-speedtest.py +%if %{with_python3} +PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} pct-speedtest3.py +%endif -%files -f egg-info -%defattr(-,root,root,-) -%doc README TODO ACKS ChangeLog LEGAL/ COPYRIGHT Doc/ -%{python_sitearch}/Crypto/ +%files -n python%{python2_pkgversion}-crypto +%license COPYRIGHT LEGAL/ +%doc README TODO ACKS ChangeLog Doc/ +%{python2_sitearch}/Crypto/ +%{python2_sitearch}/pycrypto-%{version}-py2.*.egg-info %if %{with_python3} -%files -n python3-crypto -%defattr(-,root,root,-) -%doc README TODO ACKS ChangeLog LEGAL/ COPYRIGHT Doc/ +%files -n python%{python3_pkgversion}-crypto +%license COPYRIGHT LEGAL/ +%doc README TODO ACKS ChangeLog Doc/ %{python3_sitearch}/Crypto/ -%{python3_sitearch}/pycrypto-*py3.*.egg-info +%{python3_sitearch}/pycrypto-%{version}-py3.*.egg-info %endif %changelog +* Fri May 19 2017 Pavel Cahyna - 2.6.1-15 +- Add Provides and Obsoletes for the python-crypto package now + when the package is named python2-crypto. On Fedora this is + done automatically, but not on RHEL. + +* Fri May 12 2017 Pavel Cahyna - 2.6.1-14 +- Restore the Python 3 conditional builds +- Stop using %%py2_build which we don't have yet on RHEL + +* Wed Jan 18 2017 Paul Howarth - 2.6.1-13 +- AES.new with invalid parameter crashes python (CVE-2013-7459) + (https://github.com/dlitz/pycrypto/issues/176) + +* Fri Dec 09 2016 Charalampos Stratakis - 2.6.1-12 +- Rebuild for Python 3.6 + +* Tue Jul 19 2016 Fedora Release Engineering - 2.6.1-11 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Thu Feb 04 2016 Fedora Release Engineering - 2.6.1-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Dec 30 2015 Paul Howarth - 2.6.1-9 +- Enable python3 builds from EPEL-7 (#1110373) +- Modernize spec + +* Wed Nov 04 2015 Matej Stuchlik - 2.6.1-8 +- Rebuilt for Python 3.5 + +* Thu Jun 18 2015 Fedora Release Engineering - 2.6.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sun Aug 17 2014 Fedora Release Engineering - 2.6.1-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 2.6.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Tue May 27 2014 Paul Howarth - 2.6.1-4 +- Rebuild for python3 3.4 in Rawhide again + +* Wed May 14 2014 Paul Howarth - 2.6.1-3 +- Unbundle libtomcrypt (#1087557) +- Drop %%defattr, redundant since rpm 4.4 + +* Wed May 14 2014 Bohuslav Kabrda - 2.6.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4 + * Fri Oct 18 2013 Paul Howarth - 2.6.1-1 - Update to 2.6.1 - Fix PRNG not correctly reseeded in some situations (CVE-2013-1445) @@ -349,7 +410,7 @@ rm -rf %{buildroot} * Wed Aug 17 2005 Thorsten Leemhuis - 0:2.0.1-1 - Update to 2.0.1 - Use Dist -- Drop python-crypto-64bit-unclean.patch, similar patch was applied +- Drop python-crypto-64bit-unclean.patch, similar patch was applied upstream * Thu May 05 2005 Thorsten Leemhuis - 0:2.0-4