All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Huth" <thuth@redhat.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	linux-crypto@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	"Eric Biggers" <ebiggers@kernel.org>
Subject: Re: [PATCH v2 2/4] crypto: fips - Add back the lost key length check to the hmac(sha1) algorithm
Date: Thu, 03 Dec 2026 09:50:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-247502@kernel.org> (raw)
In-Reply-To: <20261203093316.97847-3-thuth@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] crypto: per-driver FIPS check in crypto_hmac_sha1_setkey()
  skips HW drivers
--

commit d6b7b3a077cba610436db798132876d0dbc2035d
Author: Thomas Huth <thuth@redhat.com>

crypto: fips - Add back the lost key length check to the hmac(sha1) algorithm

This commit adds a FIPS minimum key length check to
crypto_hmac_sha1_setkey() so hmac-sha1-lib rejects keys shorter than
112 bits in FIPS mode.

> diff --git a/crypto/sha1.c b/crypto/sha1.c
> index 4fbf61cf03709..83eb405f011f0 100644
> --- a/crypto/sha1.c
> +++ b/crypto/sha1.c

[ ... ]

> @@ -122,6 +123,9 @@ static int crypto_sha1_import_core(struct shash_desc *desc, const void *in)
>  static int crypto_hmac_sha1_setkey(struct crypto_shash *tfm,
>  				   const u8 *raw_key, unsigned int keylen)
>  {
> +	if (fips_hmac_keylen_disallowed(keylen))
> +		return -EINVAL;
> +
>  	hmac_sha1_preparekey(HMAC_SHA1_KEY(tfm), raw_key, keylen);
>  	return 0;
>  }

[Severity: Medium]
Does enforcing fips_hmac_keylen_disallowed() only in
crypto_hmac_sha1_setkey() break hardware hmac(sha1) drivers under
CONFIG_CRYPTO_SELFTESTS_FULL with fips=1?

In FIPS mode, generate_random_hash_testvec() fuzzes keys of 1..80 bytes
against hmac-sha1-lib, which now returns -EINVAL for keys under 14 bytes.
Hardware drivers without CRYPTO_ALG_NEED_FALLBACK (e.g., caamhash.c) accept
those keys, causing test_ahash_vec_cfg() to fail and alg_test() to panic.

Higher-priority hardware hmac(sha1) drivers also continue to accept short
keys at runtime in FIPS mode.  Enforcing fips_hmac_keylen_disallowed()
centrally in crypto_shash_setkey() and crypto_ahash_setkey() for hmac(...)
algorithms would cover software, library, and hardware drivers uniformly.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203093316.97847-1-thuth@redhat.com?part=2

  reply	other threads:[~2026-12-03  9:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:33 [PATCH v2 0/4] crypto: fips - Add back the lost key length checks to the hmac(sha*) algorithms Thomas Huth
2026-12-03  9:33 ` [PATCH v2 1/4] crypto: fips - Add a wrapper function for checking the HMAC key length Thomas Huth
2026-12-03  9:33 ` [PATCH v2 2/4] crypto: fips - Add back the lost key length check to the hmac(sha1) algorithm Thomas Huth
2026-12-03  9:50   ` sashiko-bot [this message]
2026-12-03  9:33 ` [PATCH v2 3/4] crypto: fips - Add back the lost key length check to the hmac(sha256) algorithm Thomas Huth
2026-12-03  9:33 ` [PATCH v2 4/4] crypto: fips - Add back the lost key length check to the hmac(sha512) algorithm Thomas Huth
2026-12-03 20:25 ` [PATCH v2 0/4] crypto: fips - Add back the lost key length checks to the hmac(sha*) algorithms Eric Biggers

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=sashiko-outbox-247502@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=davem@davemloft.net \
    --cc=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.