Skip to content

test_socket.LinuxKernelCryptoAPI.test_hmac_sha1() fails on "AMD64 RHEL8 FIPS Only Blake2 Builtin Hash 3.x" buildbot #109396

Closed

Description

@vstinner

Bug report

When FIPS is enabled in Linux, LinuxKernelCryptoAPI.test_hmac_sha1() fails with OSError: [Errno 22] Invalid argument.

test.pythoninfo:

fips.linux_crypto_fips_enabled: 1
fips.openssl_fips_mode: 1

Error:

ERROR: test_hmac_sha1 (test.test_socket.LinuxKernelCryptoAPI.test_hmac_sha1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/test/test_socket.py", line 6479, in test_hmac_sha1
    algo.setsockopt(socket.SOL_ALG, socket.ALG_SET_KEY, b"Jefe")
OSError: [Errno 22] Invalid argument

build: https://buildbot.python.org/all/#/builders/469/builds/5995

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    on Sep 14, 2023
  2. vstinner commented on Sep 14, 2023

    @vstinner
    MemberAuthor
  3. vstinner commented on Sep 14, 2023

    @vstinner
    MemberAuthor

    It seems like hmac in FIPS mode requires a key of at least 112 bits (14 bytes), whereas the test uses a key of 32 bits (4 bytes). See hmac_setkey() in the master branch of the Linux kernel:

    	if (fips_enabled && (keylen < 112 / 8))
    		return -EINVAL;

    https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be514f4abbfc071004cbe7/crypto/hmac.c#L55-L56

  4. added 3 commits that reference this issue on Sep 14, 2023
  5. added 2 commits that reference this issue on Sep 14, 2023
  6. added a commit that references this issue on Sep 14, 2023
  7. added a commit that references this issue on Sep 14, 2023
  8. added 2 commits that reference this issue on Oct 8, 2024
  9. encukou commented on Oct 8, 2024

    @encukou
    Member

    This fails on 3.10 & 3.9 buildbots, so let's backport there too.

  10. added a commit that references this issue on Oct 22, 2024
  11. added a commit that references this issue on Nov 4, 2024
  12. added a commit that references this issue on Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions