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

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

buugaj
Copy link
Contributor

@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
Contributor 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.

@buugaj
Copy link
Contributor Author

buugaj commented Nov 6, 2024

Hi @SmileyChris, @jrief
Let me know if we can somehow get some movement on this. Thanks.

@jrief jrief merged commit ecec162 into SmileyChris:master Nov 9, 2024
4 checks passed
@jrief
Copy link
Collaborator

jrief commented Nov 9, 2024

Thanks

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.

2 participants