Blob Blame History Raw
From: =?UTF-8?q?Stephan=20M=C3=BCller?= <smueller@chronox.de>
Date: Sun, 21 Nov 2021 15:51:44 +0100
Subject: crypto: dh - limit key size to 2048 in FIPS mode
Patch-mainline: v5.17-rc1
Git-commit: 1e146c393b152a31771b49af5d104d9ed846da9b
References: jsc#SLE-21132,bsc#1193136

FIPS disallows DH with keys < 2048 bits. Thus, the kernel should
consider the enforcement of this limit.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Nicolai Stange <nstange@suse.de>
---
 crypto/dh.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/crypto/dh.c
+++ b/crypto/dh.c
@@ -5,6 +5,7 @@
  * Authors: Salvatore Benedetto <salvatore.benedetto@intel.com>
  */
 
+#include <linux/fips.h>
 #include <linux/module.h>
 #include <crypto/internal/kpp.h>
 #include <crypto/kpp.h>
@@ -47,6 +48,9 @@ static inline struct dh_ctx *dh_get_ctx(
 
 static int dh_check_params_length(unsigned int p_len)
 {
+	if (fips_enabled)
+		return (p_len < 2048) ? -EINVAL : 0;
+
 	return (p_len < 1536) ? -EINVAL : 0;
 }