From: Eric Biggers <ebiggers@kernel.org>
To: Thomas Huth <thuth@redhat.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
linux-crypto@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/4] crypto: Add back the lost FIPS key length checks to the hmac(sha*) algorithms
Date: Tue, 1 Dec 2026 20:21:48 +0000 [thread overview]
Message-ID: <20261201202148.GA501764@google.com> (raw)
In-Reply-To: <20261201184722.887139-1-thuth@redhat.com>
On Tue, Dec 01, 2026 at 07:47:18PM +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
> libcrypto. Thus add the key length check to the crypto/sha*.c files, too,
> to be compliant again with the FIPS requirements.
>
> (I've fixed each file in a separate patch to ease backporting if required)
>
> Thomas Huth (4):
> crypto: Add a wrapper function for checking the HMAC key length in
> FIPS mode
> crypto: Add back the lost FIPS key length check to the hmac(sha1)
> algorithm
> crypto: Add back the lost FIPS key length check to the hmac(sha256)
> algorithm
> crypto: Add back the lost FIPS key length check to the hmac(sha512)
> algorithm
>
> crypto/hmac.c | 2 +-
> crypto/sha1.c | 4 ++++
> crypto/sha256.c | 7 +++++++
> crypto/sha512.c | 7 +++++++
> include/linux/fips.h | 9 +++++++++
> 5 files changed, 28 insertions(+), 1 deletion(-)
Note that many FIPS modules implement HMAC without this check. Also,
even after this patchset, not all hmac(sha*) implementations in the
kernel do this check (and for s390, this is the first time the check
will have ever been present). And anytime HMAC is used as an entropy
extractor, like in HKDF, this check looks at the wrong length.
So from a technical perspective, it's hard to evaluate this patchset.
It doesn't help that the commit messages only include vague references
to "FIPS compliance".
That being said, if this patchset is really necessary and sufficient to
make the specific FIPS lab you are using happy (which presumably is the
real reason, that was not explicitly stated in the patchset), I am okay
with it. At least it's less intrusive than other potential changes.
What is inevitably going to happen, though, is that the Fixes tags are
going to result in this being backported to 6.18.y, where they will
reintroduce the regression where the kernel fails to boot with fips=1
due to the HKDF self-test failure.
And failure to boot is a real issue that people actually care about, as
was quite clear when it happened last time! (Also, it seems that the
distros that offer fips=1 don't yet have testing in place to detect such
issues preemptively.)
So I would strongly recommend leaving a note in the commit message about
the 6.18.y backporting pitfall. Otherwise it will likely get backported
without considering that and reintroduce the fips=1 boot failure.
- Eric
prev parent reply other threads:[~2026-12-01 20:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 18:47 [PATCH 0/4] crypto: Add back the lost FIPS key length checks to the hmac(sha*) algorithms Thomas Huth
2026-12-01 18:47 ` [PATCH 1/4] crypto: Add a wrapper function for checking the HMAC key length in FIPS mode Thomas Huth
2026-12-01 18:52 ` sashiko-bot
2026-12-01 19:07 ` Thomas Huth
2026-12-01 18:47 ` [PATCH 2/4] crypto: Add back the lost FIPS key length check to the hmac(sha1) algorithm Thomas Huth
2026-12-01 18:47 ` [PATCH 3/4] crypto: Add back the lost FIPS key length check to the hmac(sha256) algorithm Thomas Huth
2026-12-01 18:47 ` [PATCH 4/4] crypto: Add back the lost FIPS key length check to the hmac(sha512) algorithm Thomas Huth
2026-12-01 20:21 ` Eric Biggers [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201202148.GA501764@google.com \
--to=ebiggers@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox