(self)
| 424 | self.assertRaises(ValueError, h.hexdigest, negative_size) |
| 425 | |
| 426 | def test_shakes_overflow_digest_length(self): |
| 427 | # See https://github.com/python/cpython/issues/135759. |
| 428 | |
| 429 | exc_types = (OverflowError, ValueError) |
| 430 | # HACL* accepts an 'uint32_t' while OpenSSL accepts a 'size_t'. |
| 431 | openssl_overflown_sizes = (sys.maxsize + 1, 2 * sys.maxsize) |
| 432 | # https://github.com/python/cpython/issues/79103 restricts |
| 433 | # the accepted built-in lengths to 2 ** 29, even if OpenSSL |
| 434 | # accepts such lengths. |
| 435 | builtin_overflown_sizes = openssl_overflown_sizes + ( |
| 436 | 2 ** 29, 2 ** 32 - 10, 2 ** 32, 2 ** 32 + 10, |
| 437 | 2 ** 61, 2 ** 64 - 10, 2 ** 64, 2 ** 64 + 10, |
| 438 | ) |
| 439 | |
| 440 | for constructor in self.shake_constructors: |
| 441 | with self.subTest(constructor=constructor): |
| 442 | h = constructor(usedforsecurity=False) |
| 443 | if HASH is not None and isinstance(h, HASH): |
| 444 | overflown_sizes = openssl_overflown_sizes |
| 445 | else: |
| 446 | overflown_sizes = builtin_overflown_sizes |
| 447 | for invalid_size in overflown_sizes: |
| 448 | self.assertRaises(exc_types, h.digest, invalid_size) |
| 449 | self.assertRaises(exc_types, h.hexdigest, invalid_size) |
| 450 | |
| 451 | def test_name_attribute(self): |
| 452 | for cons in self.hash_constructors: |
nothing calls this directly
no test coverage detected