From 3bc87ab21f7b599bfc18fc53966de3c521a25435 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 12 Feb 2015 00:01:53 -0600 Subject: move EC interfaces --- docs/hazmat/primitives/asymmetric/ec.rst | 134 +++++++++++++++++++-- docs/hazmat/primitives/interfaces.rst | 129 +------------------- src/cryptography/hazmat/backends/openssl/ec.py | 4 +- .../hazmat/primitives/asymmetric/ec.py | 115 +++++++++++++++--- .../hazmat/primitives/interfaces/__init__.py | 81 +++++++++++-- .../primitives/interfaces/asymmetric/__init__.py | 5 - .../hazmat/primitives/interfaces/asymmetric/ec.py | 87 ------------- tests/hazmat/primitives/test_ec.py | 8 +- 8 files changed, 294 insertions(+), 269 deletions(-) delete mode 100644 src/cryptography/hazmat/primitives/interfaces/asymmetric/__init__.py delete mode 100644 src/cryptography/hazmat/primitives/interfaces/asymmetric/ec.py diff --git a/docs/hazmat/primitives/asymmetric/ec.rst b/docs/hazmat/primitives/asymmetric/ec.rst index 13ab7c11..4b8177ea 100644 --- a/docs/hazmat/primitives/asymmetric/ec.rst +++ b/docs/hazmat/primitives/asymmetric/ec.rst @@ -12,17 +12,13 @@ Elliptic curve cryptography Generate a new private key on ``curve`` for use with ``backend``. - :param backend: A - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve` - provider. + :param backend: A :class:`EllipticCurve` provider. :param backend: A :class:`~cryptography.hazmat.backends.interfaces.EllipticCurveBackend` provider. - :returns: A new instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateKey` - provider. + :returns: A new instance of a :class:`EllipticCurvePrivateKey` provider. Elliptic Curve Signature Algorithms @@ -86,8 +82,7 @@ Elliptic Curve Signature Algorithms :class:`~cryptography.hazmat.backends.interfaces.EllipticCurveBackend` provider. - :returns: A new instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateKey` + :returns: A new instance of a :class:`EllipticCurvePrivateKey` provider. @@ -99,7 +94,7 @@ Elliptic Curve Signature Algorithms .. attribute:: curve - :type: :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve` + :type: :class:`EllipticCurve` The elliptic curve for this key. @@ -124,8 +119,7 @@ Elliptic Curve Signature Algorithms :class:`~cryptography.hazmat.backends.interfaces.EllipticCurveBackend` provider. - :returns: A new instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicKey` + :returns: A new instance of a :class:`EllipticCurvePublicKey` provider. Elliptic Curves @@ -151,8 +145,7 @@ Currently `cryptography` only supports NIST curves, none of which are considered "safe" by the `SafeCurves`_ project run by Daniel J. Bernstein and Tanja Lange. -All named curves are providers of -:class:`~cryptography.hazmat.primtives.interfaces.EllipticCurve`. +All named curves are providers of :class:`EllipticCurve`. .. class:: SECT571K1 @@ -258,6 +251,119 @@ All named curves are providers of SECG curve ``secp192r1``. Also called NIST P-192. +Key Interfaces +~~~~~~~~~~~~~~ + +.. class:: EllipticCurve + + .. versionadded:: 0.5 + + A named elliptic curve. + + .. attribute:: name + + :type: string + + The name of the curve. Usually the name used for the ASN.1 OID such as + ``secp256k1``. + + .. attribute:: key_size + + :type: int + + The bit length of the curve's base point. + + +.. class:: EllipticCurveSignatureAlgorithm + + .. versionadded:: 0.5 + + A signature algorithm for use with elliptic curve keys. + + .. attribute:: algorithm + + :type: :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + + The digest algorithm to be used with the signature scheme. + + +.. class:: EllipticCurvePrivateKey + + .. versionadded:: 0.5 + + An elliptic curve private key for use with an algorithm such as `ECDSA`_ or + `EdDSA`_. + + .. method:: signer(signature_algorithm) + + Sign data which can be verified later by others using the public key. + The signature is formatted as DER-encoded bytes, as specified in + :rfc:`6979`. + + :param signature_algorithm: An instance of a + :class:`EllipticCurveSignatureAlgorithm` provider. + + :returns: + :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricSignatureContext` + + .. method:: public_key() + + :return: :class:`EllipticCurvePublicKey` + + The EllipticCurvePublicKey object for this private key. + + +.. class:: EllipticCurvePrivateKeyWithNumbers + + .. versionadded:: 0.6 + + Extends :class:`EllipticCurvePrivateKey`. + + .. method:: private_numbers() + + Create a :class:`EllipticCurvePrivateNumbers` object. + + :returns: An :class:`EllipticCurvePrivateNumbers` instance. + + +.. class:: EllipticCurvePublicKey + + .. versionadded:: 0.5 + + An elliptic curve public key. + + .. method:: verifier(signature, signature_algorithm) + + Verify data was signed by the private key associated with this public + key. + + :param bytes signature: The signature to verify. DER encoded as + specified in :rfc:`6979`. + + :param signature_algorithm: An instance of a + :class:`EllipticCurveSignatureAlgorithm` provider. + + :returns: + :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricSignatureContext` + + .. attribute:: curve + + :type: :class:`EllipticCurve` + + The elliptic curve for this key. + + +.. class:: EllipticCurvePublicKeyWithNumbers + + .. versionadded:: 0.6 + + Extends :class:`EllipticCurvePublicKey`. + + .. method:: public_numbers() + + Create a :class:`EllipticCurvePublicNumbers` object. + + :returns: An :class:`EllipticCurvePublicNumbers` instance. .. _`FIPS 186-3`: http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf @@ -267,3 +373,5 @@ All named curves are providers of .. _`64x lower computational cost than DH`: http://www.nsa.gov/business/programs/elliptic_curve.shtml .. _`minimize the number of security concerns for elliptic-curve cryptography`: http://cr.yp.to/ecdh/curve25519-20060209.pdf .. _`SafeCurves`: http://safecurves.cr.yp.to/ +.. _`ECDSA`: https://en.wikipedia.org/wiki/ECDSA +.. _`EdDSA`: https://en.wikipedia.org/wiki/EdDSA diff --git a/docs/hazmat/primitives/interfaces.rst b/docs/hazmat/primitives/interfaces.rst index aae891e8..16e99ff7 100644 --- a/docs/hazmat/primitives/interfaces.rst +++ b/docs/hazmat/primitives/interfaces.rst @@ -146,132 +146,12 @@ RSA In 0.8 the RSA key interfaces were moved to the :mod:`cryptography.hazmat.primitives.asymmetric.rsa` module. -.. class:: EllipticCurve - - .. versionadded:: 0.5 - - A named elliptic curve. - - .. attribute:: name - - :type: string - - The name of the curve. Usually the name used for the ASN.1 OID such as - ``secp256k1``. - - .. attribute:: key_size - - :type: int - - The bit length of the curve's base point. - Elliptic Curve ~~~~~~~~~~~~~~ -.. class:: EllipticCurveSignatureAlgorithm - - .. versionadded:: 0.5 - - A signature algorithm for use with elliptic curve keys. - - .. attribute:: algorithm - - :type: :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` - - The digest algorithm to be used with the signature scheme. - - -.. class:: EllipticCurvePrivateKey - - .. versionadded:: 0.5 - - An elliptic curve private key for use with an algorithm such as `ECDSA`_ or - `EdDSA`_. - - .. method:: signer(signature_algorithm) - - Sign data which can be verified later by others using the public key. - The signature is formatted as DER-encoded bytes, as specified in - :rfc:`6979`. - - :param signature_algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurveSignatureAlgorithm` - provider. - - :returns: - :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricSignatureContext` - - - :type: :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve` - - .. method:: public_key() - - :return: :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicKey` - - The EllipticCurvePublicKey object for this private key. - - -.. class:: EllipticCurvePrivateKeyWithNumbers - - .. versionadded:: 0.6 - - Extends :class:`EllipticCurvePrivateKey`. - - .. method:: private_numbers() - - Create a - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateNumbers` - object. - - :returns: An - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateNumbers` - instance. - - -.. class:: EllipticCurvePublicKey - - .. versionadded:: 0.5 - - An elliptic curve public key. - - .. method:: verifier(signature, signature_algorithm) - - Verify data was signed by the private key associated with this public - key. - - :param bytes signature: The signature to verify. DER encoded as - specified in :rfc:`6979`. - - :param signature_algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurveSignatureAlgorithm` - provider. - - :returns: - :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricSignatureContext` - - .. attribute:: curve - - :type: :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve` - - The elliptic curve for this key. - - -.. class:: EllipticCurvePublicKeyWithNumbers - - .. versionadded:: 0.6 - - Extends :class:`EllipticCurvePublicKey`. - - .. method:: public_numbers() - - Create a - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicNumbers` - object. - - :returns: An - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicNumbers` - instance. +In 0.8 the EC key interfaces were moved to the +:mod:`cryptography.hazmat.primitives.asymmetric.ec` module. Hash algorithms @@ -413,9 +293,4 @@ Key derivation functions the provided signature does not match the expected signature. -.. _`RSA`: https://en.wikipedia.org/wiki/RSA_(cryptosystem) -.. _`Chinese remainder theorem`: https://en.wikipedia.org/wiki/Chinese_remainder_theorem -.. _`DSA`: https://en.wikipedia.org/wiki/Digital_Signature_Algorithm .. _`CMAC`: https://en.wikipedia.org/wiki/CMAC -.. _`ECDSA`: https://en.wikipedia.org/wiki/ECDSA -.. _`EdDSA`: https://en.wikipedia.org/wiki/EdDSA diff --git a/src/cryptography/hazmat/backends/openssl/ec.py b/src/cryptography/hazmat/backends/openssl/ec.py index 33d5b498..d050c6b2 100644 --- a/src/cryptography/hazmat/backends/openssl/ec.py +++ b/src/cryptography/hazmat/backends/openssl/ec.py @@ -146,7 +146,7 @@ class _ECDSAVerificationContext(object): return True -@utils.register_interface(interfaces.EllipticCurvePrivateKeyWithNumbers) +@utils.register_interface(ec.EllipticCurvePrivateKeyWithNumbers) class _EllipticCurvePrivateKey(object): def __init__(self, backend, ec_key_cdata): self._backend = backend @@ -199,7 +199,7 @@ class _EllipticCurvePrivateKey(object): ) -@utils.register_interface(interfaces.EllipticCurvePublicKeyWithNumbers) +@utils.register_interface(ec.EllipticCurvePublicKeyWithNumbers) class _EllipticCurvePublicKey(object): def __init__(self, backend, ec_key_cdata): self._backend = backend diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index c9124249..c7749ca5 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -4,97 +4,176 @@ from __future__ import absolute_import, division, print_function +import abc + import six from cryptography import utils -from cryptography.hazmat.primitives import interfaces -@utils.register_interface(interfaces.EllipticCurve) +@six.add_metaclass(abc.ABCMeta) +class EllipticCurve(object): + @abc.abstractproperty + def name(self): + """ + The name of the curve. e.g. secp256r1. + """ + + @abc.abstractproperty + def key_size(self): + """ + The bit length of the base point of the curve. + """ + + +@six.add_metaclass(abc.ABCMeta) +class EllipticCurveSignatureAlgorithm(object): + @abc.abstractproperty + def algorithm(self): + """ + The digest algorithm used with this signature. + """ + + +@six.add_metaclass(abc.ABCMeta) +class EllipticCurvePrivateKey(object): + @abc.abstractmethod + def signer(self, signature_algorithm): + """ + Returns an AsymmetricSignatureContext used for signing data. + """ + + @abc.abstractmethod + def public_key(self): + """ + The EllipticCurvePublicKey for this private key. + """ + + @abc.abstractproperty + def curve(self): + """ + The EllipticCurve that this key is on. + """ + + +@six.add_metaclass(abc.ABCMeta) +class EllipticCurvePrivateKeyWithNumbers(EllipticCurvePrivateKey): + @abc.abstractmethod + def private_numbers(self): + """ + Returns an EllipticCurvePrivateNumbers. + """ + + +@six.add_metaclass(abc.ABCMeta) +class EllipticCurvePublicKey(object): + @abc.abstractmethod + def verifier(self, signature, signature_algorithm): + """ + Returns an AsymmetricVerificationContext used for signing data. + """ + + @abc.abstractproperty + def curve(self): + """ + The EllipticCurve that this key is on. + """ + + +@six.add_metaclass(abc.ABCMeta) +class EllipticCurvePublicKeyWithNumbers(EllipticCurvePublicKey): + @abc.abstractmethod + def public_numbers(self): + """ + Returns an EllipticCurvePublicNumbers. + """ + + +@utils.register_interface(EllipticCurve) class SECT571R1(object): name = "sect571r1" key_size = 571 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT409R1(object): name = "sect409r1" key_size = 409 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT283R1(object): name = "sect283r1" key_size = 283 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT233R1(object): name = "sect233r1" key_size = 233 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT163R2(object): name = "sect163r2" key_size = 163 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT571K1(object): name = "sect571k1" key_size = 571 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT409K1(object): name = "sect409k1" key_size = 409 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT283K1(object): name = "sect283k1" key_size = 283 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT233K1(object): name = "sect233k1" key_size = 233 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECT163K1(object): name = "sect163k1" key_size = 163 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECP521R1(object): name = "secp521r1" key_size = 521 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECP384R1(object): name = "secp384r1" key_size = 384 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECP256R1(object): name = "secp256r1" key_size = 256 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECP224R1(object): name = "secp224r1" key_size = 224 -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(EllipticCurve) class SECP192R1(object): name = "secp192r1" key_size = 192 @@ -124,7 +203,7 @@ _CURVE_TYPES = { } -@utils.register_interface(interfaces.EllipticCurveSignatureAlgorithm) +@utils.register_interface(EllipticCurveSignatureAlgorithm) class ECDSA(object): def __init__(self, algorithm): self._algorithm = algorithm @@ -144,7 +223,7 @@ class EllipticCurvePublicNumbers(object): ): raise TypeError("x and y must be integers.") - if not isinstance(curve, interfaces.EllipticCurve): + if not isinstance(curve, EllipticCurve): raise TypeError("curve must provide the EllipticCurve interface.") self._y = y diff --git a/src/cryptography/hazmat/primitives/interfaces/__init__.py b/src/cryptography/hazmat/primitives/interfaces/__init__.py index e0bcb8f5..69593b4c 100644 --- a/src/cryptography/hazmat/primitives/interfaces/__init__.py +++ b/src/cryptography/hazmat/primitives/interfaces/__init__.py @@ -9,13 +9,7 @@ import abc import six from cryptography import utils -from cryptography.hazmat.primitives.asymmetric import dsa -from cryptography.hazmat.primitives.asymmetric import rsa -from cryptography.hazmat.primitives.interfaces.asymmetric.ec import ( - EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePrivateKeyWithNumbers, - EllipticCurvePublicKey, EllipticCurvePublicKeyWithNumbers, - EllipticCurveSignatureAlgorithm -) +from cryptography.hazmat.primitives.asymmetric import dsa, ec, rsa from cryptography.hazmat.primitives.interfaces.ciphers import ( BlockCipherAlgorithm, CipherAlgorithm, Mode, ModeWithAuthenticationTag, ModeWithInitializationVector, ModeWithNonce @@ -24,18 +18,79 @@ from cryptography.hazmat.primitives.interfaces.ciphers import ( __all__ = [ "BlockCipherAlgorithm", "CipherAlgorithm", - "EllipticCurve", - "EllipticCurvePrivateKey", - "EllipticCurvePrivateKeyWithNumbers", - "EllipticCurvePublicKey", - "EllipticCurvePublicKeyWithNumbers", - "EllipticCurveSignatureAlgorithm", "Mode", "ModeWithAuthenticationTag", "ModeWithInitializationVector", "ModeWithNonce" ] + +EllipticCurve = utils.deprecated( + ec.EllipticCurve, + __name__, + ( + "The EllipticCurve interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.ec module" + ), + utils.DeprecatedIn08 +) + + +EllipticCurvePrivateKey = utils.deprecated( + ec.EllipticCurvePrivateKey, + __name__, + ( + "The EllipticCurvePrivateKey interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.ec module" + ), + utils.DeprecatedIn08 +) + + +EllipticCurvePrivateKeyWithNumbers = utils.deprecated( + ec.EllipticCurvePrivateKeyWithNumbers, + __name__, + ( + "The EllipticCurvePrivateKeyWithNumbers interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.ec module" + ), + utils.DeprecatedIn08 +) + + +EllipticCurvePublicKey = utils.deprecated( + ec.EllipticCurvePublicKey, + __name__, + ( + "The EllipticCurvePublicKey interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.ec module" + ), + utils.DeprecatedIn08 +) + + +EllipticCurvePublicKeyWithNumbers = utils.deprecated( + ec.EllipticCurvePublicKeyWithNumbers, + __name__, + ( + "The EllipticCurvePublicKeyWithNumbers interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.ec module" + ), + utils.DeprecatedIn08 +) + + +EllipticCurveSignatureAlgorithm = utils.deprecated( + ec.EllipticCurveSignatureAlgorithm, + __name__, + ( + "The EllipticCurveSignatureAlgorithm interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.ec module" + ), + utils.DeprecatedIn08 +) + + DSAParameters = utils.deprecated( dsa.DSAParameters, __name__, diff --git a/src/cryptography/hazmat/primitives/interfaces/asymmetric/__init__.py b/src/cryptography/hazmat/primitives/interfaces/asymmetric/__init__.py deleted file mode 100644 index 4b540884..00000000 --- a/src/cryptography/hazmat/primitives/interfaces/asymmetric/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file is dual licensed under the terms of the Apache License, Version -# 2.0, and the BSD License. See the LICENSE file in the root of this repository -# for complete details. - -from __future__ import absolute_import, division, print_function diff --git a/src/cryptography/hazmat/primitives/interfaces/asymmetric/ec.py b/src/cryptography/hazmat/primitives/interfaces/asymmetric/ec.py deleted file mode 100644 index 2a624576..00000000 --- a/src/cryptography/hazmat/primitives/interfaces/asymmetric/ec.py +++ /dev/null @@ -1,87 +0,0 @@ -# This file is dual licensed under the terms of the Apache License, Version -# 2.0, and the BSD License. See the LICENSE file in the root of this repository -# for complete details. - -from __future__ import absolute_import, division, print_function - -import abc - -import six - - -@six.add_metaclass(abc.ABCMeta) -class EllipticCurve(object): - @abc.abstractproperty - def name(self): - """ - The name of the curve. e.g. secp256r1. - """ - - @abc.abstractproperty - def key_size(self): - """ - The bit length of the base point of the curve. - """ - - -@six.add_metaclass(abc.ABCMeta) -class EllipticCurveSignatureAlgorithm(object): - @abc.abstractproperty - def algorithm(self): - """ - The digest algorithm used with this signature. - """ - - -@six.add_metaclass(abc.ABCMeta) -class EllipticCurvePrivateKey(object): - @abc.abstractmethod - def signer(self, signature_algorithm): - """ - Returns an AsymmetricSignatureContext used for signing data. - """ - - @abc.abstractmethod - def public_key(self): - """ - The EllipticCurvePublicKey for this private key. - """ - - @abc.abstractproperty - def curve(self): - """ - The EllipticCurve that this key is on. - """ - - -@six.add_metaclass(abc.ABCMeta) -class EllipticCurvePrivateKeyWithNumbers(EllipticCurvePrivateKey): - @abc.abstractmethod - def private_numbers(self): - """ - Returns an EllipticCurvePrivateNumbers. - """ - - -@six.add_metaclass(abc.ABCMeta) -class EllipticCurvePublicKey(object): - @abc.abstractmethod - def verifier(self, signature, signature_algorithm): - """ - Returns an AsymmetricVerificationContext used for signing data. - """ - - @abc.abstractproperty - def curve(self): - """ - The EllipticCurve that this key is on. - """ - - -@six.add_metaclass(abc.ABCMeta) -class EllipticCurvePublicKeyWithNumbers(EllipticCurvePublicKey): - @abc.abstractmethod - def public_numbers(self): - """ - Returns an EllipticCurvePublicNumbers. - """ diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index fd7f7ec5..ea621ad6 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -11,7 +11,7 @@ import pytest from cryptography import exceptions, utils from cryptography.hazmat.backends.interfaces import EllipticCurveBackend -from cryptography.hazmat.primitives import hashes, interfaces +from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ec from cryptography.hazmat.primitives.asymmetric.utils import ( encode_rfc6979_signature @@ -52,13 +52,13 @@ def _skip_curve_unsupported(backend, curve): ) -@utils.register_interface(interfaces.EllipticCurve) +@utils.register_interface(ec.EllipticCurve) class DummyCurve(object): name = "dummy-curve" key_size = 1 -@utils.register_interface(interfaces.EllipticCurveSignatureAlgorithm) +@utils.register_interface(ec.EllipticCurveSignatureAlgorithm) class DummySignatureAlgorithm(object): algorithm = None @@ -149,7 +149,7 @@ class TestECWithNumbers(object): ).private_key(backend) assert key - if isinstance(key, interfaces.EllipticCurvePrivateKeyWithNumbers): + if isinstance(key, ec.EllipticCurvePrivateKeyWithNumbers): priv_num = key.private_numbers() assert priv_num.private_value == vector['d'] assert priv_num.public_numbers.x == vector['x'] -- cgit v1.2.3 From fb88e187c1fcc9992923c31d476a3c705ed1b1e4 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 12 Feb 2015 00:11:08 -0600 Subject: add changelog entry for EC move --- CHANGELOG.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2f0802d1..c916beaa 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,15 @@ Changelog :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKeyWithNumbers` were moved from :mod:`~cryptography.hazmat.primitives.interfaces` to :mod:`~cryptography.hazmat.primitives.asymmetric.dsa` +* :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve`, + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurveSignatureAlgorithm`, + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`, + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKeyWithNumbers`, + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`, + and + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKeyWithNumbers` + were moved from :mod:`~cryptography.hazmat.primitives.interfaces` to + :mod:`~cryptography.hazmat.primitives.asymmetric.ec`. * :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`, :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithNumbers`, :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey` and -- cgit v1.2.3