]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-95231: Disable md5 & crypt modules if FIPS is enabled (GH-94742)
authorShreenidhi Shedi <53473811+sshedi@users.noreply.github.com>
Mon, 15 Aug 2022 14:48:07 +0000 (20:18 +0530)
committerGitHub <noreply@github.com>
Mon, 15 Aug 2022 14:48:07 +0000 (07:48 -0700)
commit2fa03b1b0708d5d74630c351ec9abd2aac7550da
treebe1030d1375f8a441adde48da0d3355b7757fede
parent8621e6d43a25651b39a4286c0ea62f7bf9c436ea
gh-95231: Disable md5 & crypt modules if FIPS is enabled (GH-94742)

If kernel fips is enabled, we get permission error upon doing
`import crypt`. So, if kernel fips is enabled, disable the
unallowed hashing methods.

Python 3.9.1 (default, May 10 2022, 11:36:26)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import crypt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/crypt.py", line 117, in <module>
    _add_method('MD5', '1', 8, 34)
  File "/usr/lib/python3.9/crypt.py", line 94, in _add_method
    result = crypt('', salt)
  File "/usr/lib/python3.9/crypt.py", line 82, in crypt
    return _crypt.crypt(word, salt)
PermissionError: [Errno 1] Operation not permitted

Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
Lib/crypt.py
Misc/NEWS.d/next/Library/2022-07-25-15-45-06.gh-issue-95231.i807-g.rst [new file with mode: 0644]