aboutsummaryrefslogtreecommitdiff
path: root/crypt/cert.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2018-06-29 16:53:18 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-06-29 16:53:18 +0200
commitb10a0accee709a5efff2fadf0b0bbb79ff0ad759 (patch)
tree27796fe83ec5f82a8f36a36afa169fe6dddf8b27 /crypt/cert.c
parent524d796d5f52913d5d33edede74a5075dbda25ca (diff)
downloadglibc-b10a0accee709a5efff2fadf0b0bbb79ff0ad759.tar
glibc-b10a0accee709a5efff2fadf0b0bbb79ff0ad759.tar.gz
glibc-b10a0accee709a5efff2fadf0b0bbb79ff0ad759.tar.bz2
glibc-b10a0accee709a5efff2fadf0b0bbb79ff0ad759.zip
Disallow use of DES encryption functions in new programs.
The functions encrypt, setkey, encrypt_r, setkey_r, cbc_crypt, ecb_crypt, and des_setparity should not be used in new programs, because they use the DES block cipher, which is unacceptably weak by modern standards. Demote all of them to compatibility symbols, and remove their prototypes from installed headers. cbc_crypt, ecb_crypt, and des_setparity were already compat symbols when glibc was configured with --disable-obsolete-rpc. POSIX requires encrypt and setkey to be available when _XOPEN_CRYPT is defined, so this change also removes the definition of X_OPEN_CRYPT from <unistd.h>. The entire "DES Encryption" section is dropped from the manual, as is the mention of AUTH_DES and FIPS 140-2 in the introduction to crypt.texi. The documentation of 'memfrob' cross-referenced the DES Encryption section, which is replaced by a hyperlink to libgcrypt, and while I was in there I spruced up the actual documentation of 'memfrob' and 'strfry' a little. It's still fairly jokey, because those functions _are_ jokes, but they do also have real use cases, so people trying to use them for real should have all the information they need. DES-based authentication for Sun RPC is also insecure and should be deprecated or even removed, but maybe that can be left as TI-RPC's problem.
Diffstat (limited to 'crypt/cert.c')
-rw-r--r--crypt/cert.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/crypt/cert.c b/crypt/cert.c
index 80029e9078..e070ca398d 100644
--- a/crypt/cert.c
+++ b/crypt/cert.c
@@ -10,6 +10,22 @@
#include <stdlib.h>
#include "crypt.h"
+/* This file tests the deprecated setkey/encrypt interface. */
+#include <shlib-compat.h>
+#if TEST_COMPAT (libcrypt, GLIBC_2_0, GLIBC_2_28)
+
+#define libcrypt_version_reference(symbol, version) \
+ _libcrypt_version_reference (symbol, VERSION_libcrypt_##version)
+#define _libcrypt_version_reference(symbol, version) \
+ __libcrypt_version_reference (symbol, version)
+#define __libcrypt_version_reference(symbol, version) \
+ __asm__ (".symver " #symbol ", " #symbol "@" #version)
+
+extern void setkey (const char *);
+extern void encrypt (const char *, int);
+libcrypt_version_reference (setkey, GLIBC_2_0);
+libcrypt_version_reference (encrypt, GLIBC_2_0);
+
int totfails = 0;
int main (int argc, char *argv[]);
@@ -104,3 +120,13 @@ put8 (char *cp)
printf("%02x", t);
}
}
+
+#else /* encrypt and setkey are not available. */
+
+int
+main (void)
+{
+ return 77; /* UNSUPPORTED */
+}
+
+#endif