Change-Id: I4c9e323a108cf3bab9d1c25fd0c6f430dae181eb
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3297
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,105 @@ |
| 0 |
+From 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4 Mon Sep 17 00:00:00 2001 |
|
| 1 |
+From: Legrandin <helderijs@gmail.com> |
|
| 2 |
+Date: Sun, 22 Dec 2013 22:24:46 +0100 |
|
| 3 |
+Subject: [PATCH] Throw exception when IV is used with ECB or CTR |
|
| 4 |
+ |
|
| 5 |
+The IV parameter is currently ignored when initializing |
|
| 6 |
+a cipher in ECB or CTR mode. |
|
| 7 |
+ |
|
| 8 |
+For CTR mode, it is confusing: it takes some time to see |
|
| 9 |
+that a different parameter is needed (the counter). |
|
| 10 |
+ |
|
| 11 |
+For ECB mode, it is outright dangerous. |
|
| 12 |
+ |
|
| 13 |
+This patch forces an exception to be raised. |
|
| 14 |
+--- |
|
| 15 |
+ lib/Crypto/SelfTest/Cipher/common.py | 31 +++++++++++++++++++++++-------- |
|
| 16 |
+ src/block_template.c | 11 +++++++++++ |
|
| 17 |
+ 2 files changed, 34 insertions(+), 8 deletions(-) |
|
| 18 |
+ |
|
| 19 |
+diff --git a/lib/Crypto/SelfTest/Cipher/common.py b/lib/Crypto/SelfTest/Cipher/common.py |
|
| 20 |
+index 420b6ff..a5f8a88 100644 |
|
| 21 |
+--- a/lib/Crypto/SelfTest/Cipher/common.py |
|
| 22 |
+@@ -239,16 +239,30 @@ class RoundtripTest(unittest.TestCase): |
|
| 23 |
+ return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,) |
|
| 24 |
+ |
|
| 25 |
+ def runTest(self): |
|
| 26 |
+- for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB, self.module.MODE_OPENPGP): |
|
| 27 |
++ |
|
| 28 |
++ ## ECB mode |
|
| 29 |
++ mode = self.module.MODE_ECB |
|
| 30 |
++ encryption_cipher = self.module.new(a2b_hex(self.key), mode) |
|
| 31 |
++ ciphertext = encryption_cipher.encrypt(self.plaintext) |
|
| 32 |
++ decryption_cipher = self.module.new(a2b_hex(self.key), mode) |
|
| 33 |
++ decrypted_plaintext = decryption_cipher.decrypt(ciphertext) |
|
| 34 |
++ self.assertEqual(self.plaintext, decrypted_plaintext) |
|
| 35 |
++ |
|
| 36 |
++ ## OPENPGP mode |
|
| 37 |
++ mode = self.module.MODE_OPENPGP |
|
| 38 |
++ encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) |
|
| 39 |
++ eiv_ciphertext = encryption_cipher.encrypt(self.plaintext) |
|
| 40 |
++ eiv = eiv_ciphertext[:self.module.block_size+2] |
|
| 41 |
++ ciphertext = eiv_ciphertext[self.module.block_size+2:] |
|
| 42 |
++ decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv) |
|
| 43 |
++ decrypted_plaintext = decryption_cipher.decrypt(ciphertext) |
|
| 44 |
++ self.assertEqual(self.plaintext, decrypted_plaintext) |
|
| 45 |
++ |
|
| 46 |
++ ## All other non-AEAD modes (but CTR) |
|
| 47 |
++ for mode in (self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB): |
|
| 48 |
+ encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) |
|
| 49 |
+ ciphertext = encryption_cipher.encrypt(self.plaintext) |
|
| 50 |
+- |
|
| 51 |
+- if mode != self.module.MODE_OPENPGP: |
|
| 52 |
+- decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) |
|
| 53 |
+- else: |
|
| 54 |
+- eiv = ciphertext[:self.module.block_size+2] |
|
| 55 |
+- ciphertext = ciphertext[self.module.block_size+2:] |
|
| 56 |
+- decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv) |
|
| 57 |
++ decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) |
|
| 58 |
+ decrypted_plaintext = decryption_cipher.decrypt(ciphertext) |
|
| 59 |
+ self.assertEqual(self.plaintext, decrypted_plaintext) |
|
| 60 |
+ |
|
| 61 |
+diff --git a/src/block_template.c b/src/block_template.c |
|
| 62 |
+index f940e0e..d555ceb 100644 |
|
| 63 |
+--- a/src/block_template.c |
|
| 64 |
+@@ -170,6 +170,17 @@ ALGnew(PyObject *self, PyObject *args, PyObject *kwdict) |
|
| 65 |
+ "Key cannot be the null string"); |
|
| 66 |
+ return NULL; |
|
| 67 |
+ } |
|
| 68 |
++ if (IVlen != 0 && mode == MODE_ECB) |
|
| 69 |
++ {
|
|
| 70 |
++ PyErr_Format(PyExc_ValueError, "ECB mode does not use IV"); |
|
| 71 |
++ return NULL; |
|
| 72 |
++ } |
|
| 73 |
++ if (IVlen != 0 && mode == MODE_CTR) |
|
| 74 |
++ {
|
|
| 75 |
++ PyErr_Format(PyExc_ValueError, |
|
| 76 |
++ "CTR mode needs counter parameter, not IV"); |
|
| 77 |
++ return NULL; |
|
| 78 |
++ } |
|
| 79 |
+ if (IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR) |
|
| 80 |
+ {
|
|
| 81 |
+ PyErr_Format(PyExc_ValueError, |
|
| 82 |
+From 58de28a5d32bc10e15766e5a59f41b07397cc6cb Mon Sep 17 00:00:00 2001 |
|
| 83 |
+From: Richard Mitchell <richard.j.mitchell@gmail.com> |
|
| 84 |
+Date: Mon, 28 Apr 2014 16:58:27 +0100 |
|
| 85 |
+Subject: [PATCH] Fix speedtest run for ECB modes. |
|
| 86 |
+ |
|
| 87 |
+--- |
|
| 88 |
+ pct-speedtest.py | 2 ++ |
|
| 89 |
+ 1 file changed, 2 insertions(+) |
|
| 90 |
+ |
|
| 91 |
+diff --git a/pct-speedtest.py b/pct-speedtest.py |
|
| 92 |
+index 4ce18be..c7b893a 100644 |
|
| 93 |
+--- a/pct-speedtest.py |
|
| 94 |
+@@ -121,6 +121,8 @@ class Benchmark: |
|
| 95 |
+ blocks = self.random_blocks(16384, 1000) |
|
| 96 |
+ if mode is None: |
|
| 97 |
+ cipher = module.new(key) |
|
| 98 |
++ elif mode==module.MODE_ECB: |
|
| 99 |
++ cipher = module.new(key, module.MODE_ECB) |
|
| 100 |
+ else: |
|
| 101 |
+ cipher = module.new(key, mode, iv) |
| ... | ... |
@@ -4,11 +4,12 @@ |
| 4 | 4 |
Summary: The Python Cryptography Toolkit. |
| 5 | 5 |
Name: pycrypto |
| 6 | 6 |
Version: 2.6.1 |
| 7 |
-Release: 2%{?dist}
|
|
| 7 |
+Release: 3%{?dist}
|
|
| 8 | 8 |
License: Public Domain and Python |
| 9 | 9 |
URL: http://www.pycrypto.org/ |
| 10 | 10 |
Source0: https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/%{name}-%{version}.tar.gz
|
| 11 | 11 |
%define sha1 pycrypto=aeda3ed41caf1766409d4efc689b9ca30ad6aeb2 |
| 12 |
+Patch0: pycrypto-2.6.1-CVE-2013-7459.patch |
|
| 12 | 13 |
Group: Development/Tools |
| 13 | 14 |
Vendor: VMware, Inc. |
| 14 | 15 |
Distribution: Photon |
| ... | ... |
@@ -30,6 +31,7 @@ Python 3 version. |
| 30 | 30 |
|
| 31 | 31 |
%prep |
| 32 | 32 |
%setup -q |
| 33 |
+%patch0 -p1 |
|
| 33 | 34 |
|
| 34 | 35 |
%build |
| 35 | 36 |
python setup.py build |
| ... | ... |
@@ -48,6 +50,8 @@ python3 setup.py install -O1 --root=%{buildroot} --prefix=/usr
|
| 48 | 48 |
%{python3_sitelib}/*
|
| 49 | 49 |
|
| 50 | 50 |
%changelog |
| 51 |
+* Thu Jul 20 2017 Anish Swaminathan <anishs@vmware.com> 2.6.1-3 |
|
| 52 |
+- Apply patch for CVE-2013-7459 |
|
| 51 | 53 |
* Thu Jul 13 2017 Divya Thaluru <dthaluru@vmware.com> 2.6.1-2 |
| 52 | 54 |
- Downgraded to stable version 2.6.1 |
| 53 | 55 |
* Mon Feb 27 2017 Xiaolin Li <xiaolinl@vmware.com> 2.7a1-3 |