mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
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>
This commit is contained in:
parent
e5963ee320
commit
e3dfb9b967
4 changed files with 110 additions and 1 deletions
|
@ -720,6 +720,25 @@ def collect_windows(info_add):
|
|||
pass
|
||||
|
||||
|
||||
def collect_fips(info_add):
|
||||
try:
|
||||
import _hashlib
|
||||
except ImportError:
|
||||
_hashlib = None
|
||||
|
||||
if _hashlib is not None:
|
||||
call_func(info_add, 'fips.openssl_fips_mode', _hashlib, 'get_fips_mode')
|
||||
|
||||
try:
|
||||
with open("/proc/sys/crypto/fips_enabled", encoding="utf-8") as fp:
|
||||
line = fp.readline().rstrip()
|
||||
|
||||
if line:
|
||||
info_add('fips.linux_crypto_fips_enabled', line)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def collect_info(info):
|
||||
error = False
|
||||
info_add = info.add
|
||||
|
@ -735,6 +754,7 @@ def collect_info(info):
|
|||
collect_datetime,
|
||||
collect_decimal,
|
||||
collect_expat,
|
||||
collect_fips,
|
||||
collect_gdb,
|
||||
collect_gdbm,
|
||||
collect_get_config,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue