Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated items #3794

Merged
merged 3 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Changelog

.. note:: This version is not yet released and is under active development.

* **BACKWARDS INCOMPATIBLE:** ``Whirlpool``, ``RIPEMD160``, and
``UnsupportedExtension`` have been removed in accordance with our
:doc:`/api-stability` policy.

2.0 - 2017-07-17
~~~~~~~~~~~~~~~~

Expand Down
30 changes: 0 additions & 30 deletions src/cryptography/hazmat/primitives/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,6 @@ class SHA512(object):
block_size = 128


@utils.register_interface(HashAlgorithm)
class RIPEMD160(object):
name = "ripemd160"
digest_size = 20
block_size = 64


RIPEMD160 = utils.deprecated(
RIPEMD160,
__name__,
"The RIPEMD160 hash was deprecated in version 1.9.",
utils.DeprecatedIn19
)


@utils.register_interface(HashAlgorithm)
class Whirlpool(object):
name = "whirlpool"
digest_size = 64
block_size = 64


Whirlpool = utils.deprecated(
Whirlpool,
__name__,
"The Whirlpool hash was deprecated in version 1.9.",
utils.DeprecatedIn19
)


@utils.register_interface(HashAlgorithm)
class MD5(object):
name = "md5"
Expand Down
17 changes: 0 additions & 17 deletions src/cryptography/hazmat/primitives/interfaces.py

This file was deleted.

11 changes: 1 addition & 10 deletions src/cryptography/x509/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from __future__ import absolute_import, division, print_function

from cryptography import utils
from cryptography.x509 import certificate_transparency
from cryptography.x509.base import (
Certificate, CertificateBuilder, CertificateRevocationList,
Expand All @@ -25,7 +24,7 @@
NameConstraints, NoticeReference, OCSPNoCheck, PolicyConstraints,
PolicyInformation, PrecertificateSignedCertificateTimestamps, ReasonFlags,
SubjectAlternativeName, SubjectKeyIdentifier, UnrecognizedExtension,
UnsupportedExtension, UserNotice
UserNotice
)
from cryptography.x509.general_name import (
DNSName, DirectoryName, GeneralName, IPAddress, OtherName, RFC822Name,
Expand Down Expand Up @@ -110,13 +109,6 @@
OID_CA_ISSUERS = AuthorityInformationAccessOID.CA_ISSUERS
OID_OCSP = AuthorityInformationAccessOID.OCSP

UnsupportedExtension = utils.deprecated(
UnsupportedExtension,
__name__,
"UnsupportedExtension is no longer necessary, it is never raised",
utils.DeprecatedIn19
)

__all__ = [
"certificate_transparency",
"load_pem_x509_certificate",
Expand All @@ -128,7 +120,6 @@
"random_serial_number",
"InvalidVersion",
"DuplicateExtension",
"UnsupportedExtension",
"ExtensionNotFound",
"UnsupportedGeneralNameType",
"NameAttribute",
Expand Down
4 changes: 0 additions & 4 deletions src/cryptography/x509/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def __init__(self, msg, oid):
self.oid = oid


class UnsupportedExtension(Exception):
pass


class ExtensionNotFound(Exception):
def __init__(self, msg, oid):
super(ExtensionNotFound, self).__init__(msg)
Expand Down
36 changes: 3 additions & 33 deletions tests/hazmat/backends/test_openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,24 +365,6 @@ def test_rsa_padding_supported_oaep_sha2_combinations(self):
),
) is True

def test_rsa_padding_unsupported_oaep_ripemd160_sha1(self):
assert backend.rsa_padding_supported(
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.RIPEMD160()),
algorithm=hashes.SHA1(),
label=None
),
) is False

def test_rsa_padding_unsupported_oaep_sha1_ripemd160(self):
assert backend.rsa_padding_supported(
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.SHA1()),
algorithm=hashes.RIPEMD160(),
label=None
),
) is False

def test_rsa_padding_unsupported_mgf(self):
assert backend.rsa_padding_supported(
padding.OAEP(
Expand Down Expand Up @@ -428,26 +410,14 @@ def test_unsupported_oaep_hash_algorithm_decrypt(self):
)
)

def test_unsupported_mgf1_hash_algorithm_ripemd160_decrypt(self):
private_key = RSA_KEY_512.private_key(backend)
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_PADDING):
private_key.decrypt(
b"0" * 64,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.RIPEMD160()),
algorithm=hashes.RIPEMD160(),
label=None
)
)

