From: Stephan Müller Date: Sun, 21 Nov 2021 14:51:44 +0000 (+0100) Subject: crypto: dh - limit key size to 2048 in FIPS mode X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1e146c393b152a31771b49af5d104d9ed846da9b;p=linux.git crypto: dh - limit key size to 2048 in FIPS mode FIPS disallows DH with keys < 2048 bits. Thus, the kernel should consider the enforcement of this limit. Signed-off-by: Stephan Mueller Signed-off-by: Herbert Xu --- diff --git a/crypto/dh.c b/crypto/dh.c index cd4f32092e5ce..38557e64b4b31 100644 --- a/crypto/dh.c +++ b/crypto/dh.c @@ -5,6 +5,7 @@ * Authors: Salvatore Benedetto */ +#include #include #include #include @@ -47,6 +48,9 @@ static inline struct dh_ctx *dh_get_ctx(struct crypto_kpp *tfm) 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; }