Skip to content

Commit 71ec9e7

Browse files
miss-islingtonvstinnerencukou
authored andcommitted
[3.9] pythongh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (pythonGH-109423) (pythonGH-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 5b9bdc1 commit 71ec9e7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Lib/test/test_socket.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6032,12 +6032,16 @@ def test_sha256(self):
60326032
self.assertEqual(op.recv(512), expected)
60336033

60346034
def test_hmac_sha1(self):
6035-
expected = bytes.fromhex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")
6035+
# gh-109396: In FIPS mode, Linux 6.5 requires a key
6036+
# of at least 112 bits. Use a key of 152 bits.
6037+
key = b"Python loves AF_ALG"
6038+
data = b"what do ya want for nothing?"
6039+
expected = bytes.fromhex("193dbb43c6297b47ea6277ec0ce67119a3f3aa66")
60366040
with self.create_alg('hash', 'hmac(sha1)') as algo:
6037-
algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, b"Jefe")
6041+
algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, key)
60386042
op, _ = algo.accept()
60396043
with op:
6040-
op.sendall(b"what do ya want for nothing?")
6044+
op.sendall(data)
60416045
self.assertEqual(op.recv(512), expected)
60426046

60436047
# Although it should work with 3.19 and newer the test blocks on

0 commit comments

Comments
 (0)