From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0729331280A for ; Fri, 5 Dec 2025 11:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764934311; cv=none; b=h4Fsza6fD5Uieu9buc7TNhPB0tgnLhVIj2tc4HcCTZw9zh3Xg4V92w33i2+kdkEox2oaksXXp9pHZpbEucfunRSNaAtqBJEYcRpbAUB/NiTzwteINEI4ryUdNnpgmcD4iS5EvFecnsdL5D6EI0NKEDQBgA4OGKdmSgNCMxN228g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764934311; c=relaxed/simple; bh=SZtJGFF8P2hFOr3YJFW6U79eM6LhNi8nW08d2n1GOlQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iBl60bWcIFJw0RttismRgiR4cHOaZkC1OnZH3ZngO2heNWyis3gKuEPax1kSDfbH5G2UiQHKJuT7xm3dTrXmmvP+ZNECSqjj8Jsh5rjv73oLBAgKKw5PtNAFzh+dzw/m8fh6DoD7x7NCSQIzAgqGb7u2YW70gZn1SxzWoK8tlMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=f6q0GXVP; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f6q0GXVP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764934307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oG/VqOSGdc08oA76xA7Nvg0WSnERV4bv7fXit1XbI2I=; b=f6q0GXVPCB3MXoxIe4U5UlGa+35aoVB2i51Lfn4zk5kyVa00fS7fIb2Ixu1NQswaxzjTV0 IdfgTrmn/uep61xnR/Qbr05K/4lrkAd4/BaXdThUUW0YmCFCwbL73dMMiSq8V3tATQ7oxA TzhyPHDl1v4icJt5Yg2tonwmOZj+K+s= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-457-kj2ofKYZPh6H-eSRtVN0ZA-1; Fri, 05 Dec 2025 06:31:45 -0500 X-MC-Unique: kj2ofKYZPh6H-eSRtVN0ZA-1 X-Mimecast-MFC-AGG-ID: kj2ofKYZPh6H-eSRtVN0ZA_1764934304 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 48840195608F; Fri, 5 Dec 2025 11:31:44 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.72.112.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C37721800357; Fri, 5 Dec 2025 11:31:39 +0000 (UTC) From: Li Tian To: linux-kernel@vger.kernel.org Cc: linux-crypto@vger.kernel.org, Herbert Xu , Eric Biggers , "David S . Miller" , Vitaly Kuznetsov Subject: [PATCH RFC] crypto/hkdf: Skip tests with keys too short in FIPS mode Date: Fri, 5 Dec 2025 19:31:36 +0800 Message-ID: <20251205113136.17920-1-litian@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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 --- 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 #include #include +#include #include /* @@ -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