def test_unsupported_mgf1_hash_algorithm_whirlpool_decrypt(self):
def test_unsupported_mgf1_hash_algorithm_md5_decrypt(self):
private_key = RSA_KEY_512.private_key(backend)
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_PADDING):
private_key.decrypt(
b"0" * 64,
padding.OAEP(
mgf=padding.MGF1(algorithm=hashes.Whirlpool()),
algorithm=hashes.Whirlpool(),
mgf=padding.MGF1(algorithm=hashes.MD5()),
algorithm=hashes.MD5(),
label=None
)
)
Expand Down
46 changes: 1 addition & 45 deletions tests/hazmat/primitives/test_hash_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from cryptography.hazmat.backends.interfaces import HashBackend
from cryptography.hazmat.primitives import hashes

from .utils import generate_hash_test, generate_long_string_hash_test
from .utils import generate_hash_test
from ...utils import load_hash_vectors


Expand Down Expand Up @@ -100,50 +100,6 @@ class TestSHA512(object):
)


@pytest.mark.supported(
only_if=lambda backend: backend.hash_supported(hashes.RIPEMD160()),
skip_message="Does not support RIPEMD160",
)
@pytest.mark.requires_backend_interface(interface=HashBackend)
class TestRIPEMD160(object):
test_RIPEMD160 = generate_hash_test(
load_hash_vectors,
os.path.join("hashes", "ripemd160"),
[
"ripevectors.txt",
],
hashes.RIPEMD160(),
)

test_RIPEMD160_long_string = generate_long_string_hash_test(
hashes.RIPEMD160(),
"52783243c1697bdbe16d37f97f68f08325dc1528",
)


@pytest.mark.supported(
only_if=lambda backend: backend.hash_supported(hashes.Whirlpool()),
skip_message="Does not support Whirlpool",
)
@pytest.mark.requires_backend_interface(interface=HashBackend)
class TestWhirlpool(object):
test_whirlpool = generate_hash_test(
load_hash_vectors,
os.path.join("hashes", "whirlpool"),
[
"iso-test-vectors.txt",
],
hashes.Whirlpool(),
)

test_whirlpool_long_string = generate_long_string_hash_test(
hashes.Whirlpool(),
("0c99005beb57eff50a7cf005560ddf5d29057fd86b2"
"0bfd62deca0f1ccea4af51fc15490eddc47af32bb2b"
"66c34ff9ad8c6008ad677f77126953b226e4ed8b01"),
)


@pytest.mark.supported(
only_if=lambda backend: backend.hash_supported(hashes.MD5()),
skip_message="Does not support MD5",
Expand Down
26 changes: 0 additions & 26 deletions tests/hazmat/primitives/test_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,32 +109,6 @@ class TestSHA512(object):
)


@pytest.mark.supported(
only_if=lambda backend: backend.hash_supported(hashes.RIPEMD160()),
skip_message="Does not support RIPEMD160",
)
@pytest.mark.requires_backend_interface(interface=HashBackend)
class TestRIPEMD160(object):
test_RIPEMD160 = generate_base_hash_test(
hashes.RIPEMD160(),
digest_size=20,
block_size=64,
)


@pytest.mark.supported(
only_if=lambda backend: backend.hash_supported(hashes.Whirlpool()),
skip_message="Does not support Whirlpool",
)
@pytest.mark.requires_backend_interface(interface=HashBackend)
class TestWhirlpool(object):
test_Whirlpool = generate_base_hash_test(
hashes.Whirlpool(),
digest_size=64,
block_size=64,
)


@pytest.mark.supported(
only_if=lambda backend: backend.hash_supported(hashes.MD5()),
skip_message="Does not support MD5",
Expand Down
16 changes: 0 additions & 16 deletions tests/hazmat/primitives/test_hmac_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,3 @@ class TestHMACSHA512(object):
],
hashes.SHA512(),
)


@pytest.mark.supported(
only_if=lambda backend: backend.hmac_supported(hashes.RIPEMD160()),
skip_message="Does not support RIPEMD160",
)
@pytest.mark.requires_backend_interface(interface=HMACBackend)
class TestHMACRIPEMD160(object):
test_hmac_ripemd160 = generate_hmac_test(
load_hash_vectors,
"HMAC",
[
"rfc-2286-ripemd160.txt",
],
hashes.RIPEMD160(),
)
15 changes: 0 additions & 15 deletions tests/hazmat/primitives/test_mac.py

This file was deleted.

12 changes: 0 additions & 12 deletions tests/hazmat/primitives/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,6 @@ def base_hash_test(backend, algorithm, digest_size, block_size):
assert copy.finalize() == m.finalize()


def generate_long_string_hash_test(hash_factory, md):
def test_long_string_hash(self, backend):
long_string_hash_test(backend, hash_factory, md)
return test_long_string_hash


def long_string_hash_test(backend, algorithm, md):
m = hashes.Hash(algorithm, backend=backend)
m.update(b"a" * 1000000)
assert m.finalize() == binascii.unhexlify(md.lower().encode("ascii"))


def generate_base_hmac_test(hash_cls):
def test_base_hmac(self, backend):
base_hmac_test(backend, hash_cls)
Expand Down