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=1796150855; b=NGlJh8T6rFTaYhnU0tcYK8vt0hlzvUGavOroMNdNwSUIRIUWotAacUXFSZpoc1nm8cJG oU/lREYAMjT3VJycqvEh0lKOzTbUEngHWVaRzBvg4CXApR/6y3UH97+jR8pjuUJhAKRtk nt8ZMC8uu+03Hynf+AUZ9ZX9TXf830w7zOqHvhRfzvZ22asF/nEZOxI5zxAPHjl7ZPhQr a+skwmhBy//qEARyY/78TK3loIMrifq0ANC15C5srs7JICR0D51EkoczV22llkuZiYle0 eYm6pbIv3+U/n523IZ9hQAtKjXG3ajMvVDWnxHRnuRn9iU55tMUa4Pexs9enDnjfDFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796150855; 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=u5VxtlGLk9CgCJ9VyGJjnxGIsPgav6+xRjd7yE6zrhqtm6Cwo8XiCBabQsyx2rS2wXFg h++OgpLirqy1BtK14/QiDWW2EX9j1B9P1Tpojp2dB1wNHgtve7ZxmuhSrvdpS+J09yz4G NNCI+H2uqV2RS53wL+BztOwPQ238o9RVXqF+ktGNU1tlid9a4Ebbduo8wUtJ4Bdmi039K N9GGEMAl4Wr2mKGHheORm0KuVsSG7NIsIP4kKgsME6MwZP60U0wgGZdtqCBy/Uy8qrW7V 8Fkh4Wf9iaBkOMQKY+v6N5O3/hitZYPwHe3SUTySdJvQv2eSKWJ8uQkOA+GgPfTwEZg== 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=e01kJ478; 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 83C35606A32A for ; Tue, 1 Dec 2026 18:47:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 83C35606A32A 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=e01kJ478 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796150854; 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=e01kJ478sdI1BnnBEsx6p9vxAXCKo0WzNsn3BLtgB+7E14ee/VWqWaRZ181pEg5DeUnP/U Gv3vGVE/1M+NP4dzJIp32/I8T8E4x8HkZzom3f1VNSkw8I1v3r0/CJH412HblHCgfg8QVL p6bjKcCN3mvYayOss4GhvpZFfb91BaU= 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-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.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