Skip to content
Myr

support FIPS builds without SHA-1 (#5460)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by GitHub · parents 7320e31, db46111 · Browse files · 2 files+13 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−1 removed

  • other:+13 added−1 removed

2 files+13 added−1 removed

modified:src/flask/sessions.py+9 added-1 removed
275 unmodified lines
276277session_json_serializer = TaggedJSONSerializer()278279280def _lazy_sha1(string: bytes = b"") -> t.Any:281 """Don't access ``hashlib.sha1`` until runtime. FIPS builds may not include282 SHA-1, in which case the import and use as a default would fail before the283 developer can configure something else.284 """285 return hashlib.sha1(string)286287288class SecureCookieSessionInterface(SessionInterface):289 """The default session interface that stores sessions in signed cookies290 through the :mod:`itsdangerous` module.291 """
1 unmodified line
293 #: the salt that should be applied on top of the secret key for the294 #: signing of cookie based sessions.295 salt = "cookie-session"296 #: the hash function to use for the signature. The default is sha1289 digest_method = staticmethod(hashlib.sha1)297 digest_method = staticmethod(_lazy_sha1)298 #: the name of the itsdangerous supported key derivation. The default299 #: is hmac.300 key_derivation = "hmac"301 #: A python serializer for the payload. The default is a compact
78 unmodified lines
modified:CHANGES.rst+4 added
1 unmodified line
2-------------34Unreleased56- The default ``hashlib.sha1`` may not be available in FIPS builds. Don't7 access it at import time so the developer has time to change the default.8 :issue:`5448`91011Version 3.0.212-------------1314Released 2024-02-03
1549 unmodified lines