Commit 46a3b620 authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 0.3

parent 58f657b0
......@@ -6,7 +6,7 @@ PGP key fingerprints are enclosed in parentheses.
* Alex Gaynor <alex.gaynor@gmail.com> (E27D 4AA0 1651 72CB C5D2 AF2B 125F 5C67 DFE9 4084)
* Hynek Schlawack <hs@ox.cx> (C2A0 4F86 ACE2 8ADC F817 DBB7 AE25 3622 7F69 F181)
* Donald Stufft <donald@stufft.io>
* Laurens Van Houtven <_@lvh.io>
* Laurens Van Houtven <_@lvh.io> (D9DC 4315 772F 8E91 DD22 B153 DFD1 3DF7 A8DD 569B)
* Christian Heimes <christian@python.org>
* Paul Kehrer <paul.l.kehrer@gmail.com>
* Jarret Raim <jarito@gmail.com>
......@@ -14,3 +14,6 @@ PGP key fingerprints are enclosed in parentheses.
* David Reid <dreid@dreid.org> (0F83 CC87 B32F 482B C726 B58A 9FBF D8F4 DA89 6D74)
* Konstantinos Koukopoulos <koukopoulos@gmail.com> (D6BD 52B6 8C99 A91C E2C8 934D 3300 566B 3A46 726E)
* Stephen Holsapple <sholsapp@gmail.com>
* Terry Chia <terrycwk1994@gmail.com>
* Matthew Iversen <matt@notevencode.com> (2F04 3DCC D6E6 D5AC D262 2E0B C046 E8A8 7452 2973)
* Mohammed Attia <skeuomorf@gmail.com>
Changelog
=========
0.3 - 2014-03-27
~~~~~~~~~~~~~~~~
* Added :class:`~cryptography.hazmat.primitives.twofactor.hotp.HOTP`.
* Added :class:`~cryptography.hazmat.primitives.twofactor.totp.TOTP`.
* Added :class:`~cryptography.hazmat.primitives.ciphers.algorithms.IDEA` support.
* Added signature support to :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`
and verification support to :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`.
* Moved test vectors to the new ``cryptography_vectors`` package.
0.2.2 - 2014-03-03
~~~~~~~~~~~~~~~~~~
* Removed a constant definition that was causing compilation problems with specific versions of OpenSSL.
0.2.1 - 2014-02-22
~~~~~~~~~~~~~~~~~~
* Fix a bug where importing cryptography from multiple paths could cause initialization to fail.
0.2 - 2014-02-20
~~~~~~~~~~~~~~~~
* Added :doc:`/hazmat/backends/commoncrypto`.
* Added initial :doc:`/hazmat/bindings/commoncrypto`.
* Removed ``register_cipher_adapter`` method from
:class:`~cryptography.hazmat.backends.interfaces.CipherBackend`.
* Added support for the OpenSSL backend under Windows.
* Improved thread-safety for the OpenSSL backend.
* Fixed compilation on systems where OpenSSL's ``ec.h`` header is not
available, such as CentOS.
* Added :class:`~cryptography.hazmat.primitives.kdf.pbkdf2.PBKDF2HMAC`.
* Added :class:`~cryptography.hazmat.primitives.kdf.hkdf.HKDF`.
* Added :doc:`/hazmat/backends/multibackend`.
* Set default random for the :doc:`/hazmat/backends/openssl` to the OS random engine.
* Added :class:`~cryptography.hazmat.primitives.ciphers.algorithms.CAST5` (CAST-128) support.
0.1 - 2014-01-08
~~~~~~~~~~~~~~~~
* Initial release.
.. _`master`: https://github.com/pyca/cryptography/
......@@ -10,9 +10,9 @@ Examples of contributions include:
* Bug reports and patch reviews
Extensive contribution guidelines are available in the repository at
``docs/contributing.rst``, or online at:
``docs/development/index.rst``, or online at:
https://cryptography.io/en/latest/contributing/
https://cryptography.io/en/latest/development/
Security issues
---------------
......
include LICENSE
include AUTHORS.rst
include CHANGELOG.rst
include CONTRIBUTING.rst
include LICENSE
include README.rst
recursive-include docs *
prune docs/_build
recursive-include tests *.py
recursive-include tests/vectors *
recursive-include tests/hazmat/primitives/vectors *
recursive-exclude vectors *
Metadata-Version: 1.1
Name: cryptography
Version: 0.2
Summary: cryptography is a package designed to expose cryptographic recipes and primitives to Python developers.
Version: 0.3
Summary: cryptography is a package which provides cryptographic recipes and primitives to Python developers.
Home-page: https://github.com/pyca/cryptography
Author: The cryptography developers
Author-email: cryptography-dev@python.org
......@@ -9,14 +9,14 @@ License: Apache License, Version 2.0
Description: Cryptography
============
.. image:: https://travis-ci.org/pyca/cryptography.png?branch=master
.. image:: https://travis-ci.org/pyca/cryptography.svg?branch=master
:target: https://travis-ci.org/pyca/cryptography
.. image:: https://coveralls.io/repos/pyca/cryptography/badge.png?branch=master
:target: https://coveralls.io/r/pyca/cryptography?branch=master
``cryptography`` is a package designed to expose cryptographic recipes and
``cryptography`` is a package which provides cryptographic recipes and
primitives to Python developers. Our goal is for it to be your "cryptographic
standard library". It supports Python 2.6-2.7, Python 3.2+, and PyPy.
......@@ -70,6 +70,7 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Security :: Cryptography
Cryptography
============
.. image:: https://travis-ci.org/pyca/cryptography.png?branch=master
.. image:: https://travis-ci.org/pyca/cryptography.svg?branch=master
:target: https://travis-ci.org/pyca/cryptography
.. image:: https://coveralls.io/repos/pyca/cryptography/badge.png?branch=master
:target: https://coveralls.io/r/pyca/cryptography?branch=master
``cryptography`` is a package designed to expose cryptographic recipes and
``cryptography`` is a package which provides cryptographic recipes and
primitives to Python developers. Our goal is for it to be your "cryptographic
standard library". It supports Python 2.6-2.7, Python 3.2+, and PyPy.
......
Metadata-Version: 1.1
Name: cryptography
Version: 0.2
Summary: cryptography is a package designed to expose cryptographic recipes and primitives to Python developers.
Version: 0.3
Summary: cryptography is a package which provides cryptographic recipes and primitives to Python developers.
Home-page: https://github.com/pyca/cryptography
Author: The cryptography developers
Author-email: cryptography-dev@python.org
......@@ -9,14 +9,14 @@ License: Apache License, Version 2.0
Description: Cryptography
============
.. image:: https://travis-ci.org/pyca/cryptography.png?branch=master
.. image:: https://travis-ci.org/pyca/cryptography.svg?branch=master
:target: https://travis-ci.org/pyca/cryptography
.. image:: https://coveralls.io/repos/pyca/cryptography/badge.png?branch=master
:target: https://coveralls.io/r/pyca/cryptography?branch=master
``cryptography`` is a package designed to expose cryptographic recipes and
``cryptography`` is a package which provides cryptographic recipes and
primitives to Python developers. Our goal is for it to be your "cryptographic
standard library". It supports Python 2.6-2.7, Python 3.2+, and PyPy.
......@@ -70,6 +70,7 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Security :: Cryptography
This diff is collapsed.
......@@ -18,11 +18,11 @@ __all__ = [
]
__title__ = "cryptography"
__summary__ = ("cryptography is a package designed to expose cryptographic "
"recipes and primitives to Python developers.")
__summary__ = ("cryptography is a package which provides cryptographic recipes"
" and primitives to Python developers.")
__uri__ = "https://github.com/pyca/cryptography"
__version__ = "0.2"
__version__ = "0.3"
__author__ = "The cryptography developers"
__email__ = "cryptography-dev@python.org"
......
......@@ -10,9 +10,12 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
from cryptography.__about__ import (
__title__, __summary__, __uri__, __version__, __author__, __email__,
__license__, __copyright__
__author__, __copyright__, __email__, __license__, __summary__, __title__,
__uri__, __version__
)
......
......@@ -11,9 +11,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
class _Reasons(object):
BACKEND_MISSING_INTERFACE = object()
UNSUPPORTED_HASH = object()
UNSUPPORTED_CIPHER = object()
UNSUPPORTED_PADDING = object()
class UnsupportedAlgorithm(Exception):
pass
def __init__(self, message, reason=None):
super(UnsupportedAlgorithm, self).__init__(message)
self._reason = reason
class AlreadyFinalized(Exception):
......@@ -42,3 +53,7 @@ class InternalError(Exception):
class InvalidKey(Exception):
pass
class InvalidToken(Exception):
pass
......@@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
import base64
import binascii
import os
......@@ -21,7 +23,7 @@ import six
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding, hashes
from cryptography.hazmat.primitives import hashes, padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.hmac import HMAC
......
......@@ -10,3 +10,5 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
......@@ -11,21 +11,44 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from cryptography.hazmat.backends import openssl
from __future__ import absolute_import, division, print_function
from cryptography.hazmat.backends.multibackend import MultiBackend
from cryptography.hazmat.bindings.commoncrypto.binding import (
Binding as CommonCryptoBinding
)
from cryptography.hazmat.bindings.openssl.binding import (
Binding as OpenSSLBinding
)
_available_backends_list = None
_ALL_BACKENDS = [openssl.backend]
def _available_backends():
global _available_backends_list
if CommonCryptoBinding.is_available():
from cryptography.hazmat.backends import commoncrypto
_ALL_BACKENDS.append(commoncrypto.backend)
if _available_backends_list is None:
_available_backends_list = []
if CommonCryptoBinding.is_available():
from cryptography.hazmat.backends import commoncrypto
_available_backends_list.append(commoncrypto.backend)
_default_backend = MultiBackend(_ALL_BACKENDS)
if OpenSSLBinding.is_available():
from cryptography.hazmat.backends import openssl
_available_backends_list.append(openssl.backend)
return _available_backends_list
_default_backend = None
def default_backend():
global _default_backend
if _default_backend is None:
_default_backend = MultiBackend(_available_backends())
return _default_backend
......@@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
from cryptography.hazmat.backends.commoncrypto.backend import backend
......
......@@ -17,18 +17,18 @@ from collections import namedtuple
from cryptography import utils
from cryptography.exceptions import (
UnsupportedAlgorithm, InvalidTag, InternalError
InternalError, InvalidTag, UnsupportedAlgorithm, _Reasons
)
from cryptography.hazmat.backends.interfaces import (
HashBackend, HMACBackend, CipherBackend, PBKDF2HMACBackend
CipherBackend, HMACBackend, HashBackend, PBKDF2HMACBackend
)
from cryptography.hazmat.bindings.commoncrypto.binding import Binding
from cryptography.hazmat.primitives import interfaces, constant_time
from cryptography.hazmat.primitives import constant_time, interfaces
from cryptography.hazmat.primitives.ciphers.algorithms import (
AES, Blowfish, TripleDES, ARC4, CAST5
AES, ARC4, Blowfish, CAST5, TripleDES
)
from cryptography.hazmat.primitives.ciphers.modes import (
CBC, CTR, ECB, OFB, CFB, GCM
CBC, CFB, CTR, ECB, GCM, OFB
)
......@@ -276,7 +276,8 @@ class _CipherContext(object):
raise UnsupportedAlgorithm(
"cipher {0} in {1} mode is not supported "
"by this backend".format(
cipher.name, mode.name if mode else mode)
cipher.name, mode.name if mode else mode),
_Reasons.UNSUPPORTED_CIPHER
)
ctx = self._backend._ffi.new("CCCryptorRef *")
......@@ -349,7 +350,8 @@ class _GCMCipherContext(object):
raise UnsupportedAlgorithm(
"cipher {0} in {1} mode is not supported "
"by this backend".format(
cipher.name, mode.name if mode else mode)
cipher.name, mode.name if mode else mode),
_Reasons.UNSUPPORTED_CIPHER
)
ctx = self._backend._ffi.new("CCCryptorRef *")
......@@ -422,7 +424,8 @@ class _HashContext(object):
except KeyError:
raise UnsupportedAlgorithm(
"{0} is not a supported hash on this backend".format(
algorithm.name)
algorithm.name),
_Reasons.UNSUPPORTED_HASH
)
ctx = self._backend._ffi.new(methods.ctx)
res = methods.hash_init(ctx)
......@@ -465,7 +468,8 @@ class _HMACContext(object):
except KeyError:
raise UnsupportedAlgorithm(
"{0} is not a supported HMAC hash on this backend".format(
algorithm.name)
algorithm.name),
_Reasons.UNSUPPORTED_HASH
)
self._backend._lib.CCHmacInit(ctx, alg, key, len(key))
......
......@@ -105,3 +105,18 @@ class RSABackend(six.with_metaclass(abc.ABCMeta)):
Returns an object conforming to the AsymmetricVerificationContext
interface.
"""
@abc.abstractmethod
def mgf1_hash_supported(self, algorithm):
"""
Return True if the hash algorithm is supported for MGF1 in PSS.
"""
class OpenSSLSerializationBackend(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def load_openssl_pem_private_key(self, data, password):
"""
Load a private key from PEM encoded data, using password if the data
is encrypted.
"""
......@@ -14,9 +14,9 @@
from __future__ import absolute_import, division, print_function
from cryptography import utils
from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
from cryptography.hazmat.backends.interfaces import (
CipherBackend, HashBackend, HMACBackend, PBKDF2HMACBackend, RSABackend
CipherBackend, HMACBackend, HashBackend, PBKDF2HMACBackend, RSABackend
)
......@@ -24,6 +24,7 @@ from cryptography.hazmat.backends.interfaces import (
@utils.register_interface(HashBackend)
@utils.register_interface(HMACBackend)
@utils.register_interface(PBKDF2HMACBackend)
@utils.register_interface(RSABackend)
class MultiBackend(object):
name = "multibackend"
......@@ -47,7 +48,11 @@ class MultiBackend(object):
return b.create_symmetric_encryption_ctx(algorithm, mode)
except UnsupportedAlgorithm:
pass
raise UnsupportedAlgorithm
raise UnsupportedAlgorithm(
"cipher {0} in {1} mode is not supported by this backend".format(
algorithm.name, mode.name if mode else mode),
_Reasons.UNSUPPORTED_CIPHER
)
def create_symmetric_decryption_ctx(self, algorithm, mode):
for b in self._filtered_backends(CipherBackend):
......@@ -55,7 +60,11 @@ class MultiBackend(object):
return b.create_symmetric_decryption_ctx(algorithm, mode)
except UnsupportedAlgorithm:
pass
raise UnsupportedAlgorithm
raise UnsupportedAlgorithm(
"cipher {0} in {1} mode is not supported by this backend".format(
algorithm.name, mode.name if mode else mode),
_Reasons.UNSUPPORTED_CIPHER
)
def hash_supported(self, algorithm):
return any(
......@@ -69,7 +78,11 @@ class MultiBackend(object):
return b.create_hash_ctx(algorithm)
except UnsupportedAlgorithm:
pass
raise UnsupportedAlgorithm
raise UnsupportedAlgorithm(
"{0} is not a supported hash on this backend".format(
algorithm.name),
_Reasons.UNSUPPORTED_HASH
)
def hmac_supported(self, algorithm):
return any(
......@@ -83,7 +96,11 @@ class MultiBackend(object):
return b.create_hmac_ctx(key, algorithm)
except UnsupportedAlgorithm:
pass
raise UnsupportedAlgorithm
raise UnsupportedAlgorithm(
"{0} is not a supported hash on this backend".format(
algorithm.name),
_Reasons.UNSUPPORTED_HASH
)
def pbkdf2_hmac_supported(self, algorithm):
return any(
......@@ -100,9 +117,25 @@ class MultiBackend(object):
)
except UnsupportedAlgorithm:
pass
raise UnsupportedAlgorithm
raise UnsupportedAlgorithm(
"{0} is not a supported hash on this backend".format(
algorithm.name),
_Reasons.UNSUPPORTED_HASH
)
def generate_rsa_private_key(self, public_exponent, key_size):
for b in self._filtered_backends(RSABackend):
return b.generate_rsa_private_key(public_exponent, key_size)
raise UnsupportedAlgorithm
raise UnsupportedAlgorithm("RSA is not supported by the backend")
def create_rsa_signature_ctx(self, private_key, padding, algorithm):
for b in self._filtered_backends(RSABackend):
return b.create_rsa_signature_ctx(private_key, padding, algorithm)
raise UnsupportedAlgorithm("RSA is not supported by the backend")
def create_rsa_verification_ctx(self, public_key, signature, padding,
algorithm):
for b in self._filtered_backends(RSABackend):
return b.create_rsa_verification_ctx(public_key, signature,
padding, algorithm)
raise UnsupportedAlgorithm("RSA is not supported by the backend")
......@@ -11,6 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
from cryptography.hazmat.backends.openssl.backend import backend
......
......@@ -10,3 +10,5 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
......@@ -2601,10 +2601,10 @@ static PyMethodDef _cffi_methods[] = {
};
PyMODINIT_FUNC
init_cffi__x9c102645x21ac8a22(void)
init_Cryptography_cffi_be05eb56x6daa9a79(void)
{
PyObject *lib;
lib = Py_InitModule("_cffi__x9c102645x21ac8a22", _cffi_methods);
lib = Py_InitModule("_Cryptography_cffi_be05eb56x6daa9a79", _cffi_methods);