Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize hashing algorithm names #82334

Closed
tiran opened this issue Sep 13, 2019 · 8 comments
Closed

Normalize hashing algorithm names #82334

tiran opened this issue Sep 13, 2019 · 8 comments
Assignees
Labels
3.8 (EOL) end of life 3.9 only security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@tiran
Copy link
Member

tiran commented Sep 13, 2019

BPO 38153
Nosy @gpshead, @tiran, @miss-islington, @iritkatriel
PRs
  • bpo-38153: Normalize hashing algo names #16083
  • bpo-38153: detect shake independently from sha3 (GH-16143) #16143
  • [3.8] bpo-38153: Normalize hashlib algorithm names (GH-16083) (GH-16144) #16144
  • [3.8] bpo-38153: detect shake independently from sha3 (GH-16143) #16179
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/tiran'
    closed_at = <Date 2020-10-10.01:36:14.198>
    created_at = <Date 2019-09-13.09:50:32.516>
    labels = ['extension-modules', 'type-bug', '3.8', '3.9']
    title = 'Normalize hashing algorithm names'
    updated_at = <Date 2020-10-10.01:36:14.197>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2020-10-10.01:36:14.197>
    actor = 'gregory.p.smith'
    assignee = 'christian.heimes'
    closed = True
    closed_date = <Date 2020-10-10.01:36:14.198>
    closer = 'gregory.p.smith'
    components = ['Extension Modules']
    creation = <Date 2019-09-13.09:50:32.516>
    creator = 'christian.heimes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38153
    keywords = ['patch']
    message_count = 8.0
    messages = ['352270', '352314', '352324', '352436', '352539', '352541', '378355', '378360']
    nosy_count = 4.0
    nosy_names = ['gregory.p.smith', 'christian.heimes', 'miss-islington', 'iritkatriel']
    pr_nums = ['16083', '16143', '16144', '16179']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38153'
    versions = ['Python 3.8', 'Python 3.9']

    @tiran
    Copy link
    Member Author

    tiran commented Sep 13, 2019

    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.

    @tiran tiran added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes labels Sep 13, 2019
    @tiran tiran self-assigned this Sep 13, 2019
    @tiran tiran added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Sep 13, 2019
    @gpshead
    Copy link
    Member

    gpshead commented Sep 13, 2019

    as discussed, not pushing this back into 3.7 as we aren't hearing users call this a problem.

    @gpshead gpshead removed the 3.7 (EOL) end of life label Sep 13, 2019
    @gpshead
    Copy link
    Member

    gpshead commented Sep 13, 2019

    New changeset 995b5d3 by Gregory P. Smith (Christian Heimes) in branch 'master':
    bpo-38153: Normalize hashlib algorithm names (GH-16083)
    995b5d3

    @tiran
    Copy link
    Member Author

    tiran commented Sep 14, 2019

    New changeset eb2b0c6 by Christian Heimes in branch 'master':
    bpo-38153: detect shake independently from sha3 (GH-16143)
    eb2b0c6

    @tiran
    Copy link
    Member Author

    tiran commented Sep 16, 2019

    New changeset e8d7fa2 by Christian Heimes in branch '3.8':
    [3.8] bpo-38153: Normalize hashlib algorithm names (GH-16083) (GH-16144)
    e8d7fa2

    @miss-islington
    Copy link
    Contributor

    New changeset 0067fc2 by Miss Islington (bot) in branch '3.8':
    bpo-38153: detect shake independently from sha3 (GH-16143)
    0067fc2

    @iritkatriel
    Copy link
    Member

    Can this be closed?

    @gpshead
    Copy link
    Member

    gpshead commented Oct 10, 2020

    looks like it, thanks!

    @gpshead gpshead closed this as completed Oct 10, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants