-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Cannot save SVG file with FIPS compliant Python #18192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'll provide a pull request soon. The Python docs for hashlib includes the following note:
I tested that I can just change the
|
Is there any reason to not use the standard library uuid? |
I was actually unaware of the uuid library, which is ironic since the salt for the hash is produced by Here's my 2 cents on the idea of using the functions for the uuid library based on my reading of the uuid documentation:
|
My pull request #18193 on this has passed tests and is just waiting for review now. I chose to use SHA512 rather than SHA1 which I first tested. I chose SHA512 for future proofing. I know in recent news there has been some research in generating SHA1 collisions which isn't really an issue for matplotlib's use of SHA1, but I can forsee a FIPS-like specification in the future dropping SHA1 like it did MD5. |
Allow savefig to save SVGs on FIPS enabled systems #18192
Bug report
Bug summary
If you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot use
plt.savefig
to save an image in SVG format. This is because theRenderSVG._make_id
method takes the first 10 characters of ahashlib.md5
digest of entries in the SVG as the ID for that part of the SVG file. The MD5 algorithm is disabled on FIPS compliant systems or in FIPS compliant Python installs.Code for reproduction
The big requirement here is a FIPS compliant system or at least a Python install compiled to be FIPS compliant. Then the following code will reproduce the error.
To reproduce,
sudo fips-mode-setup --enable && sudo reboot
fips-mode-setup --check
and it returnedFIPS mode is enabled.
.sudo dnf install python3
python3 -m venv venv
./venv/bin/python -m pip install -U pip setuptools
./venv/bin/python -m pip install matplotlib
./venv/bin/python demo.py
. The contents ofdemo.py
are listed below.Actual outcome
Expected outcome
Expect no errors and an SVG named "range10.svg" that shows the same plot as a PNG named "range10.png".
Matplotlib version
fips-mode-setup --check
returnsFIPS mode is enabled
print(matplotlib.get_backend())
): aggThe text was updated successfully, but these errors were encountered: