@@ -249,13 +249,25 @@ def test_usedforsecurity_false(self):
249249 self ._hashlib .new ("md5" , usedforsecurity = False )
250250 self ._hashlib .openssl_md5 (usedforsecurity = False )
251251
252+ @unittest .skipIf (get_fips_mode (), "skip in FIPS mode" )
252253 def test_clinic_signature (self ):
253254 for constructor in self .hash_constructors :
254255 with self .subTest (constructor .__name__ ):
255256 constructor (b'' )
256257 constructor (data = b'' )
257258 constructor (string = b'' ) # should be deprecated in the future
258259
260+ digest_name = constructor (b'' ).name
261+ with self .subTest (digest_name ):
262+ hashlib .new (digest_name , b'' )
263+ hashlib .new (digest_name , data = b'' )
264+ hashlib .new (digest_name , string = b'' )
265+ if self ._hashlib :
266+ self ._hashlib .new (digest_name , b'' )
267+ self ._hashlib .new (digest_name , data = b'' )
268+ self ._hashlib .new (digest_name , string = b'' )
269+
270+ @unittest .skipIf (get_fips_mode (), "skip in FIPS mode" )
259271 def test_clinic_signature_errors (self ):
260272 nomsg = b''
261273 mymsg = b'msg'
@@ -295,9 +307,16 @@ def test_clinic_signature_errors(self):
295307 [(), dict (data = nomsg , string = nomsg ), conflicting_call ],
296308 ]:
297309 for constructor in self .hash_constructors :
310+ digest_name = constructor (b'' ).name
298311 with self .subTest (constructor .__name__ , args = args , kwds = kwds ):
299312 with self .assertRaisesRegex (TypeError , errmsg ):
300313 constructor (* args , ** kwds )
314+ with self .subTest (digest_name , args = args , kwds = kwds ):
315+ with self .assertRaisesRegex (TypeError , errmsg ):
316+ hashlib .new (digest_name , * args , ** kwds )
317+ if self ._hashlib :
318+ with self .assertRaisesRegex (TypeError , errmsg ):
319+ self ._hashlib .new (digest_name , * args , ** kwds )
301320
302321 def test_unknown_hash (self ):
303322 self .assertRaises (ValueError , hashlib .new , 'spam spam spam spam spam' )
0 commit comments