Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 011fb84

Browse filesBrowse files
miss-islingtonvstinnerencukou
authored
[3.9] gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) (GH-125107)
Use a longer key: FIPS mode requires at least of at least 112 bits. The previous key was only 32 bits. (cherry picked from commit e091b9f) (cherry picked from commit f7bfac4) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent 6335557 commit 011fb84
Copy full SHA for 011fb84

File tree

2 files changed

+10
-3
lines changed
Filter options

2 files changed

+10
-3
lines changed

‎Lib/test/test_socket.py

Copy file name to clipboardExpand all lines: Lib/test/test_socket.py
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6390,12 +6390,16 @@ def test_sha256(self):
63906390
self.assertEqual(op.recv(512), expected)
63916391

63926392
def test_hmac_sha1(self):
6393-
expected = bytes.fromhex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")
6393+
# gh-109396: In FIPS mode, Linux 6.5 requires a key
6394+
# of at least 112 bits. Use a key of 152 bits.
6395+
key = b"Python loves AF_ALG"
6396+
data = b"what do ya want for nothing?"
6397+
expected = bytes.fromhex("193dbb43c6297b47ea6277ec0ce67119a3f3aa66")
63946398
with self.create_alg('hash', 'hmac(sha1)') as algo:
6395-
algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, b"Jefe")
6399+
algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, key)
63966400
op, _ = algo.accept()
63976401
with op:
6398-
op.sendall(b"what do ya want for nothing?")
6402+
op.sendall(data)
63996403
self.assertEqual(op.recv(512), expected)
64006404

64016405
# Although it should work with 3.19 and newer the test blocks on
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix ``test_socket.test_hmac_sha1()`` in FIPS mode. Use a longer key: FIPS
2+
mode requires at least of at least 112 bits. The previous key was only 32
3+
bits. Patch by Victor Stinner.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.