René's URL Explorer Experiment


Title: Unify recognization of message digest names for `_hashlib` and `_hmac` · Issue #131876 · python/cpython · GitHub

Open Graph Title: Unify recognization of message digest names for `_hashlib` and `_hmac` · Issue #131876 · python/cpython

X Title: Unify recognization of message digest names for `_hashlib` and `_hmac` · Issue #131876 · python/cpython

Description: Feature or enhancement When calling hmac.new(key, digestmod=HASH), the HASH can be: a named algorithm recognized by hashlib.new, (e.g., sha256); a digest constructor (e.g., hashlib.openssl_sha256); an object supporting PEP-247. In #13015...

Open Graph Description: Feature or enhancement When calling hmac.new(key, digestmod=HASH), the HASH can be: a named algorithm recognized by hashlib.new, (e.g., sha256); a digest constructor (e.g., hashlib.openssl_sha256);...

X Description: Feature or enhancement When calling hmac.new(key, digestmod=HASH), the HASH can be: a named algorithm recognized by hashlib.new, (e.g., sha256); a digest constructor (e.g., hashlib.openssl_sha256);...

Opengraph URL: https://github.com/python/cpython/issues/131876

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unify recognization of message digest names for `_hashlib` and `_hmac`","articleBody":"# Feature or enhancement\n\nWhen calling `hmac.new(key, digestmod=HASH)`, the `HASH` can be:\n\n- a named algorithm recognized by `hashlib.new`, (e.g., `sha256`); \n- a digest constructor (e.g., `hashlib.openssl_sha256`);\n- an object supporting PEP-247.\n\nIn #130157, I've only supported named algorithms as HACL* only supports named algorithms. When using OpenSSL HMAC instead of HACL* HMAC, determining which hash function to use from HASH is left to the `hashlib` C implementation, which itself delegates this task to OpenSSL based on NIDs.\n\nI'm creating this issue so that we can brainstorm and decide how we should make HACL* HMAC able to also possibly detect objects supporting PEP-247. I plan to first upgrade the HMAC documentation:\n\n\u003e Return a new hmac object. *key* is a bytes or bytearray object giving the secret key. If *msg* is present, the method call *update(msg)* is made. *digestmod* is the digest name, digest constructor or module for the HMAC object to use. It may be any name suitable to [hashlib.new()](https://docs.python.org/3/library/hashlib.html#hashlib.new). Despite its argument position, it is required.\n\nAs you may see, the terms \"digest constructor\" and \"module\" are not well-defined. So I first plan to explain these two. In a second phase, I plan to extract the code in `_hashopenssl.c` responsible for determining whether a name is known or not in a separate module so that it can be shared with the HMAC C implementation later. The idea is to ease the future transition where we would drop OpenSSL (but this is still not planned nor decided, and this would likely require a PEP) and entirely rely on HACL* instead, both for speed and security.\n\nSome questions we need to address before letting HACL* HMAC support non-named algorithms:\n\n- Should we restrict digest constructors to HACL* ones only or not?\n- If not, should we consider `hashlib.openssl_sha256` equivalent to using HACL* SHA-256?\n- If not again, should we fallback to a generic implementation of HMAC which directly calls that callable\n\nCurrently, passing a digest constructor to the (OpenSSL) C implementation does not mean that we're using it. We're actually using it to recover the algorithm name, so it can regarded as an alias.\n\nOTOH, in the **Python** implementation of HMAC, any callable is considered a digest constructor and will be used as is. In some sense, it's a way to have HMAC implemented using an arbitrary hash function (HMAC is designed as such).\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-136995\n* gh-137301\n* gh-137307\n* gh-137319\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/picnixz","@type":"Person","name":"picnixz"},"datePublished":"2025-03-29T10:48:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/131876/cpython/issues/131876"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:81db4948-f27c-09f0-5fd8-782df5689721
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8B14:332828:B2574:F7069:696A0B29
html-safe-nonce44caae9fa4689d0665e9a027073098aae08621f326e5132b12772563e2ce9189
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjE0OjMzMjgyODpCMjU3NDpGNzA2OTo2OTZBMEIyOSIsInZpc2l0b3JfaWQiOiI0NjE3NTMyNzE0OTYzNDY0MDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb2816604386422dc1122031fa32f7d605991779ef5cf31ef89e37d959c117e92
hovercard-subject-tagissue:2957934243
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/131876/issue_layout
twitter:imagehttps://opengraph.githubassets.com/693142453c69345d7b65084c1d6073bef1ff10b46079c0fa3cd7c968e1333448/python/cpython/issues/131876
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/693142453c69345d7b65084c1d6073bef1ff10b46079c0fa3cd7c968e1333448/python/cpython/issues/131876
og:image:altFeature or enhancement When calling hmac.new(key, digestmod=HASH), the HASH can be: a named algorithm recognized by hashlib.new, (e.g., sha256); a digest constructor (e.g., hashlib.openssl_sha256);...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepicnixz
hostnamegithub.com
expected-hostnamegithub.com
None699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7266b2d935baa1c6474b16dd9feaa5ca30607261
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/131876#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F131876
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F131876
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/131876
Reloadhttps://github.com/python/cpython/issues/131876
Reloadhttps://github.com/python/cpython/issues/131876
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/131876
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/131876
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/131876
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/131876
Unify recognization of message digest names for _hashlib and _hmachttps://github.com/python/cpython/issues/131876#top
https://github.com/picnixz
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/picnixz
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Mar 29, 2025https://github.com/python/cpython/issues/131876#issue-2957934243
PEP-247https://peps.python.org/247
#130157https://github.com/python/cpython/pull/130157
PEP-247https://peps.python.org/247
hashlib.new()https://docs.python.org/3/library/hashlib.html#hashlib.new
gh-131876: extract _hashlib helpers into a separate directory #136995https://github.com/python/cpython/pull/136995
gh-131876: use extern storage for _hashlib helper functions #137301https://github.com/python/cpython/pull/137301
gh-131876: Revert "gh-131876: extract _hashlib helpers into a separate directory (#136995) #137307https://github.com/python/cpython/pull/137307
gh-131876: extract _hashlib helpers into a separate directory #137319https://github.com/python/cpython/pull/137319
picnixzhttps://github.com/picnixz
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.