Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions 30 Lib/test/test_hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ def get_fips_mode():

requires_blake2 = unittest.skipUnless(_blake2, 'requires _blake2')

# bpo-46913: Don't test the _sha3 extension on a Python UBSAN build
# TODO(gh-99108): Revisit this after _sha3 uses HACL*.
SKIP_SHA3 = support.check_sanitizer(ub=True)
requires_sha3 = unittest.skipUnless(not SKIP_SHA3, 'requires _sha3')
try:
import _sha3
except ImportError:
_sha3 = None

requires_sha3 = unittest.skipUnless(_sha3, 'requires _sha3')


def hexstr(s):
Expand Down Expand Up @@ -132,8 +134,6 @@ def __init__(self, *args, **kwargs):

self.constructors_to_test = {}
for algorithm in algorithms:
if SKIP_SHA3 and algorithm.startswith('sha3_'):
continue
self.constructors_to_test[algorithm] = set()

# For each algorithm, test the direct constructor and the use
Expand Down Expand Up @@ -180,20 +180,18 @@ def add_builtin_constructor(name):
add_builtin_constructor('sha256')
add_builtin_constructor('sha384')
add_builtin_constructor('sha512')
_sha3 = self._conditional_import_module('_sha3')
if _sha3:
add_builtin_constructor('sha3_224')
add_builtin_constructor('sha3_256')
add_builtin_constructor('sha3_384')
add_builtin_constructor('sha3_512')
add_builtin_constructor('shake_128')
add_builtin_constructor('shake_256')
if _blake2:
add_builtin_constructor('blake2s')
add_builtin_constructor('blake2b')

if not SKIP_SHA3:
_sha3 = self._conditional_import_module('_sha3')
if _sha3:
add_builtin_constructor('sha3_224')
add_builtin_constructor('sha3_256')
add_builtin_constructor('sha3_384')
add_builtin_constructor('sha3_512')
add_builtin_constructor('shake_128')
add_builtin_constructor('shake_256')

super(HashLibTestCase, self).__init__(*args, **kwargs)

@property
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.