From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796290419; b=xHSr9i/6w7LqTUdYwIKGg9zR0LOSmuVCxfTPw2eQcQN+VOUBaGnAgIXVzDxAieZb9kx4 NUv9+qgjh0HNCycLZVPHUVX7NhGh4oXGT97Fpv6T5cyEtdgcGUrT+9tUjQS7TmUN1RnP8 0AWSZCU7lBM1Q5fXVPVdcJ/OkpB4ysUDpPkSE/o79+Mju8Czvuk31bUB5N2x5+HKCyUgU o8TsXckHFwsH+NleszvWt4Sv/WQVRhzqJEV3PTspsf5KW3twxhU73f3bpo9ku6X8DkQS9 k/KMTx4S/Wiv5HbM42HeLrsybmN17tzpCtKbBLYuI0IfXtH+mSdVEeE6cNUxwo7o6wQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796290419; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=gTPAIUZ4Wil5yICDBeLfQsMIZa2TrKJPIH5ySiffKSE=; b=r0OFwdEBDONM+dg4IgYEDRI3V3mJdcXX/7HrIrM4fLV8zj/f369yWugMT9/l4r67ofuU 6vuoTERnLyWKSpIkAQ8IQAs75Ed0m5HAU8sNevdSkNizz5llfoGBK4eW1U6FfWVI14KKy RG7NiQ4OsA3vNQv7Sgz/utmB9XapkXM7o7gccVqgcuoSd3stZcvuHe8c+zeFboAwOaZUg r2IztA6uuxqazFlMZgc8ttMxJnRgj6p/bmE05hQMwfJgsOsxSI+4oCvuUFOtAsVLvbYl6 vXXYDML3dCJxLzErxGJqgALCgoHr5FO9xeLwlt+EFX3wF26cOTC0aUZIG3O2999q11g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cCsQ+3sQ; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A2B0606A68E for ; Thu, 3 Dec 2026 09:33:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3A2B0606A68E 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.a=rsa-sha256 header.s=mimecast20190719 header.b=cCsQ+3sQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796290419; 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: in-reply-to:in-reply-to:references:references; bh=gTPAIUZ4Wil5yICDBeLfQsMIZa2TrKJPIH5ySiffKSE=; b=cCsQ+3sQRoI8t08O+mSByKvBA4LJ+OkKsaXwhw3wZ0MQgcE2oaGRWG249UDnkuc5NcwSVp Lf05uhpZpIbuOlWNJY5eMgUD0IZQjeOvkNMPysepRsoGZHxeUCR7jp3qErNfT1ldA8s8L0 +Uf2UVfn6pmnbi9QCIo2j7RDSpF96Ak= 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-658-M0ULFcI9MomZJwWQ6h2skQ-1; Thu, 3 Dec 2026 09:33:32 +0000 X-MC-Unique: M0ULFcI9MomZJwWQ6h2skQ-1 X-Mimecast-MFC-AGG-ID: M0ULFcI9MomZJwWQ6h2skQ_1796290411 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 C37B1191DADD; Thu, 3 Dec 2026 09:33:30 +0000 (UTC) Received: from thuth-p1g4.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C657EB89; Thu, 3 Dec 2026 09:33:28 +0000 (UTC) From: Thomas Huth To: Herbert Xu , linux-crypto@vger.kernel.org Cc: "David S. Miller" , Eric Biggers , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 4/4] crypto: fips - Add back the lost key length check to the hmac(sha512) algorithm Date: Thu, 3 Dec 2026 10:33:16 +0100 Message-ID: <20261203093316.97847-5-thuth@redhat.com> In-Reply-To: <20261203093316.97847-1-thuth@redhat.com> References: <20261203093316.97847-1-thuth@redhat.com> X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 The generic code in hmac_setkey() in crypto/hmac.c rejects keys with less than 112 bits in FIPS-compliance mode. However, this check got lost when the hmac(sha384) and hmac(sha512) algorithms were implemented via the crypto library. Let's restore the same behavior from kernel v6.16 and earlier by adding the key length check to the crypto/sha512.c file, too. Cc: stable@vger.kernel.org # 6.19+, see https://lore.kernel.org/all/20261201202148.GA501764@google.com/ Fixes: 469acaa12502e ("crypto: sha512 - Replace sha512_generic with wrapper around SHA-512 library") Signed-off-by: Thomas Huth --- crypto/sha512.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crypto/sha512.c b/crypto/sha512.c index d320fe53913fa..4551f4bd31830 100644 --- a/crypto/sha512.c +++ b/crypto/sha512.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include @@ -193,6 +194,9 @@ static int crypto_sha512_import_core(struct shash_desc *desc, const void *in) static int crypto_hmac_sha384_setkey(struct crypto_shash *tfm, const u8 *raw_key, unsigned int keylen) { + if (fips_hmac_keylen_disallowed(keylen)) + return -EINVAL; + hmac_sha384_preparekey(HMAC_SHA384_KEY(tfm), raw_key, keylen); return 0; } @@ -260,6 +264,9 @@ static int crypto_hmac_sha384_import_core(struct shash_desc *desc, static int crypto_hmac_sha512_setkey(struct crypto_shash *tfm, const u8 *raw_key, unsigned int keylen) { + if (fips_hmac_keylen_disallowed(keylen)) + return -EINVAL; + hmac_sha512_preparekey(HMAC_SHA512_KEY(tfm), raw_key, keylen); return 0; } -- 2.56.1