[New-bugs-announce] [issue38132] Simplify hashlib implementation
report at bugs.python.org
Thu Sep 12 06:44:02 EDT 2019
New submission from Christian Heimes <lists at cheimes.de>:
The hashlib module uses complicated macros and some pointless optimization. The code can be simplified to make maintenance easier. Cleanup also makes it easier to get rid of static global state and to add "usedforsecurity" feature.
* The EVPobject contains a PyObject* with the name of the hashing algorithm as PyUnicode object. The name is rarely used and can be efficiently calculated from a const char* of the EVP_MD_CTX.
* The module caches pre-generated EVP_MD_CTX objects for commonly used hashes like sha256. Tests with timeit has shown that generating a EVP_MD_CTX from a EVP constructor is as fast as copying and reinitializing a EVP_MD_CTX.
* The pre-calculated constructs can be replaced with argument clinic to make the code more readable.
components: Extension Modules
nosy: christian.heimes, gregory.p.smith
title: Simplify hashlib implementation
versions: Python 3.8, Python 3.9
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce