Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2d5e503

Browse filesBrowse files
authored
Merge pull request #29608 from martinky24/bugfix/29603/md5-fips
Remove md5 usage to prevent issues on FIPS enabled systems (closes #29603)
2 parents 8465b0f + 938ad62 commit 2d5e503
Copy full SHA for 2d5e503

File tree

3 files changed

+13
-9
lines changed
Filter options

3 files changed

+13
-9
lines changed

‎lib/matplotlib/sphinxext/mathmpl.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/mathmpl.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ def latex2html(node, source):
146146
fontset = node['fontset']
147147
fontsize = node['fontsize']
148148
name = 'math-{}'.format(
149-
hashlib.md5(f'{latex}{fontset}{fontsize}'.encode()).hexdigest()[-10:])
149+
hashlib.sha256(
150+
f'{latex}{fontset}{fontsize}'.encode(),
151+
usedforsecurity=False,
152+
).hexdigest()[-10:])
150153

151154
destdir = Path(setup.app.builder.outdir, '_images', 'mathmpl')
152155
destdir.mkdir(parents=True, exist_ok=True)

‎lib/matplotlib/testing/compare.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/compare.py
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,20 @@ def get_cache_dir():
4646

4747

4848
def get_file_hash(path, block_size=2 ** 20):
49-
md5 = hashlib.md5()
49+
sha256 = hashlib.sha256(usedforsecurity=False)
5050
with open(path, 'rb') as fd:
5151
while True:
5252
data = fd.read(block_size)
5353
if not data:
5454
break
55-
md5.update(data)
55+
sha256.update(data)
5656

5757
if Path(path).suffix == '.pdf':
58-
md5.update(str(mpl._get_executable_info("gs").version)
59-
.encode('utf-8'))
58+
sha256.update(str(mpl._get_executable_info("gs").version).encode('utf-8'))
6059
elif Path(path).suffix == '.svg':
61-
md5.update(str(mpl._get_executable_info("inkscape").version)
62-
.encode('utf-8'))
60+
sha256.update(str(mpl._get_executable_info("inkscape").version).encode('utf-8'))
6361

64-
return md5.hexdigest()
62+
return sha256.hexdigest()
6563

6664

6765
class _ConverterError(Exception):

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ def get_basefile(cls, tex, fontsize, dpi=None):
168168
Return a filename based on a hash of the string, fontsize, and dpi.
169169
"""
170170
src = cls._get_tex_source(tex, fontsize) + str(dpi)
171-
filehash = hashlib.md5(src.encode('utf-8')).hexdigest()
171+
filehash = hashlib.sha256(
172+
src.encode('utf-8'),
173+
usedforsecurity=False
174+
).hexdigest()
172175
filepath = Path(cls._texcache)
173176

174177
num_letters, num_levels = 2, 2

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.