@@ -213,7 +213,7 @@ def assert_hmac(
213213 self .assert_hmac_new_by_name (
214214 key , msg , hexdigest , hashname , digest_size , block_size
215215 )
216- self .assert_hmac_hexdigest_by_new (
216+ self .assert_hmac_hexdigest_by_name (
217217 key , msg , hexdigest , hashname , digest_size
218218 )
219219
@@ -272,16 +272,28 @@ def assert_hmac_hexdigest(
272272 self , key , msg , hexdigest , digestmod , digest_size ,
273273 ):
274274 """Check a HMAC digest computed by hmac_digest()."""
275- d = self .hmac_digest (key , msg , digestmod = digestmod )
276- self .assertEqual (len (d ), digest_size )
277- self .assertEqual (d , binascii .unhexlify (hexdigest ))
275+ self ._check_hmac_hexdigest (
276+ key , msg , hexdigest , digest_size ,
277+ hmac_digest_func = self .hmac_digest ,
278+ hmac_digest_kwds = {'digestmod' : digestmod },
279+ )
278280
279- def assert_hmac_hexdigest_by_new (
281+ def assert_hmac_hexdigest_by_name (
280282 self , key , msg , hexdigest , hashname , digest_size
281283 ):
282284 """Check a HMAC digest computed by hmac_digest_by_name()."""
283- self .assertIsInstance (hashname , str | None )
284- d = self .hmac_digest_by_name (key , msg , hashname = hashname )
285+ self .assertIsInstance (hashname , str )
286+ self ._check_hmac_hexdigest (
287+ key , msg , hexdigest , digest_size ,
288+ hmac_digest_func = self .hmac_digest_by_name ,
289+ hmac_digest_kwds = {'hashname' : hashname },
290+ )
291+
292+ def _check_hmac_hexdigest (
293+ self , key , msg , hexdigest , digest_size ,
294+ hmac_digest_func , hmac_digest_kwds ,
295+ ):
296+ d = hmac_digest_func (key , msg , ** hmac_digest_kwds )
285297 self .assertEqual (len (d ), digest_size )
286298 self .assertEqual (d , binascii .unhexlify (hexdigest ))
287299
0 commit comments