* [PATCH RFC] crypto/hkdf: Skip tests with keys too short in FIPS mode
@ 2025-12-05 11:31 Li Tian
2025-12-09 22:54 ` Eric Biggers
0 siblings, 1 reply; 4+ messages in thread
From: Li Tian @ 2025-12-05 11:31 UTC (permalink / raw)
To: linux-kernel
Cc: linux-crypto, Herbert Xu, Eric Biggers, David S . Miller,
Vitaly Kuznetsov
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;
+
+ struct crypto_shash *tfm = NULL;
u8 *prk = NULL, *okm = NULL;
unsigned int prk_size;
const char *driver;
--
2.50.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] crypto/hkdf: Skip tests with keys too short in FIPS mode
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
2025-12-17 0:08 ` Li Tian
0 siblings, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2025-12-09 22:54 UTC (permalink / raw)
To: Li Tian
Cc: linux-kernel, linux-crypto, Herbert Xu, David S . Miller,
Vitaly Kuznetsov
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] crypto/hkdf: Skip tests with keys too short in FIPS mode
2025-12-09 22:54 ` Eric Biggers
@ 2025-12-17 0:08 ` Li Tian
2025-12-17 4:13 ` Eric Biggers
0 siblings, 1 reply; 4+ messages in thread
From: Li Tian @ 2025-12-17 0:08 UTC (permalink / raw)
To: Eric Biggers
Cc: linux-kernel, linux-crypto, Herbert Xu, David S . Miller,
Vitaly Kuznetsov, Simo Sorce
On Wed, Dec 10, 2025 at 6:54 AM Eric Biggers <ebiggers@kernel.org> wrote:
> What problem are you trying to solve?
Eric, as you've said "keylen < 14 check in the new version in
crypto/sha256.c." was forgotten.
IMHO, it deserves recovery in terms of FIPS. And by the time the check
is restored, the hkdf_test
cases failure will likely surface again. Hence the skipping in this proposal.
Li Tian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFC] crypto/hkdf: Skip tests with keys too short in FIPS mode
2025-12-17 0:08 ` Li Tian
@ 2025-12-17 4:13 ` Eric Biggers
0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2025-12-17 4:13 UTC (permalink / raw)
To: Li Tian
Cc: linux-kernel, linux-crypto, Herbert Xu, David S . Miller,
Vitaly Kuznetsov, Simo Sorce
On Wed, Dec 17, 2025 at 08:08:48AM +0800, Li Tian wrote:
> On Wed, Dec 10, 2025 at 6:54 AM Eric Biggers <ebiggers@kernel.org> wrote:
> > What problem are you trying to solve?
>
> Eric, as you've said "keylen < 14 check in the new version in
> crypto/sha256.c." was forgotten.
> IMHO, it deserves recovery in terms of FIPS. And by the time the check
> is restored, the hkdf_test
> cases failure will likely surface again. Hence the skipping in this proposal.
>
> Li Tian
Sure, but there's no reason to consider this patch unless the incorrect
and problematic keylen check is added back in.
- Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-17 4:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-12-17 0:08 ` Li Tian
2025-12-17 4:13 ` Eric Biggers
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).