This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Normalize hashing algorithm names
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: christian.heimes, gregory.p.smith, iritkatriel, miss-islington
Priority: normal Keywords: patch

Created on 2019-09-13 09:50 by christian.heimes, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16083 merged christian.heimes, 2019-09-13 10:21
PR 16143 merged christian.heimes, 2019-09-14 14:11
PR 16144 merged christian.heimes, 2019-09-14 14:12
PR 16179 merged miss-islington, 2019-09-16 12:10
Messages (8)
msg352270 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-09-13 09:50
The hashlib module / PEP 452 and OpenSSL use slightly different conventions for hashing algorithm names. The old and common algorithms like md5 to sha512 use the same strings (all lower case, no dashes or underscores). But new algorithms like sha3_512, shake, sha512_256, and blake2 use different conventions.

The inconsistency bloats the list of available algorithms. Also the builtin OpenSSL constructor does not support Python's preferred names.

>>> import hashlib, _hashlib
>>> sorted(hashlib.algorithms_available)
['blake2b', 'blake2b512', 'blake2s', 'blake2s256', 'md4', 'md5', 'md5-sha1', 'ripemd160', 'sha1', 'sha224', 'sha256', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512', 'sha384', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'sha512', 'sha512-224', 'sha512-256', 'shake128', 'shake256', 'shake_128', 'shake_256', 'sm3', 'whirlpool']
>>> _hashlib.new("sha3_512")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unsupported hash type
>>> _hashlib.new("sha3-512")
<sha3-512 HASH object @ 0x7f1387890840>

I propose to normalize names to Python standard names for HASH.name, repr, list of available algorithms, and for the new() constructor.
msg352314 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2019-09-13 12:54
as discussed, not pushing this back into 3.7 as we aren't hearing users call this a problem.
msg352324 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2019-09-13 13:31
New changeset 995b5d38e7cc24cac3de8dfd516115f86b0bcf80 by Gregory P. Smith (Christian Heimes) in branch 'master':
bpo-38153: Normalize hashlib algorithm names (GH-16083)
https://github.com/python/cpython/commit/995b5d38e7cc24cac3de8dfd516115f86b0bcf80
msg352436 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-09-14 15:29
New changeset eb2b0c694aef6122fdf95015abb24e0d095b6401 by Christian Heimes in branch 'master':
bpo-38153: detect shake independently from sha3 (GH-16143)
https://github.com/python/cpython/commit/eb2b0c694aef6122fdf95015abb24e0d095b6401
msg352539 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-09-16 12:08
New changeset e8d7fa2db8a6c641019b06943852492f24ac3e69 by Christian Heimes in branch '3.8':
[3.8] bpo-38153: Normalize hashlib algorithm names (GH-16083) (GH-16144)
https://github.com/python/cpython/commit/e8d7fa2db8a6c641019b06943852492f24ac3e69
msg352541 - (view) Author: miss-islington (miss-islington) Date: 2019-09-16 12:28
New changeset 0067fc287a86cdd8d71dc2d402d596950ff88fca by Miss Islington (bot) in branch '3.8':
bpo-38153: detect shake independently from sha3 (GH-16143)
https://github.com/python/cpython/commit/0067fc287a86cdd8d71dc2d402d596950ff88fca
msg378355 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-10-09 22:45
Can this be closed?
msg378360 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2020-10-10 01:36
looks like it, thanks!
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82334
2020-10-10 01:36:14gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg378360

stage: patch review -> resolved
2020-10-09 22:45:05iritkatrielsetnosy: + iritkatriel
messages: + msg378355
2019-09-16 12:28:35miss-islingtonsetnosy: + miss-islington
messages: + msg352541
2019-09-16 12:10:28miss-islingtonsetpull_requests: + pull_request15789
2019-09-16 12:08:58christian.heimessetmessages: + msg352539
2019-09-14 15:29:58christian.heimessetmessages: + msg352436
2019-09-14 14:12:47christian.heimessetpull_requests: + pull_request15754
2019-09-14 14:11:18christian.heimessetpull_requests: + pull_request15753
2019-09-13 13:31:23gregory.p.smithsetmessages: + msg352324
2019-09-13 12:54:50gregory.p.smithsetmessages: + msg352314
versions: - Python 3.7
2019-09-13 10:21:06christian.heimessetkeywords: + patch
stage: patch review
pull_requests: + pull_request15705
2019-09-13 09:50:32christian.heimescreate