10000 remove md5 usage to prevent issues on FIPS enabled systems matplotlib… · matplotlib/matplotlib@c830f5c · GitHub
[go: up one dir, main page]

Skip to content

Commit c830f5c

Browse files
committed
remove md5 usage to prevent issues on FIPS enabled systems #29603
1 parent b8b6899 commit c830f5c

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

lib/matplotlib/sphinxext/mathmpl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ 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(f'{latex}{fontset}{fontsize}'.encode()).hexdigest()[-10:])
150150

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

lib/matplotlib/testing/compare.py

Lines 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()
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ 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(src.encode('utf-8')).hexdigest()
172172
filepath = Path(cls._texcache)
173173

174174
num_letters, num_levels = 2, 2

0 commit comments

Comments
 (0)
0