MCPcopy Index your code
hub / github.com/RustPython/RustPython / check_hmac_new

Method check_hmac_new

Lib/test/test_hmac.py:304–327  ·  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=types.MappingProxyType({}),
    )

Source from the content-addressed store, hash-verified

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

Callers 2

assert_hmac_newMethod · 0.95

Calls 2

check_objectMethod · 0.80
subTestMethod · 0.80

Tested by

no test coverage detected