GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-94199: Remove hashlib.pbkdf2_hmac() Python implementation by vstinner · Pull Request #94200 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 24, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Remove the pure Python implementation of hashlib.pbkdf2_hmac(),
deprecated in Python 3.10. Python 3.10 and newer requires OpenSSL
1.1.1 or newer (PEP 644), this OpenSSL version provides a C
implementation of pbkdf2_hmac() which is faster.

  • Issue: ssl and hashlib: Remove functions deprecated in Python 3.10 #94199

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the awaiting core review label Jun 24, 2022
@vstinner
vstinner marked this pull request as ready for review June 24, 2022 08:20
@vstinner
vstinner requested a review from tiran as a code owner June 24, 2022 08:20
@vstinner

vstinner commented Jun 24, 2022

Copy link
Copy Markdown
Member Author

@tiran: I'm not sure about what I wrote: "the C implementation is safer". I don't know the rationale for removing the pure Python implementation. The docstring says that the Python implement is faster for long passwords. The deprecation message seems to say that the OpenSSL implementation is faster. So the removal is about performance, not safety?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 24, 2022

Copy link
Copy Markdown
Member Author

@tiran: I'm not sure about what I wrote: "the C implementation is safer".

I replaced it with: "is faster" :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tiran

tiran commented Jun 24, 2022

Copy link
Copy Markdown
Member

In this case faster is safer!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tiran
tiran reviewed Jun 24, 2022
View reviewed changes
Comment thread Lib/test/test_hashlib.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@tiran

tiran commented Jun 24, 2022

Copy link
Copy Markdown
Member

Please update documentation, too.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 24, 2022

Copy link
Copy Markdown
Member Author

Please update documentation, too.

I updated the doc and I included your test change. Please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 24, 2022

Copy link
Copy Markdown
Member Author

PR rebased to fix a conflict on Doc/whatsnew/3.12.rst.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Jun 24, 2022
ssl and hashlib: Remove functions deprecated in Python 3.10 #94199
Closed
@vstinner

vstinner commented Jun 26, 2022

Copy link
Copy Markdown
Member Author

@tiran: Would you mind to review the completed PR? (updated doc)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tiran
tiran reviewed Jun 26, 2022
View reviewed changes
Comment thread Doc/library/hashlib.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@rhettinger

rhettinger commented Jun 26, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

PEP 399 says that we should have a pure python version when possible. That said if there is bona fide security risk, then it should be removed.

Also, do you know if PyPy relies on the pure python version or does it too build with OpenSSL?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rhettinger
rhettinger requested a review from brettcannon June 26, 2022 15:00
vstinner added 2 commits June 27, 2022 02:14
@vstinner
gh-94199: Remove hashlib.pbkdf2_hmac() Python implementation
4584fdf
Remove the pure Python implementation of hashlib.pbkdf2_hmac(),
deprecated in Python 3.10. Python 3.10 and newer requires OpenSSL
1.1.1 or newer (PEP 644), this OpenSSL version provides a C
implementation of pbkdf2_hmac() which is faster.
@vstinner
Rephase versionchanged note in the doc
d78c578
@vstinner

vstinner commented Jun 27, 2022

Copy link
Copy Markdown
Member Author

PEP 399 says that we should have a pure python version when possible. That said if there is bona fide security risk, then it should be removed.

PyPy gets the C implementation of pbkdf2_hmac() from OpenSSL: https://foss.heptapod.net/pypy/pypy/-/blob/branch/py3.9/lib_pypy/_hashlib/__init__.py#L205

It has the same Python fallack implementation if the C implementation is missing: https://foss.heptapod.net/pypy/pypy/-/blob/branch/py3.9/lib-python/3/hashlib.py#L192

But I guess that the C implementaiton is always available on OpenSSL 1.1.1 and newer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brettcannon
brettcannon approved these changes Jun 27, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jun 27, 2022
@ambv
ambv merged commit 71d5299 into python:main Jun 28, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Jun 28, 2022
@vstinner
vstinner deleted the pbkdf2_hmac_py branch June 28, 2022 10:32
gvanrossum pushed a commit to gvanrossum/cpython that referenced this pull request Jun 30, 2022
@vstinner @gvanrossum
pythongh-94199: Remove hashlib.pbkdf2_hmac() Python implementation (p…
8603119
…ythonGH-94200)

Remove the pure Python implementation of hashlib.pbkdf2_hmac(),
deprecated in Python 3.10. Python 3.10 and newer requires OpenSSL
1.1.1 or newer (PEP 644), this OpenSSL version provides a C
implementation of pbkdf2_hmac() which is faster.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@brettcannon brettcannon brettcannon approved these changes
+1 more reviewer
@tiran tiran tiran left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@vstinner @tiran @rhettinger @brettcannon @ambv @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.