da4393
diff -up vim82/src/config.h.in.fips-warning vim82/src/config.h.in
da4393
--- vim82/src/config.h.in.fips-warning	2021-03-01 12:20:20.887162181 +0100
da4393
+++ vim82/src/config.h.in	2021-03-01 12:20:42.520977438 +0100
da4393
@@ -499,3 +499,12 @@
da4393
 
da4393
 /* Define if _SC_SIGSTKSZ is available via sysconf() */
da4393
 #undef HAVE_SYSCONF_SIGSTKSZ
da4393
+
da4393
+/* Do we need FIPS warning? */
da4393
+#undef HAVE_FIPS_WARNING
da4393
+
da4393
+/* Link to system-fips file */
da4393
+#undef SYSTEM_FIPS_FILE_LINK
da4393
+
da4393
+/* Link to fips_enabled file */
da4393
+#undef FIPS_ENABLED_FILE_LINK
da4393
diff -up vim82/src/configure.ac.fips-warning vim82/src/configure.ac
da4393
--- vim82/src/configure.ac.fips-warning	2021-03-01 12:20:20.885162198 +0100
da4393
+++ vim82/src/configure.ac	2021-03-01 12:20:20.888162173 +0100
da4393
@@ -541,6 +541,38 @@ else
da4393
   AC_MSG_RESULT(yes)
da4393
 fi
da4393
 
da4393
+dnl Checking if we want FIPS warning
da4393
+
da4393
+AC_MSG_CHECKING(--enable-fips-warning)
da4393
+AC_ARG_ENABLE([fips-warning],
da4393
+              AS_HELP_STRING([--enable-fips-warning], [Enable FIPS warning]),
da4393
+              ,[enable_fips_warning="no"])
da4393
+
da4393
+if test "$enable_fips_warning" = "yes"; then
da4393
+  AC_MSG_RESULT(yes)
da4393
+  AC_DEFINE([HAVE_FIPS_WARNING])
da4393
+
da4393
+  dnl Setting path for system-fips file
da4393
+
da4393
+  AC_MSG_CHECKING(--with-system-fips-file argument)
da4393
+  AC_ARG_WITH([system-fips-file], [  --with-system-fips-file=PATH       Link to system-fips file (default: /etc/system-fips)],
da4393
+	with_system_fips_file=$withval,
da4393
+       with_system_fips_file="/etc/system-fips")
da4393
+  AC_MSG_RESULT([$with_system_fips_file])
da4393
+  AC_DEFINE_UNQUOTED([SYSTEM_FIPS_FILE_LINK], ["$with_system_fips_file"])
da4393
+
da4393
+  dnl Setting link to fips_enabled file
da4393
+
da4393
+  AC_MSG_CHECKING(--with-fips-enabled-file argument)
da4393
+  AC_ARG_WITH([fips-enabled-file], [  --with-fips-enabled-file=PATH       Link to fibs_enabled file (default: /proc/sys/crypto/fips_enabled)],
da4393
+	with_fips_enabled_file=$withval,
da4393
+       with_fips_enabled_file="/proc/sys/crypto/fips_enabled")
da4393
+  AC_MSG_RESULT([$with_fips_enabled_file])
da4393
+  AC_DEFINE_UNQUOTED([FIPS_ENABLED_FILE_LINK], ["$with_fips_enabled_file"])
da4393
+else
da4393
+  AC_MSG_RESULT(no)
da4393
+fi
da4393
+
da4393
 dnl Check for Lua feature.
da4393
 AC_MSG_CHECKING(--enable-luainterp argument)
da4393
 AC_ARG_ENABLE(luainterp,
da4393
diff -up vim82/src/crypt.c.fips-warning vim82/src/crypt.c
da4393
--- vim82/src/crypt.c.fips-warning	2021-03-01 12:13:11.000000000 +0100
da4393
+++ vim82/src/crypt.c	2021-03-01 12:20:20.888162173 +0100
da4393
@@ -523,6 +523,21 @@ crypt_check_method(int method)
da4393
 	msg_scroll = TRUE;
da4393
 	msg(_("Warning: Using a weak encryption method; see :help 'cm'"));
da4393
     }
da4393
+#ifdef HAVE_FIPS_WARNING
da4393
+    FILE *fips_enable_fd = fopen(FIPS_ENABLED_FILE_LINK, "r");
da4393
+    if (fips_enable_fd == NULL)
da4393
+      return;
da4393
+
da4393
+    int enabled = fgetc(fips_enable_fd);
da4393
+
da4393
+    if ( access(SYSTEM_FIPS_FILE_LINK, F_OK) != -1 && enabled == '1')
da4393
+    {
da4393
+	msg_scroll = TRUE;
da4393
+	msg(_("Warning: This cryptography is not FIPS 140-2 compliant."));
da4393
+    }
da4393
+
da4393
+    fclose(fips_enable_fd);
da4393
+#endif
da4393
 }
da4393
 
da4393
     void