Skip to content
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

Ensure FIPS compliance by marking MD5 and SHA-1 as non-security-related #646

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

buugaj
Copy link

@buugaj buugaj commented Sep 26, 2024

This update addresses issues with environments that enforce FIPS standards by preventing non-compliant algorithms (like MD5 and SHA-1) from being used in contexts related to security. Since these hashes do not involve sensitive data they should be explicitly marked as not used for security.

The easiest syntax change would be to just add a kwarg to calls.
short_sha = hashlib.sha1(parts.encode('utf-8', usedforsecurity=False))
Unfortunately that's not compatible with Python <3.9.

Alternative solution to this problem could be switching to sha-256 hashes everywhere.
Alternative implementation could be:

def md5_not_usedforsecurity(data):
    try:
        return hashlib.md5(data, usedforsecurity=False).hexdigest()
    except TypeError:
        return hashlib.md5(data).hexdigest()

Context:
python/cpython#53462 (comment)

@buugaj
Copy link
Author

buugaj commented Oct 14, 2024

Hi @SmileyChris @jrief, without this change easy-thumbnails cannot be used on systems adhering to Federal Information Processing Standards. Please let me know if there are any further changes or actions needed to proceed with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant