mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-9216: Add usedforsecurity to hashlib constructors (GH-16044)
The usedforsecurity keyword only argument added to the hash constructors is useful for FIPS builds and similar restrictive environment with non-technical requirements that legacy algorithms be forbidden by their implementations without being explicitly annotated as not being used for any security related purposes. Linux distros with FIPS support benefit from this being standard rather than making up their own way(s) to do it. Contributed and Signed-off-by: Christian Heimes christian@python.org
This commit is contained in:
parent
3a4f66707e
commit
7cad53e6b0
20 changed files with 495 additions and 165 deletions
|
|
@ -601,13 +601,15 @@ static PyTypeObject SHA256type = {
|
|||
_sha256.sha256
|
||||
|
||||
string: object(c_default="NULL") = b''
|
||||
*
|
||||
usedforsecurity: bool = True
|
||||
|
||||
Return a new SHA-256 hash object; optionally initialized with a string.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_sha256_sha256_impl(PyObject *module, PyObject *string)
|
||||
/*[clinic end generated code: output=fa644436dcea5c31 input=09cce3fb855056b2]*/
|
||||
_sha256_sha256_impl(PyObject *module, PyObject *string, int usedforsecurity)
|
||||
/*[clinic end generated code: output=a1de327e8e1185cf input=9be86301aeb14ea5]*/
|
||||
{
|
||||
SHAobject *new;
|
||||
Py_buffer buf;
|
||||
|
|
@ -641,13 +643,15 @@ _sha256_sha256_impl(PyObject *module, PyObject *string)
|
|||
_sha256.sha224
|
||||
|
||||
string: object(c_default="NULL") = b''
|
||||
*
|
||||
usedforsecurity: bool = True
|
||||
|
||||
Return a new SHA-224 hash object; optionally initialized with a string.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_sha256_sha224_impl(PyObject *module, PyObject *string)
|
||||
/*[clinic end generated code: output=21e3ba22c3404f93 input=27a04ba24c353a73]*/
|
||||
_sha256_sha224_impl(PyObject *module, PyObject *string, int usedforsecurity)
|
||||
/*[clinic end generated code: output=08be6b36569bc69c input=9fcfb46e460860ac]*/
|
||||
{
|
||||
SHAobject *new;
|
||||
Py_buffer buf;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue