Skip to content

Commit 24bd8dd

Browse files
committed
HID -> HashId
1 parent 1a9bd8c commit 24bd8dd

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

Lib/test/support/hashlib_helper.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Implementation(enum.StrEnum):
7373
hashlib = enum.auto()
7474

7575

76-
class HID(enum.StrEnum):
76+
class HashId(enum.StrEnum):
7777
"""Enumeration containing the canonical digest names.
7878
7979
Those names should only be used by hashlib.new() or hmac.new().
@@ -113,10 +113,10 @@ def is_keyed(self):
113113
return self.startswith("blake2")
114114

115115

116-
CANONICAL_DIGEST_NAMES = frozenset(map(str, HID.__members__))
116+
CANONICAL_DIGEST_NAMES = frozenset(map(str, HashId.__members__))
117117
NON_HMAC_DIGEST_NAMES = frozenset((
118-
HID.shake_128, HID.shake_256,
119-
HID.blake2s, HID.blake2b,
118+
HashId.shake_128, HashId.shake_256,
119+
HashId.blake2s, HashId.blake2b,
120120
))
121121

122122

@@ -189,32 +189,32 @@ def fullname(self, implementation):
189189
# constructors. If the constructor name is None, then this means that the
190190
# algorithm can only be used by the "agile" new() interfaces.
191191
_EXPLICIT_CONSTRUCTORS = MappingProxyType({ # fmt: skip
192-
HID.md5: HashInfo("_md5.md5", "openssl_md5", "md5"),
193-
HID.sha1: HashInfo("_sha1.sha1", "openssl_sha1", "sha1"),
194-
HID.sha224: HashInfo("_sha2.sha224", "openssl_sha224", "sha224"),
195-
HID.sha256: HashInfo("_sha2.sha256", "openssl_sha256", "sha256"),
196-
HID.sha384: HashInfo("_sha2.sha384", "openssl_sha384", "sha384"),
197-
HID.sha512: HashInfo("_sha2.sha512", "openssl_sha512", "sha512"),
198-
HID.sha3_224: HashInfo(
192+
HashId.md5: HashInfo("_md5.md5", "openssl_md5", "md5"),
193+
HashId.sha1: HashInfo("_sha1.sha1", "openssl_sha1", "sha1"),
194+
HashId.sha224: HashInfo("_sha2.sha224", "openssl_sha224", "sha224"),
195+
HashId.sha256: HashInfo("_sha2.sha256", "openssl_sha256", "sha256"),
196+
HashId.sha384: HashInfo("_sha2.sha384", "openssl_sha384", "sha384"),
197+
HashId.sha512: HashInfo("_sha2.sha512", "openssl_sha512", "sha512"),
198+
HashId.sha3_224: HashInfo(
199199
"_sha3.sha3_224", "openssl_sha3_224", "sha3_224"
200200
),
201-
HID.sha3_256: HashInfo(
201+
HashId.sha3_256: HashInfo(
202202
"_sha3.sha3_256", "openssl_sha3_256", "sha3_256"
203203
),
204-
HID.sha3_384: HashInfo(
204+
HashId.sha3_384: HashInfo(
205205
"_sha3.sha3_384", "openssl_sha3_384", "sha3_384"
206206
),
207-
HID.sha3_512: HashInfo(
207+
HashId.sha3_512: HashInfo(
208208
"_sha3.sha3_512", "openssl_sha3_512", "sha3_512"
209209
),
210-
HID.shake_128: HashInfo(
210+
HashId.shake_128: HashInfo(
211211
"_sha3.shake_128", "openssl_shake_128", "shake_128"
212212
),
213-
HID.shake_256: HashInfo(
213+
HashId.shake_256: HashInfo(
214214
"_sha3.shake_256", "openssl_shake_256", "shake_256"
215215
),
216-
HID.blake2s: HashInfo("_blake2.blake2s", None, "blake2s"),
217-
HID.blake2b: HashInfo("_blake2.blake2b", None, "blake2b"),
216+
HashId.blake2s: HashInfo("_blake2.blake2s", None, "blake2s"),
217+
HashId.blake2b: HashInfo("_blake2.blake2b", None, "blake2b"),
218218
})
219219
assert _EXPLICIT_CONSTRUCTORS.keys() == CANONICAL_DIGEST_NAMES
220220
get_hash_info = _EXPLICIT_CONSTRUCTORS.__getitem__
@@ -223,16 +223,16 @@ def fullname(self, implementation):
223223
# There is currently no OpenSSL one-shot named function and there will likely
224224
# be none in the future.
225225
_EXPLICIT_HMAC_CONSTRUCTORS = {
226-
HID(name): f"_hmac.compute_{name}"
226+
HashId(name): f"_hmac.compute_{name}"
227227
for name in CANONICAL_DIGEST_NAMES
228228
}
229229
# Neither HACL* nor OpenSSL supports HMAC over XOFs.
230-
_EXPLICIT_HMAC_CONSTRUCTORS[HID.shake_128] = None
231-
_EXPLICIT_HMAC_CONSTRUCTORS[HID.shake_256] = None
230+
_EXPLICIT_HMAC_CONSTRUCTORS[HashId.shake_128] = None
231+
_EXPLICIT_HMAC_CONSTRUCTORS[HashId.shake_256] = None
232232
# Strictly speaking, HMAC-BLAKE is meaningless as BLAKE2 is already a
233233
# keyed hash function. However, as it's exposed by HACL*, we test it.
234-
_EXPLICIT_HMAC_CONSTRUCTORS[HID.blake2s] = '_hmac.compute_blake2s_32'
235-
_EXPLICIT_HMAC_CONSTRUCTORS[HID.blake2b] = '_hmac.compute_blake2b_32'
234+
_EXPLICIT_HMAC_CONSTRUCTORS[HashId.blake2s] = '_hmac.compute_blake2s_32'
235+
_EXPLICIT_HMAC_CONSTRUCTORS[HashId.blake2b] = '_hmac.compute_blake2b_32'
236236
_EXPLICIT_HMAC_CONSTRUCTORS = MappingProxyType(_EXPLICIT_HMAC_CONSTRUCTORS)
237237
assert _EXPLICIT_HMAC_CONSTRUCTORS.keys() == CANONICAL_DIGEST_NAMES
238238

@@ -663,7 +663,7 @@ def _block_builtin_hash_new(name):
663663
"""Block a buitin-in hash name from the hashlib.new() interface."""
664664
assert isinstance(name, str), name
665665
assert name.lower() == name, f"invalid name: {name}"
666-
assert name in HID, f"invalid hash: {name}"
666+
assert name in HashId, f"invalid hash: {name}"
667667

668668
# Re-import 'hashlib' in case it was mocked
669669
hashlib = importlib.import_module('hashlib')

0 commit comments

Comments
 (0)