Skip to content

Commit e44b32f

Browse files
miss-islingtonvstinnerencukou
authored
[3.10] gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) (#125106)
[3.11] gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) (GH-109427) gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (GH-109423) 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 <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
1 parent 850189a commit e44b32f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Lib/test/test_socket.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -6409,12 +6409,16 @@ def test_sha256(self):
64096409
self.assertEqual(op.recv(512), expected)
64106410

64116411
def test_hmac_sha1(self):
6412-
expected = bytes.fromhex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")
6412+
# gh-109396: In FIPS mode, Linux 6.5 requires a key
6413+
# of at least 112 bits. Use a key of 152 bits.
6414+
key = b"Python loves AF_ALG"
6415+
data = b"what do ya want for nothing?"
6416+
expected = bytes.fromhex("193dbb43c6297b47ea6277ec0ce67119a3f3aa66")
64136417
with self.create_alg('hash', 'hmac(sha1)') as algo:
6414-
algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, b"Jefe")
6418+
algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, key)
64156419
op, _ = algo.accept()
64166420
with op:
6417-
op.sendall(b"what do ya want for nothing?")
6421+
op.sendall(data)
64186422
self.assertEqual(op.recv(512), expected)
64196423

64206424
# Although it should work with 3.19 and newer the test blocks on
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)