From f83ed1d8afc2cf8cee2a02496ae3cc3cdb3aee77 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sat, 10 Aug 2013 23:28:29 +0200 Subject: [PATCH 01/19] add classifiers, url, description and nose integration for python setup.py test --- setup.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/setup.py b/setup.py index c3b754f3f..d162958b6 100644 --- a/setup.py +++ b/setup.py @@ -18,4 +18,31 @@ setup( name="cryptography", license="Apache License, Version 2.0", install_requires=["cffi>=0.6"], + setup_requires=["nose>=1.0"], + test_suite="nose.collector", + url="https://github.com/alex/cryptography", + description="cryptography is a package designed to expose cryptographic " + "primitives and recipes to Python developers.", + classifiers=[ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX", + "Operating System :: POSIX :: BSD", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Programming Language :: C", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.6", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.2", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Security :: Cryptography", + ], ) From 43f6873de4f5d0763172b017b514ff1f6807249a Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Sat, 10 Aug 2013 22:13:13 +0200 Subject: [PATCH 02/19] Add requirements for code files to CONTRIBUTING --- CONTRIBUTING.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index ff1a619ca..3ee89b80f 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -10,6 +10,13 @@ Code When in doubt, refer to `PEP 8`_ for Python code. +Every code file must start with the boilerplate notice of the Apache License. +Additionally, every Python code file must contain + +.. code-block:: python + + from __future__ import absolute_import, division, print_function + Docs ==== @@ -17,12 +24,12 @@ Write docstrings like this: .. code-block:: python - def some_function(some_arg): - """ - Does some things. + def some_function(some_arg): + """ + Does some things. - :param some_arg: Some argument. - """ + :param some_arg: Some argument. + """ So, specifically: From 9f3468dcfc92fca43ac105204427d03c863b4b4b Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 08:17:48 -0400 Subject: [PATCH 03/19] Better describe why this library exists. Refs #5 --- README.rst | 7 ------- docs/index.rst | 13 +++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 4379bb58b..8cf84d826 100644 --- a/README.rst +++ b/README.rst @@ -12,10 +12,3 @@ recipes to Python developers. It is currently in early development and isn't recommended for general usage yet. It targets Python 2.6-2.7, Python 3.2+, as well as PyPy. - -Why a new crypto library for Python? ------------------------------------- - -None of the existing ones work on PyPy, and many of them are unmaintained or -are based around very poor implementations of algorithms (i.e ones with known -side-channel attacks). diff --git a/docs/index.rst b/docs/index.rst index 1d8ffda62..a061b3e7a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,6 +8,19 @@ Welcome to ``cryptography`` ``cryptography`` is a Python library which exposes cryptographic primitives and recipes. +Why a new crypto library for Python? +------------------------------------ + +We wanted to address a few issues with existing cryptography libraries in +Python: + +* Lack of PyPy support +* Lack of maintenance +* Use poor implementations of algorithms (i.e. ones with known side-channel + attacks) +* Lack of high level, "Cryptography for humans", APIs + + Contents: .. toctree:: From 3538fdbc5c85485628ac220f1287537b01fb6b11 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 08:18:40 -0400 Subject: [PATCH 04/19] Make this a heading --- docs/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index a061b3e7a..998515772 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,7 +21,8 @@ Python: * Lack of high level, "Cryptography for humans", APIs -Contents: +Contents +-------- .. toctree:: :maxdepth: 2 From ec4ba7385752812d2acd113fc7f2e1529402c504 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 08:19:05 -0400 Subject: [PATCH 05/19] Better gramar --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 998515772..c7f02da72 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,7 +16,7 @@ Python: * Lack of PyPy support * Lack of maintenance -* Use poor implementations of algorithms (i.e. ones with known side-channel +* Use of poor implementations of algorithms (i.e. ones with known side-channel attacks) * Lack of high level, "Cryptography for humans", APIs From 711b01409f620f7aec0b262cac32f19abc66ef9f Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 08:24:12 -0400 Subject: [PATCH 06/19] Link the docs in the readme --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 4379bb58b..a8c91223b 100644 --- a/README.rst +++ b/README.rst @@ -13,9 +13,15 @@ recipes to Python developers. It is currently in early development and isn't recommended for general usage yet. It targets Python 2.6-2.7, Python 3.2+, as well as PyPy. +You can more documentation at `Read The Docs`_. + +.. _`Read The Docs`: https://cryptography.readthedocs.org/ + + Why a new crypto library for Python? ------------------------------------ None of the existing ones work on PyPy, and many of them are unmaintained or are based around very poor implementations of algorithms (i.e ones with known side-channel attacks). + From 3e989d60886d2c75eefe58a3f673f9687175d8ab Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 08:26:30 -0400 Subject: [PATCH 07/19] Dropped a word --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a8c91223b..77fcc6ca7 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ recipes to Python developers. It is currently in early development and isn't recommended for general usage yet. It targets Python 2.6-2.7, Python 3.2+, as well as PyPy. -You can more documentation at `Read The Docs`_. +You can find more documentation at `Read The Docs`_. .. _`Read The Docs`: https://cryptography.readthedocs.org/ From aa66554116d47ef725b5617b814034e0140560a8 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 08:41:03 -0400 Subject: [PATCH 08/19] Document that we want AES-GCM --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index c7f02da72..f1a0cd84e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,6 +19,7 @@ Python: * Use of poor implementations of algorithms (i.e. ones with known side-channel attacks) * Lack of high level, "Cryptography for humans", APIs +* Absence of algorithms such as AES-GCM Contents From 4373d7a2939454a976c0fcd08f756f793058d1d5 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 08:57:17 -0400 Subject: [PATCH 09/19] Added another item from hynek --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index f1a0cd84e..49e7b29e7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,6 +20,7 @@ Python: attacks) * Lack of high level, "Cryptography for humans", APIs * Absence of algorithms such as AES-GCM +* Poor introspectability, and thus poor testability Contents From b55f9269ec5d9674bc76fe652f54a62322ee9577 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 11 Aug 2013 15:09:21 +0200 Subject: [PATCH 10/19] use py.test for testing correct cffi dependency to setup_requires ignore cffi, pycparser and pytest egg directories add myself to AUTHORS.rst --- .gitignore | 3 +++ AUTHORS.rst | 2 ++ setup.py | 27 +++++++++++++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2bf40e7c6..886683e31 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ _build/ .tox/ *.egg-info/ .coverage +cffi-*.egg/ +pycparser-*.egg/ +pytest-*.egg/ diff --git a/AUTHORS.rst b/AUTHORS.rst index 06e23d1f8..3438aa046 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -5,3 +5,5 @@ AUTHORS * Hynek Schlawack * Donald Stufft * Laurens Van Houtven <_@lvh.io> +* Christian Heimes + diff --git a/setup.py b/setup.py index d162958b6..2b9353408 100644 --- a/setup.py +++ b/setup.py @@ -11,18 +11,33 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys from setuptools import setup +from setuptools.command.test import test as TestCommand + + +class PyTest(TestCommand): + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + + def run_tests(self): + import pytest + errno = pytest.main(self.test_args) + sys.exit(errno) setup( name="cryptography", - license="Apache License, Version 2.0", - install_requires=["cffi>=0.6"], - setup_requires=["nose>=1.0"], - test_suite="nose.collector", - url="https://github.com/alex/cryptography", description="cryptography is a package designed to expose cryptographic " "primitives and recipes to Python developers.", + license="Apache License, Version 2.0", + url="https://github.com/alex/cryptography", + zip_safe=False, # for cffi + setup_requires=["cffi>=0.6"], + tests_require=["pytest"], + cmdclass = {"test": PyTest}, classifiers=[ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", @@ -33,7 +48,7 @@ setup( "Operating System :: POSIX :: BSD", "Operating System :: POSIX :: Linux", "Operating System :: Microsoft :: Windows", - "Programming Language :: C", + #"Programming Language :: cffi", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", From d6bef56f290dbc4354ab90d9cdffccb8704522bc Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 09:09:28 -0400 Subject: [PATCH 11/19] English grammar --- docs/index.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 49e7b29e7..12e74ed87 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,13 +14,13 @@ Why a new crypto library for Python? We wanted to address a few issues with existing cryptography libraries in Python: -* Lack of PyPy support -* Lack of maintenance +* Lack of PyPy support. +* Lack of maintenance. * Use of poor implementations of algorithms (i.e. ones with known side-channel - attacks) -* Lack of high level, "Cryptography for humans", APIs -* Absence of algorithms such as AES-GCM -* Poor introspectability, and thus poor testability + attacks). +* Lack of high level, "Cryptography for humans", APIs. +* Absence of algorithms such as AES-GCM. +* Poor introspectability, and thus poor testability. Contents From f0d139aa2d9d194dcf7ace775053039e0724bb11 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Aug 2013 09:13:27 -0400 Subject: [PATCH 12/19] Another issue we're targetting --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index 12e74ed87..29f0b5455 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,6 +21,7 @@ Python: * Lack of high level, "Cryptography for humans", APIs. * Absence of algorithms such as AES-GCM. * Poor introspectability, and thus poor testability. +* Extremely error prone APIs, and bad defaults. Contents From ff1e64fd4ad32227f34e6ff2210c56e1a3db0d7d Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 11 Aug 2013 15:33:51 +0200 Subject: [PATCH 13/19] drop setup.py test again --- setup.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/setup.py b/setup.py index 2b9353408..7fc10b4cc 100644 --- a/setup.py +++ b/setup.py @@ -13,20 +13,6 @@ import sys from setuptools import setup -from setuptools.command.test import test as TestCommand - - -class PyTest(TestCommand): - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - import pytest - errno = pytest.main(self.test_args) - sys.exit(errno) - setup( name="cryptography", @@ -36,8 +22,6 @@ setup( url="https://github.com/alex/cryptography", zip_safe=False, # for cffi setup_requires=["cffi>=0.6"], - tests_require=["pytest"], - cmdclass = {"test": PyTest}, classifiers=[ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", From 913bcb79c581992d99bd33c629631f78364b0cfe Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 11 Aug 2013 15:35:40 +0200 Subject: [PATCH 14/19] super nit-pick --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7fc10b4cc..30b795b59 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,8 @@ setup( "primitives and recipes to Python developers.", license="Apache License, Version 2.0", url="https://github.com/alex/cryptography", - zip_safe=False, # for cffi + # for cffi + zip_safe=False, setup_requires=["cffi>=0.6"], classifiers=[ "Development Status :: 2 - Pre-Alpha", From 7fe70cb233d9489488d3be297d0daf0b3523b7bc Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 11 Aug 2013 15:52:21 +0200 Subject: [PATCH 15/19] hyper nit-pick --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 30b795b59..fe23f3027 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys from setuptools import setup setup( From 292112bc875016fd08198fe72091ab32f48f515b Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Sun, 11 Aug 2013 14:32:17 -0400 Subject: [PATCH 16/19] Make the example error free Without padding b"my secret message" is not divisible by AES's block size and thus would throw an error. --- docs/primitives/symmetric-encryption.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/primitives/symmetric-encryption.rst b/docs/primitives/symmetric-encryption.rst index 0812f6b93..9986d89d2 100644 --- a/docs/primitives/symmetric-encryption.rst +++ b/docs/primitives/symmetric-encryption.rst @@ -14,7 +14,7 @@ where the encrypter and decrypter both use the same key. >>> from cryptography.primitives.block import BlockCipher, ciphers, modes >>> cipher = BlockCipher(ciphers.AES(key), modes.CBC(iv)) - >>> cipher.encrypt("my secret message") + cipher.finalize() + >>> cipher.encrypt(b"a secret message") + cipher.finalize() # The ciphertext [...] From 5f12a1b89a46f028582945dff23a97c53e8ae2c5 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Sun, 11 Aug 2013 16:37:43 -0400 Subject: [PATCH 17/19] Fix the packaging meta-data --- cryptography/__about__.py | 32 ++++++++++++++++++++++++++++++ cryptography/__init__.py | 22 +++++++++++++++++++++ setup.py | 41 ++++++++++++++++++++++++++++++--------- 3 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 cryptography/__about__.py diff --git a/cryptography/__about__.py b/cryptography/__about__.py new file mode 100644 index 000000000..16d631fd2 --- /dev/null +++ b/cryptography/__about__.py @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from __future__ import absolute_import, division, print_function + +__all__ = [ + "__title__", "__summary__", "__uri__", "__version__", "__author__", + "__email__", "__license__", "__copyright__", +] + +__title__ = "cryptography" +__summary__ = ("cryptography is a package designed to expose cryptographic " + "primitives and recipes to Python developers.") +__uri__ = "https://github.com/alex/cryptography" + +__version__ = "0.1.dev1" + +__author__ = ("Alex Gaynor, Donald Stufft, Laurens van Houvten, " + "Jean-Paul Calderone, Chris Heime, and Indivdual Contributors") +__email__ = "cryptography-dev@python.org" + +__license__ = "Apache License, Version 2.0" +__copyright__ = "Copyright 2013 Donald Stufft" diff --git a/cryptography/__init__.py b/cryptography/__init__.py index e69de29bb..f37bd2276 100644 --- a/cryptography/__init__.py +++ b/cryptography/__init__.py @@ -0,0 +1,22 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from cryptography.__about__ import ( + __title__, __summary__, __uri__, __version__, __author__, __email__, + __license__, __copyright__ +) + + +__all__ = [ + "__title__", "__summary__", "__uri__", "__version__", "__author__", + "__email__", "__license__", "__copyright__", +] diff --git a/setup.py b/setup.py index fe23f3027..7fe90d9c7 100644 --- a/setup.py +++ b/setup.py @@ -10,18 +10,35 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. - from setuptools import setup +about = {} +with open("cryptography/__about__.py") as fp: + exec(fp.read(), about) + + +CFFI_DEPENDENCY = "cffi>=0.6" + +install_requires = [ + CFFI_DEPENDENCY, +] + +setup_requires = [ + CFFI_DEPENDENCY, +] + + setup( - name="cryptography", - description="cryptography is a package designed to expose cryptographic " - "primitives and recipes to Python developers.", - license="Apache License, Version 2.0", - url="https://github.com/alex/cryptography", - # for cffi - zip_safe=False, - setup_requires=["cffi>=0.6"], + name=about["__title__"], + version=about["__version__"], + + description=about["__summary__"], + license=about["__license__"], + url=about["__uri__"], + + author=about["__author__"], + author_email=about["__email__"], + classifiers=[ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", @@ -44,4 +61,10 @@ setup( "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Security :: Cryptography", ], + + install_requires=install_requires, + setup_requires=setup_requires, + + # for cffi + zip_safe=False, ) From 9ebb8ff06ceb8b65bf41a9f1c907dbddfeabd2ed Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Sun, 11 Aug 2013 17:05:03 -0400 Subject: [PATCH 18/19] Include all of our files in the distributions, and install packages --- MANIFEST.in | 7 +++++++ setup.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..a0d91cecc --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +include LICENSE +include AUTHORS.rst +include CONTRIBUTING.rst +include README.rst + +recursive-include tests *.py +recursive-include tests/primitives/vectors * diff --git a/setup.py b/setup.py index 7fe90d9c7..e1cc23944 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -from setuptools import setup +from setuptools import setup, find_packages about = {} with open("cryptography/__about__.py") as fp: @@ -62,6 +62,8 @@ setup( "Topic :: Security :: Cryptography", ], + packages=find_packages(exclude=["tests", "tests.*"]), + install_requires=install_requires, setup_requires=setup_requires, From 4c1852c74bc77ad82f198245a79cbcb75c832072 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Sun, 11 Aug 2013 17:05:41 -0400 Subject: [PATCH 19/19] Ignore the dist directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 886683e31..ecf07a08c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ _build/ cffi-*.egg/ pycparser-*.egg/ pytest-*.egg/ +dist/