From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796150854; b=Vv0dAFr3gU6zeHCqJDxfsskU7Aq5ZWougxgvdolHLoRJhYfmgIuyCujI1l5qZM3+eHua Tb09sFbLwIRFkXVOpc/4d7F2/g6SzSzVLVSY+WHCg7VqRCGwfOG1SotV7qEjRp5gzC8sS 1S7P2EEN9WwbjJoa4iSLGPyW4NqkUDvr5qJicnZYZ+hMSqV4sfavZ+AwGE5htaNwrvaPx HOlOCtrBd4QpPd9EyTcWT+hvq0rgfsoGdBsqvnfdiDydqlisP1NNnDauqxiZWMCpDmELh uBLxq8kWNj6/M2CwVeeI0RbEcZTt271q71NkqclyCm9rxUp4EfQFKvb6o3S89fKipAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796150854; 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=yVror+gIj/kvAwSQ8YD+vBtaQwBBpAfTDL2PRv1x/lc=; b=DuSl6cxw7NpqWojw2S6VOgUD8C7YN/B3FiO+eFWzajGHprgpTtEuzkHTjDB4msRrFAW2 JSYk0ElgwcLEOCVWKhx5yhuelUTMxNZp9QIe1EKJ1jAJhfN+XRU9ze1xZiP0feYGd24Ro fO7sOGs5N33qfvPMSslpGoNCaNItmljaKtt+7mOUZjwSwIWyJWmzWQgmhLjCXUiCezrMy wcJJY3eMzQgaSEM5XWutoYPEYAvoFMUc4WpaWWruihLzGHU4/f3ZY2qbwR3uhdtSt79bd ODr6aG4eTIoN+jaNBdKrfYqPL5TQzuMhyHYaw0FXTn59kLat2OaJO6iGLqazpKHXqQg== 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=iUDKDSUu; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 A0B0A606A320 for ; Tue, 1 Dec 2026 18:47:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A0B0A606A320 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=iUDKDSUu DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796150853; 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=yVror+gIj/kvAwSQ8YD+vBtaQwBBpAfTDL2PRv1x/lc=; b=iUDKDSUuXjMhyZrmAhppVrSJjHEH9ZK4MMUm1M4+l+dhoQXYkXmjWwxTW0CU5VseKbIVzk GmiE63dPwlZQs970kDR7BJI0PBn69UEGqgyit6EaoBTIcINhz1uploIJGC1PfbY3DYQ/cs NfHJmC4qR5+foVHH1EL5tABmJK074ak= Received: from mx-prod-mc-05.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-261-xEl7HZUFMUWJooXpQvxl2w-1; Tue, 1 Dec 2026 18:47:29 +0000 X-MC-Unique: xEl7HZUFMUWJooXpQvxl2w-1 X-Mimecast-MFC-AGG-ID: xEl7HZUFMUWJooXpQvxl2w_1796150848 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 21ED01933FBB; Tue, 1 Dec 2026 18:47:28 +0000 (UTC) Received: from thuth-p1g4.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4A18A1955BD4; Tue, 1 Dec 2026 18:47:26 +0000 (UTC) From: Thomas Huth To: Herbert Xu , linux-crypto@vger.kernel.org Cc: "David S. Miller" , Eric Biggers , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] crypto: Add a wrapper function for checking the HMAC key length in FIPS mode Date: Tue, 1 Dec 2026 19:47:19 +0100 Message-ID: <20261201184722.887139-2-thuth@redhat.com> In-Reply-To: <20261201184722.887139-1-thuth@redhat.com> References: <20261201184722.887139-1-thuth@redhat.com> X-Mailing-List: linux-kernel@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.0 on 10.30.177.12 We are going to need this check in multiple locations. To avoid that we have to update each location in the future in case of changes in the FIPS requirements, let's introduce a proper wrapper function for this check first. Signed-off-by: Thomas Huth --- crypto/hmac.c | 2 +- include/linux/fips.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crypto/hmac.c b/crypto/hmac.c index 807e08b252c55..53ed48deb4b5a 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -246,7 +246,7 @@ static int hmac_setkey_ahash(struct crypto_ahash *parent, u8 *ipad = &tctx->pads[0]; int err, i; - if (fips_enabled && (keylen < 112 / 8)) + if (fips_hmac_keylen_disallowed(keylen)) return -EINVAL; ahash_request_set_callback(req, 0, NULL, NULL); diff --git a/include/linux/fips.h b/include/linux/fips.h index c6961e932fef3..75b9ed6ec49be 100644 --- a/include/linux/fips.h +++ b/include/linux/fips.h @@ -2,17 +2,26 @@ #ifndef _FIPS_H #define _FIPS_H +#include + #ifdef CONFIG_CRYPTO_FIPS extern int fips_enabled; extern struct atomic_notifier_head fips_fail_notif_chain; void fips_fail_notify(void); +static inline bool fips_hmac_keylen_disallowed(unsigned int keylen) +{ + return fips_enabled && keylen < 112 / 8; +} + #else #define fips_enabled 0 static inline void fips_fail_notify(void) {} +#define fips_hmac_keylen_disallowed(x) false + #endif #endif -- 2.56.1