diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-29 16:04:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 16:04:22 (GMT) |
commit | e3dfb9b967c560f4d094092dcae4a16fc9634681 (patch) | |
tree | 87cce94d1a8858c6a8cf591557a5778d7e01ae65 /Modules/clinic/_hashopenssl.c.h | |
parent | e5963ee32035d279c12ef32e87205d4c3e5e4a0e (diff) | |
download | cpython-e3dfb9b967c560f4d094092dcae4a16fc9634681.zip cpython-e3dfb9b967c560f4d094092dcae4a16fc9634681.tar.gz cpython-e3dfb9b967c560f4d094092dcae4a16fc9634681.tar.bz2 |
bpo-9216: Expose OpenSSL FIPS_mode() as _hashlib.get_fips_mode() (GH-19703)
test.pythoninfo logs OpenSSL FIPS_mode() and Linux
/proc/sys/crypto/fips_enabled in a new "fips" section.
Co-Authored-By: Petr Viktorin <encukou@gmail.com>
Diffstat (limited to 'Modules/clinic/_hashopenssl.c.h')
-rw-r--r-- | Modules/clinic/_hashopenssl.c.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/Modules/clinic/_hashopenssl.c.h b/Modules/clinic/_hashopenssl.c.h index de53e7e..275784d 100644 --- a/Modules/clinic/_hashopenssl.c.h +++ b/Modules/clinic/_hashopenssl.c.h @@ -725,7 +725,48 @@ exit: return return_value; } +#if !defined(LIBRESSL_VERSION_NUMBER) + +PyDoc_STRVAR(_hashlib_get_fips_mode__doc__, +"get_fips_mode($module, /)\n" +"--\n" +"\n" +"Determine the OpenSSL FIPS mode of operation.\n" +"\n" +"Effectively any non-zero return value indicates FIPS mode;\n" +"values other than 1 may have additional significance.\n" +"\n" +"See OpenSSL documentation for the FIPS_mode() function for details."); + +#define _HASHLIB_GET_FIPS_MODE_METHODDEF \ + {"get_fips_mode", (PyCFunction)_hashlib_get_fips_mode, METH_NOARGS, _hashlib_get_fips_mode__doc__}, + +static int +_hashlib_get_fips_mode_impl(PyObject *module); + +static PyObject * +_hashlib_get_fips_mode(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _hashlib_get_fips_mode_impl(module); + if ((_return_value == -1) && PyErr_Occurred()) { + goto exit; + } + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* !defined(LIBRESSL_VERSION_NUMBER) */ + #ifndef _HASHLIB_SCRYPT_METHODDEF #define _HASHLIB_SCRYPT_METHODDEF #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */ -/*[clinic end generated code: output=acb22ccddb7043c7 input=a9049054013a1b77]*/ + +#ifndef _HASHLIB_GET_FIPS_MODE_METHODDEF + #define _HASHLIB_GET_FIPS_MODE_METHODDEF +#endif /* !defined(_HASHLIB_GET_FIPS_MODE_METHODDEF) */ +/*[clinic end generated code: output=b0703dd5a043394d input=a9049054013a1b77]*/ |