1 From 3c7b86229f7bd2600d74db14b1fe5b3896be3875 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
3 Date: Fri, 6 Apr 2018 14:27:18 +0200
4 Subject: [PATCH] pppd: Use openssl for the DES instead of the libcrypt / glibc
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 It seems the latest glibc (in Fedora glibc-2.27.9000-12.fc29) dropped
10 libcrypt. The libxcrypt standalone package can be used instead, but
11 it dropped the old setkey/encrypt API which ppp uses for DES. There
12 is support for using openssl in pppcrypt.c, but it contains typos
13 preventing it from compiling and seems to be written for an ancient
16 This updates the code to use current openssl.
18 [paulus@ozlabs.org - wrote the commit description, fixed comment in
21 Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
22 Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
24 pppd/Makefile.linux | 7 ++++---
25 pppd/pppcrypt.c | 18 +++++++++---------
26 2 files changed, 13 insertions(+), 12 deletions(-)
28 diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
29 index 36d2b036..8d5ce99d 100644
30 --- a/pppd/Makefile.linux
31 +++ b/pppd/Makefile.linux
32 @@ -35,10 +35,10 @@ endif
33 COPTS = -O2 -pipe -Wall -g
36 -# Uncomment the next 2 lines to include support for Microsoft's
37 +# Uncomment the next line to include support for Microsoft's
38 # MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux.
42 # Don't use MSLANMAN unless you really know what you're doing.
44 # Uncomment the next line to include support for MPPE. CHAPMS (above) must
45 @@ -137,7 +137,8 @@ endif
49 -LIBS += -ldes $(LIBS)
50 +CFLAGS += -I/usr/include/openssl
53 CFLAGS += -DUSE_CRYPT=1
55 diff --git a/pppd/pppcrypt.c b/pppd/pppcrypt.c
56 index 8b85b132..6b35375e 100644
59 @@ -64,7 +64,7 @@ u_char *des_key; /* OUT 64 bit DES key with parity bits added */
60 des_key[7] = Get7Bits(key, 49);
63 - des_set_odd_parity((des_cblock *)des_key);
64 + DES_set_odd_parity((DES_cblock *)des_key);
68 @@ -158,25 +158,25 @@ u_char *clear; /* OUT 8 octets */
72 -static des_key_schedule key_schedule;
73 +static DES_key_schedule key_schedule;
81 MakeKey(key, des_key);
82 - des_set_key(&des_key, key_schedule);
83 + DES_set_key(&des_key, &key_schedule);
88 -DesEncrypt(clear, key, cipher)
89 +DesEncrypt(clear, cipher)
90 u_char *clear; /* IN 8 octets */
91 u_char *cipher; /* OUT 8 octets */
93 - des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher,
95 + DES_ecb_encrypt((DES_cblock *)clear, (DES_cblock *)cipher,
100 @@ -185,8 +185,8 @@ DesDecrypt(cipher, clear)
101 u_char *cipher; /* IN 8 octets */
102 u_char *clear; /* OUT 8 octets */
104 - des_ecb_encrypt((des_cblock *)cipher, (des_cblock *)clear,
106 + DES_ecb_encrypt((DES_cblock *)cipher, (DES_cblock *)clear,