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: Add truncated SHA512/224 and SHA512/256
Type: enhancement Stage: patch review
Components: Documentation, Extension Modules Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: christian.heimes, docs@python, gregory.p.smith, martin.panter, nicktimko, sir-sigurd
Priority: normal Keywords: patch

Created on 2016-04-23 19:27 by christian.heimes, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
cpython-cheimes-0001-Add-truncate-SHA512-224-and-SHA512-256-hash-algorith.patch christian.heimes, 2016-04-23 19:27 review
Messages (4)
msg264068 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-04-23 19:27
SHA512/224 and SHA512/256 are truncated versions of SHA512. Just like SHA384 they use the same algorithm but different initial values and a smaller digest. I took the start vectors and test values from libtomcrypt.

Like in my blake2 branch I have add tp_new to the types and removed the old factory methods. Now it is possible to instantiate the types.

The code is also in my github fork https://github.com/tiran/cpython/tree/feature/sha512truncated
msg266471 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-05-27 03:18
Would it be appropriate to mention these hashes higher up in the documentation, e.g. where it lists the names of the always-present constructors?

I haven’t had a close look at the C code. It looks like you are also adding better multithreading support for SHA-512 objects (? related to Issue 4821).
msg316086 - (view) Author: Nick Timkovich (nicktimko) * Date: 2018-05-02 19:36
Was this patch mostly ready to go? The additional SHA512 variants are appealing because they run ~40% faster than SHA256 on 64-bit hardware for longer messages.
msg404598 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-10-21 13:11
OpenSSL 1.1.1 comes with sha512_256 and sha512_224. I propose that we use the OpenSSL implementation and don't add the variants to our _sha512 module.

>>> hashlib.new("sha512_256").hexdigest()
'c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a'
>>> hashlib.new("sha512_224").hexdigest()
'6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4'
History
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71021
2021-10-21 13:11:03christian.heimessetversions: + Python 3.11, - Python 3.8
nosy: + docs@python

messages: + msg404598

assignee: docs@python
components: + Documentation
2020-08-07 07:39:42sir-sigurdsetnosy: + sir-sigurd
2018-05-02 21:44:12gregory.p.smithsetversions: + Python 3.8, - Python 3.6
2018-05-02 19:36:01nicktimkosetnosy: + nicktimko
messages: + msg316086
2016-05-27 03:18:22martin.pantersetnosy: + martin.panter
messages: + msg266471
2016-04-23 19:27:41christian.heimescreate