linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Li Tian <litian@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>,
	Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: Re: [PATCH RFC] crypto/hkdf: Skip tests with keys too short in FIPS mode
Date: Tue, 9 Dec 2025 14:54:01 -0800	[thread overview]
Message-ID: <20251209225401.GA54030@quark> (raw)
In-Reply-To: <20251205113136.17920-1-litian@redhat.com>

On Fri, Dec 05, 2025 at 07:31:36PM +0800, Li Tian wrote:
> FIPS mode mandates the keys to _setkey should be longer than 14 bytes.
> It's up to the callers to not use keys too short.
> 
> Signed-off-by: Li Tian <litian@redhat.com>
> ---
>  crypto/hkdf.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/crypto/hkdf.c b/crypto/hkdf.c
> index 82d1b32ca6ce..73d318f3f677 100644
> --- a/crypto/hkdf.c
> +++ b/crypto/hkdf.c
> @@ -10,6 +10,7 @@
>  #include <crypto/internal/hash.h>
>  #include <crypto/sha2.h>
>  #include <crypto/hkdf.h>
> +#include <linux/fips.h>
>  #include <linux/module.h>
>  
>  /*
> @@ -462,7 +463,12 @@ static const struct hkdf_testvec hkdf_sha512_tv[] = {
>  };
>  
>  static int hkdf_test(const char *shash, const struct hkdf_testvec *tv)
> -{	struct crypto_shash *tfm = NULL;
> +{
> +	/* Skip the tests with keys too short in FIPS mode */
> +	if (fips_enabled && (tv->salt_size < 112 / 8))
> +		return 0;
> +

As I've explained before, in HKDF the secret is in the input keying
material, not the salt.

What problem are you trying to solve?

- Eric

  reply	other threads:[~2025-12-09 22:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-05 11:31 [PATCH RFC] crypto/hkdf: Skip tests with keys too short in FIPS mode Li Tian
2025-12-09 22:54 ` Eric Biggers [this message]
2025-12-17  0:08   ` Li Tian
2025-12-17  4:13     ` 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=20251209225401.GA54030@quark \
    --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=litian@redhat.com \
    --cc=vkuznets@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;
as well as URLs for NNTP newsgroup(s).