We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Deprecate Whirlpool and RIPEMD


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cryptography/hazmat/primitives/hashes.py`
Content:
```
1 # This file is dual licensed under the terms of the Apache License, Version
2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3 # for complete details.
4 
5 from __future__ import absolute_import, division, print_function
6 
7 import abc
8 
9 import six
10 
11 from cryptography import utils
12 from cryptography.exceptions import (
13     AlreadyFinalized, UnsupportedAlgorithm, _Reasons
14 )
15 from cryptography.hazmat.backends.interfaces import HashBackend
16 
17 
18 @six.add_metaclass(abc.ABCMeta)
19 class HashAlgorithm(object):
20     @abc.abstractproperty
21     def name(self):
22         """
23         A string naming this algorithm (e.g. "sha256", "md5").
24         """
25 
26     @abc.abstractproperty
27     def digest_size(self):
28         """
29         The size of the resulting digest in bytes.
30         """
31 
32     @abc.abstractproperty
33     def block_size(self):
34         """
35         The internal block size of the hash algorithm in bytes.
36         """
37 
38 
39 @six.add_metaclass(abc.ABCMeta)
40 class HashContext(object):
41     @abc.abstractproperty
42     def algorithm(self):
43         """
44         A HashAlgorithm that will be used by this context.
45         """
46 
47     @abc.abstractmethod
48     def update(self, data):
49         """
50         Processes the provided bytes through the hash.
51         """
52 
53     @abc.abstractmethod
54     def finalize(self):
55         """
56         Finalizes the hash context and returns the hash digest as bytes.
57         """
58 
59     @abc.abstractmethod
60     def copy(self):
61         """
62         Return a HashContext that is a copy of the current context.
63         """
64 
65 
66 @utils.register_interface(HashContext)
67 class Hash(object):
68     def __init__(self, algorithm, backend, ctx=None):
69         if not isinstance(backend, HashBackend):
70             raise UnsupportedAlgorithm(
71                 "Backend object does not implement HashBackend.",
72                 _Reasons.BACKEND_MISSING_INTERFACE
73             )
74 
75         if not isinstance(algorithm, HashAlgorithm):
76             raise TypeError("Expected instance of hashes.HashAlgorithm.")
77         self._algorithm = algorithm
78 
79         self._backend = backend
80 
81         if ctx is None:
82             self._ctx = self._backend.create_hash_ctx(self.algorithm)
83         else:
84             self._ctx = ctx
85 
86     algorithm = utils.read_only_property("_algorithm")
87 
88     def update(self, data):
89         if self._ctx is None:
90             raise AlreadyFinalized("Context was already finalized.")
91         if not isinstance(data, bytes):
92             raise TypeError("data must be bytes.")
93         self._ctx.update(data)
94 
95     def copy(self):
96         if self._ctx is None:
97             raise AlreadyFinalized("Context was already finalized.")
98         return Hash(
99             self.algorithm, backend=self._backend, ctx=self._ctx.copy()
100         )
101 
102     def finalize(self):
103         if self._ctx is None:
104             raise AlreadyFinalized("Context was already finalized.")
105         digest = self._ctx.finalize()
106         self._ctx = None
107         return digest
108 
109 
110 @utils.register_interface(HashAlgorithm)
111 class SHA1(object):
112     name = "sha1"
113     digest_size = 20
114     block_size = 64
115 
116 
117 @utils.register_interface(HashAlgorithm)
118 class SHA224(object):
119     name = "sha224"
120     digest_size = 28
121     block_size = 64
122 
123 
124 @utils.register_interface(HashAlgorithm)
125 class SHA256(object):
126     name = "sha256"
127     digest_size = 32
128     block_size = 64
129 
130 
131 @utils.register_interface(HashAlgorithm)
132 class SHA384(object):
133     name = "sha384"
134     digest_size = 48
135     block_size = 128
136 
137 
138 @utils.register_interface(HashAlgorithm)
139 class SHA512(object):
140     name = "sha512"
141     digest_size = 64
142     block_size = 128
143 
144 
145 @utils.register_interface(HashAlgorithm)
146 class RIPEMD160(object):
147     name = "ripemd160"
148     digest_size = 20
149     block_size = 64
150 
151 
152 @utils.register_interface(HashAlgorithm)
153 class Whirlpool(object):
154     name = "whirlpool"
155     digest_size = 64
156     block_size = 64
157 
158 
159 @utils.register_interface(HashAlgorithm)
160 class MD5(object):
161     name = "md5"
162     digest_size = 16
163     block_size = 64
164 
165 
166 @utils.register_interface(HashAlgorithm)
167 class BLAKE2b(object):
168     name = "blake2b"
169     _max_digest_size = 64
170     _min_digest_size = 1
171     block_size = 128
172 
173     def __init__(self, digest_size):
174         if (
175             digest_size > self._max_digest_size or
176             digest_size < self._min_digest_size
177         ):
178             raise ValueError("Digest size must be {0}-{1}".format(
179                 self._min_digest_size, self._max_digest_size)
180             )
181 
182         self._digest_size = digest_size
183 
184     digest_size = utils.read_only_property("_digest_size")
185 
186 
187 @utils.register_interface(HashAlgorithm)
188 class BLAKE2s(object):
189     name = "blake2s"
190     block_size = 64
191     _max_digest_size = 32
192     _min_digest_size = 1
193 
194     def __init__(self, digest_size):
195         if (
196             digest_size > self._max_digest_size or
197             digest_size < self._min_digest_size
198         ):
199             raise ValueError("Digest size must be {0}-{1}".format(
200                 self._min_digest_size, self._max_digest_size)
201             )
202 
203         self._digest_size = digest_size
204 
205     digest_size = utils.read_only_property("_digest_size")
206
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cryptography/hazmat/primitives/hashes.py b/src/cryptography/hazmat/primitives/hashes.py
--- a/src/cryptography/hazmat/primitives/hashes.py
+++ b/src/cryptography/hazmat/primitives/hashes.py
@@ -149,6 +149,14 @@
     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"
