MCPcopy Index your code
hub / github.com/python/cpython / check_hmac_new

Method check_hmac_new

Lib/test/test_hmac.py:303–326  ·  view source on GitHub ↗

Check that HMAC(key, msg) == digest. This also tests that using an empty/None initial message and then calling `h.update(msg)` produces the same result, namely that HMAC(key, msg) is equivalent to HMAC(key).update(msg).

(
        self, key, msg, hexdigest, hashname, digest_size, block_size,
        hmac_new_func, hmac_new_kwds=frozendict(),
    )

Source from the content-addressed store, hash-verified

301 )
302
303 def check_hmac_new(
304 self, key, msg, hexdigest, hashname, digest_size, block_size,
305 hmac_new_func, hmac_new_kwds=frozendict(),
306 ):
307 """Check that HMAC(key, msg) == digest.
308
309 This also tests that using an empty/None initial message and
310 then calling `h.update(msg)` produces the same result, namely
311 that HMAC(key, msg) is equivalent to HMAC(key).update(msg).
312 """
313 h = hmac_new_func(key, msg, **hmac_new_kwds)
314 self.check_object(h, hexdigest, hashname, digest_size, block_size)
315
316 def hmac_new_feed(*args):
317 h = hmac_new_func(key, *args, **hmac_new_kwds)
318 h.update(msg)
319 self.check_hexdigest(h, hexdigest, digest_size)
320
321 with self.subTest('no initial message'):
322 hmac_new_feed()
323 with self.subTest('initial message is empty'):
324 hmac_new_feed(b'')
325 with self.subTest('initial message is None'):
326 hmac_new_feed(None)
327
328 def assert_hmac_hexdigest(
329 self, key, msg, hexdigest, digestmod, digest_size,

Callers 2

assert_hmac_newMethod · 0.95

Calls 3

frozendictClass · 0.85
check_objectMethod · 0.80
subTestMethod · 0.45

Tested by

no test coverage detected