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

Method assert_hmac

Lib/test/test_hmac.py:235–276  ·  view source on GitHub ↗

Check that HMAC(key, msg) == digest. The 'hashfunc' and 'hashname' are used as 'digestmod' values, thereby allowing to test the underlying dispatching mechanism. Note that 'hashfunc' may be a string, a callable, or a PEP-257 module. Note that not all HMAC implementa

(
        self, key, msg, hexdigest, hashfunc, hashname, digest_size, block_size
    )

Source from the content-addressed store, hash-verified

233 return self.hmac_digest(key, msg, digestmod=hashname)
234
235 def assert_hmac(
236 self, key, msg, hexdigest, hashfunc, hashname, digest_size, block_size
237 ):
238 """Check that HMAC(key, msg) == digest.
239
240 The 'hashfunc' and 'hashname' are used as 'digestmod' values,
241 thereby allowing to test the underlying dispatching mechanism.
242
243 Note that 'hashfunc' may be a string, a callable, or a PEP-257
244 module. Note that not all HMAC implementations may recognize the
245 same set of types for 'hashfunc', but they should always accept
246 a hash function by its name.
247 """
248 if hashfunc == hashname:
249 choices = [hashname]
250 else:
251 choices = [hashfunc, hashname]
252
253 for digestmod in choices:
254 with self.subTest(digestmod=digestmod):
255 self.assert_hmac_new(
256 key, msg, hexdigest, digestmod,
257 hashname, digest_size, block_size
258 )
259 self.assert_hmac_hexdigest(
260 key, msg, hexdigest, digestmod, digest_size
261 )
262 self.assert_hmac_common_cases(
263 key, msg, hexdigest, digestmod,
264 hashname, digest_size, block_size
265 )
266 self.assert_hmac_extra_cases(
267 key, msg, hexdigest, digestmod,
268 hashname, digest_size, block_size
269 )
270
271 self.assert_hmac_new_by_name(
272 key, msg, hexdigest, hashname, digest_size, block_size
273 )
274 self.assert_hmac_hexdigest_by_name(
275 key, msg, hexdigest, hashname, digest_size
276 )
277
278 def assert_hmac_new(
279 self, key, msg, hexdigest, digestmod, hashname, digest_size, block_size

Callers 7

md5testMethod · 0.80
shatestMethod · 0.80
hmactestMethod · 0.80
test_sha3_224_nistMethod · 0.80
test_sha3_256_nistMethod · 0.80
test_sha3_384_nistMethod · 0.80
test_sha3_512_nistMethod · 0.80

Calls 7

assert_hmac_newMethod · 0.95
assert_hmac_hexdigestMethod · 0.95
subTestMethod · 0.80

Tested by

no test coverage detected