bpo-29410: Change the default hash algorithm to SipHash13. (GH-28752)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
Inada Naoki 2021-10-10 17:29:46 +09:00 committed by GitHub
parent a1c3c9e824
commit ad970e8623
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 123 additions and 26 deletions

View file

@ -42,8 +42,8 @@ def pysiphash(uint64):
def skip_unless_internalhash(test):
"""Skip decorator for tests that depend on SipHash24 or FNV"""
ok = sys.hash_info.algorithm in {"fnv", "siphash24"}
msg = "Requires SipHash24 or FNV"
ok = sys.hash_info.algorithm in {"fnv", "siphash13", "siphash24"}
msg = "Requires SipHash13, SipHash24 or FNV"
return test if ok else unittest.skip(msg)(test)
@ -206,6 +206,19 @@ class StringlikeHashRandomizationTests(HashRandomizationTests):
# seed 42, 'abc'
[-678966196, 573763426263223372, -820489388, -4282905804826039665],
],
'siphash13': [
# NOTE: PyUCS2 layout depends on endianness
# seed 0, 'abc'
[69611762, -4594863902769663758, 69611762, -4594863902769663758],
# seed 42, 'abc'
[-975800855, 3869580338025362921, -975800855, 3869580338025362921],
# seed 42, 'abcdefghijk'
[-595844228, 7764564197781545852, -595844228, 7764564197781545852],
# seed 0, 'äú∑ℇ'
[-1093288643, -2810468059467891395, -1041341092, 4925090034378237276],
# seed 42, 'äú∑ℇ'
[-585999602, -2845126246016066802, -817336969, -2219421378907968137],
],
'siphash24': [
# NOTE: PyUCS2 layout depends on endianness
# seed 0, 'abc'