@@ -156,6 +164,14 @@
     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"

{"golden_diff": "diff --git a/src/cryptography/hazmat/primitives/hashes.py b/src/cryptography/hazmat/primitives/hashes.py\n--- a/src/cryptography/hazmat/primitives/hashes.py\n+++ b/src/cryptography/hazmat/primitives/hashes.py\n@@ -149,6 +149,14 @@\n     block_size = 64\n \n \n+RIPEMD160 = utils.deprecated(\n+    RIPEMD160,\n+    __name__,\n+    \"The RIPEMD160 hash was deprecated in version 1.9.\",\n+    utils.DeprecatedIn19\n+)\n+\n+\n @utils.register_interface(HashAlgorithm)\n class Whirlpool(object):\n     name = \"whirlpool\"\n@@ -156,6 +164,14 @@\n     block_size = 64\n \n \n+Whirlpool = utils.deprecated(\n+    Whirlpool,\n+    __name__,\n+    \"The Whirlpool hash was deprecated in version 1.9.\",\n+    utils.DeprecatedIn19\n+)\n+\n+\n @utils.register_interface(HashAlgorithm)\n class MD5(object):\n     name = \"md5\"\n", "issue": "Deprecate Whirlpool and RIPEMD\n\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport abc\n\nimport six\n\nfrom cryptography import utils\nfrom cryptography.exceptions import (\n    AlreadyFinalized, UnsupportedAlgorithm, _Reasons\n)\nfrom cryptography.hazmat.backends.interfaces import HashBackend\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass HashAlgorithm(object):\n    @abc.abstractproperty\n    def name(self):\n        \"\"\"\n        A string naming this algorithm (e.g. \"sha256\", \"md5\").\n        \"\"\"\n\n    @abc.abstractproperty\n    def digest_size(self):\n        \"\"\"\n        The size of the resulting digest in bytes.\n        \"\"\"\n\n    @abc.abstractproperty\n    def block_size(self):\n        \"\"\"\n        The internal block size of the hash algorithm in bytes.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass HashContext(object):\n    @abc.abstractproperty\n    def algorithm(self):\n        \"\"\"\n        A HashAlgorithm that will be used by this context.\n        \"\"\"\n\n    @abc.abstractmethod\n    def update(self, data):\n        \"\"\"\n        Processes the provided bytes through the hash.\n        \"\"\"\n\n    @abc.abstractmethod\n    def finalize(self):\n        \"\"\"\n        Finalizes the hash context and returns the hash digest as bytes.\n        \"\"\"\n\n    @abc.abstractmethod\n    def copy(self):\n        \"\"\"\n        Return a HashContext that is a copy of the current context.\n        \"\"\"\n\n\n@utils.register_interface(HashContext)\nclass Hash(object):\n    def __init__(self, algorithm, backend, ctx=None):\n        if not isinstance(backend, HashBackend):\n            raise UnsupportedAlgorithm(\n                \"Backend object does not implement HashBackend.\",\n                _Reasons.BACKEND_MISSING_INTERFACE\n            )\n\n        if not isinstance(algorithm, HashAlgorithm):\n            raise TypeError(\"Expected instance of hashes.HashAlgorithm.\")\n        self._algorithm = algorithm\n\n        self._backend = backend\n\n        if ctx is None:\n            self._ctx = self._backend.create_hash_ctx(self.algorithm)\n        else:\n            self._ctx = ctx\n\n    algorithm = utils.read_only_property(\"_algorithm\")\n\n    def update(self, data):\n        if self._ctx is None:\n            raise AlreadyFinalized(\"Context was already finalized.\")\n        if not isinstance(data, bytes):\n            raise TypeError(\"data must be bytes.\")\n        self._ctx.update(data)\n\n    def copy(self):\n        if self._ctx is None:\n            raise AlreadyFinalized(\"Context was already finalized.\")\n        return Hash(\n            self.algorithm, backend=self._backend, ctx=self._ctx.copy()\n        )\n\n    def finalize(self):\n        if self._ctx is None:\n            raise AlreadyFinalized(\"Context was already finalized.\")\n        digest = self._ctx.finalize()\n        self._ctx = None\n        return digest\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA1(object):\n    name = \"sha1\"\n    digest_size = 20\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA224(object):\n    name = \"sha224\"\n    digest_size = 28\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA256(object):\n    name = \"sha256\"\n    digest_size = 32\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA384(object):\n    name = \"sha384\"\n    digest_size = 48\n    block_size = 128\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA512(object):\n    name = \"sha512\"\n    digest_size = 64\n    block_size = 128\n\n\n@utils.register_interface(HashAlgorithm)\nclass RIPEMD160(object):\n    name = \"ripemd160\"\n    digest_size = 20\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass Whirlpool(object):\n    name = \"whirlpool\"\n    digest_size = 64\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass MD5(object):\n    name = \"md5\"\n    digest_size = 16\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass BLAKE2b(object):\n    name = \"blake2b\"\n    _max_digest_size = 64\n    _min_digest_size = 1\n    block_size = 128\n\n    def __init__(self, digest_size):\n        if (\n            digest_size > self._max_digest_size or\n            digest_size < self._min_digest_size\n        ):\n            raise ValueError(\"Digest size must be {0}-{1}\".format(\n                self._min_digest_size, self._max_digest_size)\n            )\n\n        self._digest_size = digest_size\n\n    digest_size = utils.read_only_property(\"_digest_size\")\n\n\n@utils.register_interface(HashAlgorithm)\nclass BLAKE2s(object):\n    name = \"blake2s\"\n    block_size = 64\n    _max_digest_size = 32\n    _min_digest_size = 1\n\n    def __init__(self, digest_size):\n        if (\n            digest_size > self._max_digest_size or\n            digest_size < self._min_digest_size\n        ):\n            raise ValueError(\"Digest size must be {0}-{1}\".format(\n                self._min_digest_size, self._max_digest_size)\n            )\n\n        self._digest_size = digest_size\n\n    digest_size = utils.read_only_property(\"_digest_size\")\n", "path": "src/cryptography/hazmat/primitives/hashes.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport abc\n\nimport six\n\nfrom cryptography import utils\nfrom cryptography.exceptions import (\n    AlreadyFinalized, UnsupportedAlgorithm, _Reasons\n)\nfrom cryptography.hazmat.backends.interfaces import HashBackend\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass HashAlgorithm(object):\n    @abc.abstractproperty\n    def name(self):\n        \"\"\"\n        A string naming this algorithm (e.g. \"sha256\", \"md5\").\n        \"\"\"\n\n    @abc.abstractproperty\n    def digest_size(self):\n        \"\"\"\n        The size of the resulting digest in bytes.\n        \"\"\"\n\n    @abc.abstractproperty\n    def block_size(self):\n        \"\"\"\n        The internal block size of the hash algorithm in bytes.\n        \"\"\"\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass HashContext(object):\n    @abc.abstractproperty\n    def algorithm(self):\n        \"\"\"\n        A HashAlgorithm that will be used by this context.\n        \"\"\"\n\n    @abc.abstractmethod\n    def update(self, data):\n        \"\"\"\n        Processes the provided bytes through the hash.\n        \"\"\"\n\n    @abc.abstractmethod\n    def finalize(self):\n        \"\"\"\n        Finalizes the hash context and returns the hash digest as bytes.\n        \"\"\"\n\n    @abc.abstractmethod\n    def copy(self):\n        \"\"\"\n        Return a HashContext that is a copy of the current context.\n        \"\"\"\n\n\n@utils.register_interface(HashContext)\nclass Hash(object):\n    def __init__(self, algorithm, backend, ctx=None):\n        if not isinstance(backend, HashBackend):\n            raise UnsupportedAlgorithm(\n                \"Backend object does not implement HashBackend.\",\n                _Reasons.BACKEND_MISSING_INTERFACE\n            )\n\n        if not isinstance(algorithm, HashAlgorithm):\n            raise TypeError(\"Expected instance of hashes.HashAlgorithm.\")\n        self._algorithm = algorithm\n\n        self._backend = backend\n\n        if ctx is None:\n            self._ctx = self._backend.create_hash_ctx(self.algorithm)\n        else:\n            self._ctx = ctx\n\n    algorithm = utils.read_only_property(\"_algorithm\")\n\n    def update(self, data):\n        if self._ctx is None:\n            raise AlreadyFinalized(\"Context was already finalized.\")\n        if not isinstance(data, bytes):\n            raise TypeError(\"data must be bytes.\")\n        self._ctx.update(data)\n\n    def copy(self):\n        if self._ctx is None:\n            raise AlreadyFinalized(\"Context was already finalized.\")\n        return Hash(\n            self.algorithm, backend=self._backend, ctx=self._ctx.copy()\n        )\n\n    def finalize(self):\n        if self._ctx is None:\n            raise AlreadyFinalized(\"Context was already finalized.\")\n        digest = self._ctx.finalize()\n        self._ctx = None\n        return digest\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA1(object):\n    name = \"sha1\"\n    digest_size = 20\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA224(object):\n    name = \"sha224\"\n    digest_size = 28\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA256(object):\n    name = \"sha256\"\n    digest_size = 32\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA384(object):\n    name = \"sha384\"\n    digest_size = 48\n    block_size = 128\n\n\n@utils.register_interface(HashAlgorithm)\nclass SHA512(object):\n    name = \"sha512\"\n    digest_size = 64\n    block_size = 128\n\n\n@utils.register_interface(HashAlgorithm)\nclass RIPEMD160(object):\n    name = \"ripemd160\"\n    digest_size = 20\n    block_size = 64\n\n\nRIPEMD160 = utils.deprecated(\n    RIPEMD160,\n    __name__,\n    \"The RIPEMD160 hash was deprecated in version 1.9.\",\n    utils.DeprecatedIn19\n)\n\n\n@utils.register_interface(HashAlgorithm)\nclass Whirlpool(object):\n    name = \"whirlpool\"\n    digest_size = 64\n    block_size = 64\n\n\nWhirlpool = utils.deprecated(\n    Whirlpool,\n    __name__,\n    \"The Whirlpool hash was deprecated in version 1.9.\",\n    utils.DeprecatedIn19\n)\n\n\n@utils.register_interface(HashAlgorithm)\nclass MD5(object):\n    name = \"md5\"\n    digest_size = 16\n    block_size = 64\n\n\n@utils.register_interface(HashAlgorithm)\nclass BLAKE2b(object):\n    name = \"blake2b\"\n    _max_digest_size = 64\n    _min_digest_size = 1\n    block_size = 128\n\n    def __init__(self, digest_size):\n        if (\n            digest_size > self._max_digest_size or\n            digest_size < self._min_digest_size\n        ):\n            raise ValueError(\"Digest size must be {0}-{1}\".format(\n                self._min_digest_size, self._max_digest_size)\n            )\n\n        self._digest_size = digest_size\n\n    digest_size = utils.read_only_property(\"_digest_size\")\n\n\n@utils.register_interface(HashAlgorithm)\nclass BLAKE2s(object):\n    name = \"blake2s\"\n    block_size = 64\n    _max_digest_size = 32\n    _min_digest_size = 1\n\n    def __init__(self, digest_size):\n        if (\n            digest_size > self._max_digest_size or\n            digest_size < self._min_digest_size\n        ):\n            raise ValueError(\"Digest size must be {0}-{1}\".format(\n                self._min_digest_size, self._max_digest_size)\n            )\n\n        self._digest_size = digest_size\n\n    digest_size = utils.read_only_property(\"_digest_size\")\n", "path": "src/cryptography/hazmat/primitives/hashes.py"}]}