Re: [PATCH v2 0/4] crypto: fips - Add back the lost key length checks to the hmac(sha*) algorithms
From: Eric Biggers
Date: Thu Dec 03 2026 - 15:25:59 EST
On Thu, Dec 03, 2026 at 10:33:12AM +0100, Thomas Huth wrote:
> The generic code in hmac_setkey() in crypto/hmac.c correctly rejects
> keys with less than 112 bits in FIPS-compliance mode. However, this
> check got lost when the hmac(sha*) algorithms were implemented via
> the crypto library.
>
> We noticed this behavioral change after backporting the corresponding
> commits to an older kernel branch: One of our downstream tests checks
> whether setting key length with less than 112 bits works in fips_enabled
> mode, and this test started failing. Thus let's restore the same behavior
> from kernel v6.16 and earlier by adding the key length check to the
> crypto/sha*.c files, too.
>
> Note: Please don't backport these patches to any kernel before 6.19, see:
> https://lore.kernel.org/linux-crypto/20261201202148.GA501764@xxxxxxxxxx/
>
> v2:
> - Moved the helper in the first patch out of the #ifdef and removed
> superfluous macro
> - Reworked patch descriptions and added notes to not backport this
> to the 6.18 stable trees
>
> Thomas Huth (4):
> crypto: fips - Add a wrapper function for checking the HMAC key length
> crypto: fips - Add back the lost key length check to the hmac(sha1)
> algorithm
> crypto: fips - Add back the lost key length check to the hmac(sha256)
> algorithm
> crypto: fips - Add back the lost key length check to the hmac(sha512)
> algorithm
Acked-by: Eric Biggers <ebiggers@xxxxxxxxxx>
- Eric