diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2015-01-18 15:57:28 +0000 |
---|---|---|
committer | Alex Stapleton <alex@ly.st> | 2015-01-22 15:26:22 +0000 |
commit | f48f69d6654a10a46e34323747c54e0f0ccb7eef (patch) | |
tree | 326919d2326898b7236312a777feb25cdc9e301b /src | |
parent | 7b672cace5c59a682e20854eac423e7e8c427531 (diff) | |
download | cryptography-f48f69d6654a10a46e34323747c54e0f0ccb7eef.tar.gz cryptography-f48f69d6654a10a46e34323747c54e0f0ccb7eef.tar.bz2 cryptography-f48f69d6654a10a46e34323747c54e0f0ccb7eef.zip |
Move DSA* interfaces to interfaces.dsa module
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/dsa.py | 86 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/interfaces/__init__.py | 74 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/interfaces/asymmetric/dsa.py | 93 | ||||
-rw-r--r-- | src/cryptography/utils.py | 2 |
4 files changed, 152 insertions, 103 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/dsa.py b/src/cryptography/hazmat/primitives/asymmetric/dsa.py index 9b06f3e6..58058df9 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/dsa.py +++ b/src/cryptography/hazmat/primitives/asymmetric/dsa.py @@ -4,11 +4,97 @@ from __future__ import absolute_import, division, print_function +import abc + import six from cryptography import utils +@six.add_metaclass(abc.ABCMeta) +class DSAParameters(object): + @abc.abstractmethod + def generate_private_key(self): + """ + Generates and returns a DSAPrivateKey. + """ + + +@six.add_metaclass(abc.ABCMeta) +class DSAParametersWithNumbers(DSAParameters): + @abc.abstractmethod + def parameter_numbers(self): + """ + Returns a DSAParameterNumbers. + """ + + +@six.add_metaclass(abc.ABCMeta) +class DSAPrivateKey(object): + @abc.abstractproperty + def key_size(self): + """ + The bit length of the prime modulus. + """ + + @abc.abstractmethod + def public_key(self): + """ + The DSAPublicKey associated with this private key. + """ + + @abc.abstractmethod + def parameters(self): + """ + The DSAParameters object associated with this private key. + """ + + @abc.abstractmethod + def signer(self, signature_algorithm): + """ + Returns an AsymmetricSignatureContext used for signing data. + """ + + +@six.add_metaclass(abc.ABCMeta) +class DSAPrivateKeyWithNumbers(DSAPrivateKey): + @abc.abstractmethod + def private_numbers(self): + """ + Returns a DSAPrivateNumbers. + """ + + +@six.add_metaclass(abc.ABCMeta) +class DSAPublicKey(object): + @abc.abstractproperty + def key_size(self): + """ + The bit length of the prime modulus. + """ + + @abc.abstractmethod + def parameters(self): + """ + The DSAParameters object associated with this public key. + """ + + @abc.abstractmethod + def verifier(self, signature, signature_algorithm): + """ + Returns an AsymmetricVerificationContext used for signing data. + """ + + +@six.add_metaclass(abc.ABCMeta) +class DSAPublicKeyWithNumbers(DSAPublicKey): + @abc.abstractmethod + def public_numbers(self): + """ + Returns a DSAPublicNumbers. + """ + + def generate_parameters(key_size, backend): return backend.generate_dsa_parameters(key_size) diff --git a/src/cryptography/hazmat/primitives/interfaces/__init__.py b/src/cryptography/hazmat/primitives/interfaces/__init__.py index fb5ceeae..7961cf15 100644 --- a/src/cryptography/hazmat/primitives/interfaces/__init__.py +++ b/src/cryptography/hazmat/primitives/interfaces/__init__.py @@ -8,10 +8,10 @@ import abc import six -from cryptography.hazmat.primitives.interfaces.asymmetric.dsa import ( - DSAParameters, DSAParametersWithNumbers, DSAPrivateKey, - DSAPrivateKeyWithNumbers, DSAPublicKey, DSAPublicKeyWithNumbers -) +from cryptography import utils + +from cryptography.hazmat.primitives.asymmetric import dsa + from cryptography.hazmat.primitives.interfaces.asymmetric.ec import ( EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePrivateKeyWithNumbers, EllipticCurvePublicKey, EllipticCurvePublicKeyWithNumbers, @@ -25,12 +25,6 @@ from cryptography.hazmat.primitives.interfaces.ciphers import ( __all__ = [ "BlockCipherAlgorithm", "CipherAlgorithm", - "DSAParameters", - "DSAParametersWithNumbers", - "DSAPrivateKey", - "DSAPrivateKeyWithNumbers", - "DSAPublicKey", - "DSAPublicKeyWithNumbers", "EllipticCurve", "EllipticCurvePrivateKey", "EllipticCurvePrivateKeyWithNumbers", @@ -43,6 +37,66 @@ __all__ = [ "ModeWithNonce" ] +DSAParameters = utils.deprecated( + dsa.DSAParameters, + __name__, + ( + "The DSAParameters interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.dsa.module" + ), + utils.DeprecatedIn08 +) + +DSAParametersWithNumbers = utils.deprecated( + dsa.DSAParametersWithNumbers, + __name__, + ( + "The DSAParametersWithNumbers interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.dsa.module" + ), + utils.DeprecatedIn08 +) + +DSAPrivateKey = utils.deprecated( + dsa.DSAPrivateKey, + __name__, + ( + "The DSAPrivateKey interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.dsa.module" + ), + utils.DeprecatedIn08 +) + +DSAPrivateKeyWithNumbers = utils.deprecated( + dsa.DSAPrivateKeyWithNumbers, + __name__, + ( + "The DSAPrivateKeyWithNumbers interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.dsa.module" + ), + utils.DeprecatedIn08 +) + +DSAPublicKey = utils.deprecated( + dsa.DSAPublicKey, + __name__, + ( + "The DSAPublicKeyWithNumbers interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.dsa.module" + ), + utils.DeprecatedIn08 +) + +DSAPublicKeyWithNumbers = utils.deprecated( + dsa.DSAPublicKeyWithNumbers, + __name__, + ( + "The DSAPublicKeyWithNumbers interface has moved to the " + "cryptography.hazmat.primitives.asymmetric.dsa.module" + ), + utils.DeprecatedIn08 +) + @six.add_metaclass(abc.ABCMeta) class CipherContext(object): diff --git a/src/cryptography/hazmat/primitives/interfaces/asymmetric/dsa.py b/src/cryptography/hazmat/primitives/interfaces/asymmetric/dsa.py deleted file mode 100644 index acfc8973..00000000 --- a/src/cryptography/hazmat/primitives/interfaces/asymmetric/dsa.py +++ /dev/null @@ -1,93 +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 DSAParameters(object): - @abc.abstractmethod - def generate_private_key(self): - """ - Generates and returns a DSAPrivateKey. - """ - - -@six.add_metaclass(abc.ABCMeta) -class DSAParametersWithNumbers(DSAParameters): - @abc.abstractmethod - def parameter_numbers(self): - """ - Returns a DSAParameterNumbers. - """ - - -@six.add_metaclass(abc.ABCMeta) -class DSAPrivateKey(object): - @abc.abstractproperty - def key_size(self): - """ - The bit length of the prime modulus. - """ - - @abc.abstractmethod - def public_key(self): - """ - The DSAPublicKey associated with this private key. - """ - - @abc.abstractmethod - def parameters(self): - """ - The DSAParameters object associated with this private key. - """ - - @abc.abstractmethod - def signer(self, signature_algorithm): - """ - Returns an AsymmetricSignatureContext used for signing data. - """ - - -@six.add_metaclass(abc.ABCMeta) -class DSAPrivateKeyWithNumbers(DSAPrivateKey): - @abc.abstractmethod - def private_numbers(self): - """ - Returns a DSAPrivateNumbers. - """ - - -@six.add_metaclass(abc.ABCMeta) -class DSAPublicKey(object): - @abc.abstractproperty - def key_size(self): - """ - The bit length of the prime modulus. - """ - - @abc.abstractmethod - def parameters(self): - """ - The DSAParameters object associated with this public key. - """ - - @abc.abstractmethod - def verifier(self, signature, signature_algorithm): - """ - Returns an AsymmetricVerificationContext used for signing data. - """ - - -@six.add_metaclass(abc.ABCMeta) -class DSAPublicKeyWithNumbers(DSAPublicKey): - @abc.abstractmethod - def public_numbers(self): - """ - Returns a DSAPublicNumbers. - """ diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index 72f9a347..78dcc1ca 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -13,6 +13,8 @@ import warnings # DeprecatedIn07 objects exist. This comment exists to remind developers to # look for them when it's time for the ninth release cycle deprecation dance. +DeprecatedIn08 = PendingDeprecationWarning + def read_only_property(name): return property(lambda self: getattr(self, name)) |