55from __future__ import annotations
66
77import abc
8+ import typing
89
910from cryptography .hazmat .bindings ._rust import openssl as rust_openssl
1011from cryptography .utils import Buffer
@@ -103,66 +104,99 @@ class SHA1(HashAlgorithm):
103104 digest_size = 20
104105 block_size = 64
105106
107+ def __eq__ (self , other : typing .Any ) -> bool :
108+ return isinstance (other , SHA1 )
109+
106110
107111class SHA512_224 (HashAlgorithm ): # noqa: N801
108112 name = "sha512-224"
109113 digest_size = 28
110114 block_size = 128
111115
116+ def __eq__ (self , other : typing .Any ) -> bool :
117+ return isinstance (other , SHA512_224 )
118+
112119
113120class SHA512_256 (HashAlgorithm ): # noqa: N801
114121 name = "sha512-256"
115122 digest_size = 32
116123 block_size = 128
117124
125+ def __eq__ (self , other : typing .Any ) -> bool :
126+ return isinstance (other , SHA512_256 )
127+
118128
119129class SHA224 (HashAlgorithm ):
120130 name = "sha224"
121131 digest_size = 28
122132 block_size = 64
123133
134+ def __eq__ (self , other : typing .Any ) -> bool :
135+ return isinstance (other , SHA224 )
136+
124137
125138class SHA256 (HashAlgorithm ):
126139 name = "sha256"
127140 digest_size = 32
128141 block_size = 64
129142
143+ def __eq__ (self , other : typing .Any ) -> bool :
144+ return isinstance (other , SHA256 )
145+
130146
131147class SHA384 (HashAlgorithm ):
132148 name = "sha384"
133149 digest_size = 48
134150 block_size = 128
135151
152+ def __eq__ (self , other : typing .Any ) -> bool :
153+ return isinstance (other , SHA384 )
154+
136155
137156class SHA512 (HashAlgorithm ):
138157 name = "sha512"
139158 digest_size = 64
140159 block_size = 128
141160
161+ def __eq__ (self , other : typing .Any ) -> bool :
162+ return isinstance (other , SHA512 )
163+
142164
143165class SHA3_224 (HashAlgorithm ): # noqa: N801
144166 name = "sha3-224"
145167 digest_size = 28
146168 block_size = None
147169
170+ def __eq__ (self , other : typing .Any ) -> bool :
171+ return isinstance (other , SHA3_224 )
172+
148173
149174class SHA3_256 (HashAlgorithm ): # noqa: N801
150175 name = "sha3-256"
151176 digest_size = 32
152177 block_size = None
153178
179+ def __eq__ (self , other : typing .Any ) -> bool :
180+ return isinstance (other , SHA3_256 )
181+
154182
155183class SHA3_384 (HashAlgorithm ): # noqa: N801
156184 name = "sha3-384"
157185 digest_size = 48
158186 block_size = None
159187
188+ def __eq__ (self , other : typing .Any ) -> bool :
189+ return isinstance (other , SHA3_384 )
190+
160191
161192class SHA3_512 (HashAlgorithm ): # noqa: N801
162193 name = "sha3-512"
163194 digest_size = 64
164195 block_size = None
165196
197+ def __eq__ (self , other : typing .Any ) -> bool :
198+ return isinstance (other , SHA3_512 )
199+
166200
167201class SHAKE128 (HashAlgorithm , ExtendableOutputFunction ):
168202 name = "shake128"
@@ -177,6 +211,12 @@ def __init__(self, digest_size: int):
177211
178212 self ._digest_size = digest_size
179213
214+ def __eq__ (self , other : typing .Any ) -> bool :
215+ return (
216+ isinstance (other , SHAKE128 )
217+ and self ._digest_size == other ._digest_size
218+ )
219+
180220 @property
181221 def digest_size (self ) -> int :
182222 return self ._digest_size
@@ -195,6 +235,12 @@ def __init__(self, digest_size: int):
195235
196236 self ._digest_size = digest_size
197237
238+ def __eq__ (self , other : typing .Any ) -> bool :
239+ return (
240+ isinstance (other , SHAKE256 )
241+ and self ._digest_size == other ._digest_size
242+ )
243+
198244 @property
199245 def digest_size (self ) -> int :
200246 return self ._digest_size
@@ -205,6 +251,9 @@ class MD5(HashAlgorithm):
205251 digest_size = 16
206252 block_size = 64
207253
254+ def __eq__ (self , other : typing .Any ) -> bool :
255+ return isinstance (other , MD5 )
256+
208257
209258class BLAKE2b (HashAlgorithm ):
210259 name = "blake2b"
@@ -218,6 +267,12 @@ def __init__(self, digest_size: int):
218267
219268 self ._digest_size = digest_size
220269
270+ def __eq__ (self , other : typing .Any ) -> bool :
271+ return (
272+ isinstance (other , BLAKE2b )
273+ and self ._digest_size == other ._digest_size
274+ )
275+
221276 @property
222277 def digest_size (self ) -> int :
223278 return self ._digest_size
@@ -235,6 +290,12 @@ def __init__(self, digest_size: int):
235290
236291 self ._digest_size = digest_size
237292
293+ def __eq__ (self , other : typing .Any ) -> bool :
294+ return (
295+ isinstance (other , BLAKE2s )
296+ and self ._digest_size == other ._digest_size
297+ )
298+
238299 @property
239300 def digest_size (self ) -> int :
240301 return self ._digest_size
@@ -244,3 +305,6 @@ class SM3(HashAlgorithm):
244305 name = "sm3"
245306 digest_size = 32
246307 block_size = 64
308+
309+ def __eq__ (self , other : typing .Any ) -> bool :
310+ return isinstance (other , SM3 )
0 commit comments