Repository navigation
Expand file tree
/
Copy pathvim-crypto-warning.patch
More file actions
86 lines (82 loc) · 2.89 KB
/
Copy pathvim-crypto-warning.patch
File metadata and controls
86 lines (82 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
diff -up vim-9.0.1614/src/config.h.in.10~ vim-9.0.1614/src/config.h.in
--- vim-9.0.1614/src/config.h.in.10~ 2023-06-06 16:59:59.000000000 +0200
+++ vim-9.0.1614/src/config.h.in 2023-06-07 15:53:18.248793994 +0200
@@ -495,6 +495,15 @@
/* Define to inline symbol or empty */
#undef inline
+/* Do we need FIPS warning? */
+#undef HAVE_FIPS_WARNING
+
+/* Link to system-fips file */
+#undef SYSTEM_FIPS_FILE_LINK
+
+/* Link to fips_enabled file */
+#undef FIPS_ENABLED_FILE_LINK
+
/* Define if _SC_SIGSTKSZ is available via sysconf() */
#undef HAVE_SYSCONF_SIGSTKSZ
diff -up vim-9.0.1614/src/configure.ac.10~ vim-9.0.1614/src/configure.ac
--- vim-9.0.1614/src/configure.ac.10~ 2023-06-06 16:59:59.000000000 +0200
+++ vim-9.0.1614/src/configure.ac 2023-06-07 15:53:18.249794002 +0200
@@ -589,6 +589,38 @@ else
AC_SUBST(XDIFF_OBJS_USED)
fi
+dnl Checking if we want FIPS warning
+
+AC_MSG_CHECKING(--enable-fips-warning)
+AC_ARG_ENABLE([fips-warning],
+ AS_HELP_STRING([--enable-fips-warning], [Enable FIPS warning]),
+ ,[enable_fips_warning="no"])
+
+if test "$enable_fips_warning" = "yes"; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_FIPS_WARNING])
+
+ dnl Setting path for system-fips file
+
+ AC_MSG_CHECKING(--with-system-fips-file argument)
+ AC_ARG_WITH([system-fips-file], [ --with-system-fips-file=PATH Link to system-fips file (default: /etc/system-fips)],
+ with_system_fips_file=$withval,
+ with_system_fips_file="/etc/system-fips")
+ AC_MSG_RESULT([$with_system_fips_file])
+ AC_DEFINE_UNQUOTED([SYSTEM_FIPS_FILE_LINK], ["$with_system_fips_file"])
+
+ dnl Setting link to fips_enabled file
+
+ AC_MSG_CHECKING(--with-fips-enabled-file argument)
+ AC_ARG_WITH([fips-enabled-file], [ --with-fips-enabled-file=PATH Link to fibs_enabled file (default: /proc/sys/crypto/fips_enabled)],
+ with_fips_enabled_file=$withval,
+ with_fips_enabled_file="/proc/sys/crypto/fips_enabled")
+ AC_MSG_RESULT([$with_fips_enabled_file])
+ AC_DEFINE_UNQUOTED([FIPS_ENABLED_FILE_LINK], ["$with_fips_enabled_file"])
+else
+ AC_MSG_RESULT(no)
+fi
+
dnl Check for Lua feature.
AC_MSG_CHECKING(--enable-luainterp argument)
AC_ARG_ENABLE(luainterp,
diff -up vim-9.0.1614/src/crypt.c.10~ vim-9.0.1614/src/crypt.c
--- vim-9.0.1614/src/crypt.c.10~ 2023-06-07 15:53:18.249794002 +0200
+++ vim-9.0.1614/src/crypt.c 2023-06-07 15:54:58.755655772 +0200
@@ -795,6 +795,21 @@ crypt_check_method(int method)
msg_scroll = TRUE;
msg(_("Warning: Using a weak encryption method; see :help 'cm'"));
}
+#ifdef HAVE_FIPS_WARNING
+ FILE *fips_enable_fd = fopen(FIPS_ENABLED_FILE_LINK, "r");
+ if (fips_enable_fd == NULL)
+ return;
+
+ int enabled = fgetc(fips_enable_fd);
+
+ if ( access(SYSTEM_FIPS_FILE_LINK, F_OK) != -1 && enabled == '1')
+ {
+ msg_scroll = TRUE;
+ msg(_("Warning: This cryptography is not FIPS 140-2 compliant."));
+ }
+
+ fclose(fips_enable_fd);
+#endif
}
/*