mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Call `hashlib
functions with
usedforsecurity=False
`
This commit is contained in:
parent
f0dbe8180d
commit
13a87d8070
@ -6,6 +6,7 @@ import hashlib
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
from importlib import import_module
|
||||
from os import path
|
||||
@ -133,31 +134,23 @@ class FilenameUniqDict(dict):
|
||||
def md5(data=b'', **kwargs):
|
||||
"""Wrapper around hashlib.md5
|
||||
|
||||
Attempt call with 'usedforsecurity=False' if we get a ValueError, which happens when
|
||||
OpenSSL FIPS mode is enabled:
|
||||
ValueError: error:060800A3:digital envelope routines:EVP_DigestInit_ex:disabled for fips
|
||||
|
||||
See: https://github.com/sphinx-doc/sphinx/issues/7611
|
||||
Attempt call with 'usedforsecurity=False' if supported.
|
||||
"""
|
||||
|
||||
try:
|
||||
return hashlib.md5(data, **kwargs)
|
||||
except ValueError:
|
||||
return hashlib.md5(data, **kwargs, usedforsecurity=False) # type: ignore
|
||||
if sys.version_info[:2] > (3, 8):
|
||||
return hashlib.md5(data, usedforsecurity=False)
|
||||
return hashlib.md5(data, **kwargs)
|
||||
|
||||
|
||||
def sha1(data=b'', **kwargs):
|
||||
"""Wrapper around hashlib.sha1
|
||||
|
||||
Attempt call with 'usedforsecurity=False' if we get a ValueError
|
||||
|
||||
See: https://github.com/sphinx-doc/sphinx/issues/7611
|
||||
Attempt call with 'usedforsecurity=False' if supported.
|
||||
"""
|
||||
|
||||
try:
|
||||
return hashlib.sha1(data, **kwargs)
|
||||
except ValueError:
|
||||
return hashlib.sha1(data, **kwargs, usedforsecurity=False) # type: ignore
|
||||
if sys.version_info[:2] > (3, 8):
|
||||
return hashlib.sha1(data, usedforsecurity=False)
|
||||
return hashlib.sha1(data, **kwargs)
|
||||
|
||||
|
||||
class DownloadFiles(dict):
|
||||
|
Loading…
Reference in New Issue
Block a user