summaryrefslogtreecommitdiff
path: root/dev-python/pycrypto
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/pycrypto')
-rw-r--r--dev-python/pycrypto/Manifest5
-rw-r--r--dev-python/pycrypto/files/pycrypto-2.6.1-CVE-2013-7459.patch88
-rw-r--r--dev-python/pycrypto/files/pycrypto-2.6.1-cross-compile.patch13
-rw-r--r--dev-python/pycrypto/metadata.xml34
-rw-r--r--dev-python/pycrypto/pycrypto-2.6.1-r2.ebuild75
5 files changed, 215 insertions, 0 deletions
diff --git a/dev-python/pycrypto/Manifest b/dev-python/pycrypto/Manifest
new file mode 100644
index 000000000000..eddae4818e8d
--- /dev/null
+++ b/dev-python/pycrypto/Manifest
@@ -0,0 +1,5 @@
+AUX pycrypto-2.6.1-CVE-2013-7459.patch 3808 BLAKE2B a13ec783c0a99f06efba4caa2f77cc101bad577c47eeea58a53aaca343fb6caa4ba6e617c5ff07808781c2fe71a2f48fd9a3ec4aa18d504d56ab0e7a2ec9f40c SHA512 b34a28fa886ad749878aee17459307fb3006f392304a368e9c80b9beac78b1bca2f35831664e504097996ae1be4e1e81eae5e68b211e47fbf11f2b05b2379fb8
+AUX pycrypto-2.6.1-cross-compile.patch 489 BLAKE2B e4505725793379547d13a3b08b3621471ae0828915c48253aba778b576c3b379267210e5e763ce9f78f3f9ff992b2521c9a9940c744042d16ba992b9e5728b17 SHA512 fbf1f5b6d065725e84594c1493d0d795a9f8c73d9e873f28b473ebc6bf2f346330d5a92362e1dc09f465227f0bc839ccfaf8dc0011c21323ac80931f74b16fca
+DIST pycrypto-2.6.1.tar.gz 446240 BLAKE2B 89c9cc5b8cbd446364bd56c170c2733b960ec269a6691085392b3cc0ebc2eb244721f6763ed72a1254f90bfaadee2cc1a8446865a95fca19ffb36700d89711a9 SHA512 20a4aed4dac4e9e61d773ebc1d48ea577e9870c33f396be53d075a9bf8487d93e75e200179882d81e452efd0f6751789bac434f6f431b3e7c1c8ef9dba392847
+EBUILD pycrypto-2.6.1-r2.ebuild 2092 BLAKE2B b1176d816528ba5a8e7354dc68f2cdcd229306ed4139b08d6fdbb458617cacc3c50eb5ce1b067a5e00d47981dddc73f0d9155cf9f781d744b37ca916f5f1c2de SHA512 72828f96c1876197ac7f6906f4dacf3ce362ed1fdd115cbc7685394e9d4aa00c6aa498a5d22ca8728829623a07d6589d4cf7a0f86639cb3f0d4b1de8749cf298
+MISC metadata.xml 1797 BLAKE2B 0880d583a65ca52fccc51fc6451205ad5ff2bdb49e861c8abc3586e396fdff72fb1b30082b44eb6a48c4e5be32895a5e4a74642821b9025e8ec0b1d81ee7620e SHA512 63afa4bd18299965a4e5ae4690ece849a00d568cbae5bc4d7983f4299fa0755c5cced81a8d160820b3b3f1772c5b40d0e81d8ac2b4e784f4017400acb592ba65
diff --git a/dev-python/pycrypto/files/pycrypto-2.6.1-CVE-2013-7459.patch b/dev-python/pycrypto/files/pycrypto-2.6.1-CVE-2013-7459.patch
new file mode 100644
index 000000000000..9850f0340510
--- /dev/null
+++ b/dev-python/pycrypto/files/pycrypto-2.6.1-CVE-2013-7459.patch
@@ -0,0 +1,88 @@
+From 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4 Mon Sep 17 00:00:00 2001
+From: Legrandin <helderijs@gmail.com>
+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,19 +239,34 @@ def shortDescription(self):
+ 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)
+
++
+ class PGPTest(unittest.TestCase):
+ def __init__(self, module, params):
+ unittest.TestCase.__init__(self)
+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,
diff --git a/dev-python/pycrypto/files/pycrypto-2.6.1-cross-compile.patch b/dev-python/pycrypto/files/pycrypto-2.6.1-cross-compile.patch
new file mode 100644
index 000000000000..2ce24a49cc71
--- /dev/null
+++ b/dev-python/pycrypto/files/pycrypto-2.6.1-cross-compile.patch
@@ -0,0 +1,13 @@
+do not hardcode -I/usr/include as it's useless and breaks cross-compiles
+
+--- a/setup.py
++++ b/setup.py
+@@ -370,7 +370,7 @@ kw = {'name':"pycrypto",
+ 'ext_modules': plat_ext + [
+ # _fastmath (uses GNU mp library)
+ Extension("Crypto.PublicKey._fastmath",
+- include_dirs=['src/','/usr/include/'],
++ include_dirs=['src/'],
+ libraries=['gmp'],
+ sources=["src/_fastmath.c"]),
+
diff --git a/dev-python/pycrypto/metadata.xml b/dev-python/pycrypto/metadata.xml
new file mode 100644
index 000000000000..e14ce6691800
--- /dev/null
+++ b/dev-python/pycrypto/metadata.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="project">
+ <email>python@gentoo.org</email>
+ <name>Python</name>
+ </maintainer>
+ <longdescription>
+ The Python Cryptography Toolkit is a collection of cryptographic
+ algorithms and protocols, implemented for use from Python. Among
+ the contents of the package:
+
+ * Hash functions: MD2, MD4, RIPEMD, SHA256.
+ * Block encryption algorithms: AES, ARC2, Blowfish, CAST, DES, Triple-DES, IDEA, RC5.
+ * Stream encryption algorithms: ARC4, simple XOR.
+ * Public-key algorithms: RSA, DSA, ElGamal, qNEW.
+ * Protocols: All-or-nothing transforms, chaffing/winnowing.
+ * Miscellaneous: RFC1751 module for converting 128-key keys into a set of English words, primality testing.
+ * Some demo programs (currently all quite old and outdated).
+ </longdescription>
+ <longdescription lang="ja">
+ このPython言語のクリプトグラフィー・ツールキットは、暗号手法のアルゴリズムとプロ
+ トコルの集合で、Python言語から利用されるための実装です。このパッケージ内容は以下
+ です。
+
+ * Hash ファンクション: MD2, MD4, RIPEMD, SHA256.
+ * ブロック・エンクリプション・アルゴリズム: AES, ARC2, Blowfish, CAST, DES, Triple-DES, IDEA, RC5.
+ * ストリーム・エンクリプション・アルゴリズム: ARC4, simple XOR.
+ * 公開鍵アルゴリズム: RSA, DSA, ElGamal, qNEW.
+ * プロトコル: All-or-nothing transforms, chaffing/winnowing.
+ * その他: RFC1751 module for converting 128-key keys into a set of English words, primality testing.
+ * デモ・プログラム(現在では完全に古く時代遅れなもの)
+ </longdescription>
+</pkgmetadata>
diff --git a/dev-python/pycrypto/pycrypto-2.6.1-r2.ebuild b/dev-python/pycrypto/pycrypto-2.6.1-r2.ebuild
new file mode 100644
index 000000000000..33ff67ea4eba
--- /dev/null
+++ b/dev-python/pycrypto/pycrypto-2.6.1-r2.ebuild
@@ -0,0 +1,75 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
+PYTHON_REQ_USE="threads(+)"
+
+inherit distutils-r1 flag-o-matic
+
+DESCRIPTION="Python Cryptography Toolkit"
+HOMEPAGE="https://www.dlitz.net/software/pycrypto/
+ https://pypi.org/project/pycrypto/"
+SRC_URI="http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/${P}.tar.gz"
+
+LICENSE="PSF-2 public-domain"
+SLOT="0"
+KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~m68k ~mips ppc ppc64 ~s390 ~sh sparc x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~x86-solaris"
+IUSE="doc +gmp test"
+
+RDEPEND="gmp? ( dev-libs/gmp:0= )"
+DEPEND="${RDEPEND}
+ doc? (
+ dev-python/docutils[${PYTHON_USEDEP}]
+ $(python_gen_cond_dep '>=dev-python/epydoc-3[${PYTHON_USEDEP}]' 'python2*')
+ )"
+
+REQUIRED_USE="test? ( gmp )"
+
+DOCS=( ACKS ChangeLog README TODO )
+PATCHES=(
+ "${FILESDIR}"/${P}-cross-compile.patch
+ "${FILESDIR}"/${P}-CVE-2013-7459.patch
+)
+
+python_prepare_all() {
+ # Fix Crypto.PublicKey.RSA._RSAobj.exportKey(format="OpenSSH") with Python 3
+ # https://github.com/dlitz/pycrypto/commit/ab25c6fe95ee92fac3187dcd90e0560ccacb084a
+ sed \
+ -e "/keyparts =/s/'ssh-rsa'/b('ssh-rsa')/" \
+ -e "s/keystring = ''.join/keystring = b('').join/" \
+ -e "s/return 'ssh-rsa '/return b('ssh-rsa ')/" \
+ -i lib/Crypto/PublicKey/RSA.py || die
+
+ distutils-r1_python_prepare_all
+}
+
+python_configure_all() {
+ # the configure does not interact with python in any way,
+ # it just sets up the C header file.
+ econf \
+ $(use_with gmp) \
+ --without-mpir
+}
+
+python_compile_all() {
+ if use doc; then
+ rst2html.py Doc/pycrypt.rst > Doc/index.html || die
+ epydoc --config=Doc/epydoc-config --exclude-introspect="^Crypto\.(Random\.OSRNG\.nt|Util\.winrandom)$" || die
+ HTML_DOCS=( Doc/apidoc/. Doc/index.html )
+ fi
+}
+
+python_compile() {
+ if ! python_is_python3; then
+ local -x CFLAGS="${CFLAGS}"
+ append-cflags -fno-strict-aliasing
+ fi
+
+ distutils-r1_python_compile
+}
+
+python_test() {
+ esetup.py test
+}