]>
Commit | Line | Data |
---|---|---|
e28e813e MT |
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 | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
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 | |
14 | openssl version. | |
15 | ||
16 | This updates the code to use current openssl. | |
17 | ||
18 | [paulus@ozlabs.org - wrote the commit description, fixed comment in | |
19 | Makefile.linux.] | |
20 | ||
21 | Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com> | |
22 | Signed-off-by: Paul Mackerras <paulus@ozlabs.org> | |
23 | --- | |
24 | pppd/Makefile.linux | 7 ++++--- | |
25 | pppd/pppcrypt.c | 18 +++++++++--------- | |
26 | 2 files changed, 13 insertions(+), 12 deletions(-) | |
27 | ||
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 | |
34 | LIBS = | |
35 | ||
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. | |
39 | CHAPMS=y | |
40 | -USE_CRYPT=y | |
41 | +#USE_CRYPT=y | |
42 | # Don't use MSLANMAN unless you really know what you're doing. | |
43 | #MSLANMAN=y | |
44 | # Uncomment the next line to include support for MPPE. CHAPMS (above) must | |
45 | @@ -137,7 +137,8 @@ endif | |
46 | ||
47 | ifdef NEEDDES | |
48 | ifndef USE_CRYPT | |
49 | -LIBS += -ldes $(LIBS) | |
50 | +CFLAGS += -I/usr/include/openssl | |
51 | +LIBS += -lcrypto | |
52 | else | |
53 | CFLAGS += -DUSE_CRYPT=1 | |
54 | endif | |
55 | diff --git a/pppd/pppcrypt.c b/pppd/pppcrypt.c | |
56 | index 8b85b132..6b35375e 100644 | |
57 | --- a/pppd/pppcrypt.c | |
58 | +++ b/pppd/pppcrypt.c | |
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); | |
61 | ||
62 | #ifndef USE_CRYPT | |
63 | - des_set_odd_parity((des_cblock *)des_key); | |
64 | + DES_set_odd_parity((DES_cblock *)des_key); | |
65 | #endif | |
66 | } | |
67 | ||
68 | @@ -158,25 +158,25 @@ u_char *clear; /* OUT 8 octets */ | |
69 | } | |
70 | ||
71 | #else /* USE_CRYPT */ | |
72 | -static des_key_schedule key_schedule; | |
73 | +static DES_key_schedule key_schedule; | |
74 | ||
75 | bool | |
76 | DesSetkey(key) | |
77 | u_char *key; | |
78 | { | |
79 | - des_cblock des_key; | |
80 | + DES_cblock des_key; | |
81 | MakeKey(key, des_key); | |
82 | - des_set_key(&des_key, key_schedule); | |
83 | + DES_set_key(&des_key, &key_schedule); | |
84 | return (1); | |
85 | } | |
86 | ||
87 | bool | |
88 | -DesEncrypt(clear, key, cipher) | |
89 | +DesEncrypt(clear, cipher) | |
90 | u_char *clear; /* IN 8 octets */ | |
91 | u_char *cipher; /* OUT 8 octets */ | |
92 | { | |
93 | - des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher, | |
94 | - key_schedule, 1); | |
95 | + DES_ecb_encrypt((DES_cblock *)clear, (DES_cblock *)cipher, | |
96 | + &key_schedule, 1); | |
97 | return (1); | |
98 | } | |
99 | ||
100 | @@ -185,8 +185,8 @@ DesDecrypt(cipher, clear) | |
101 | u_char *cipher; /* IN 8 octets */ | |
102 | u_char *clear; /* OUT 8 octets */ | |
103 | { | |
104 | - des_ecb_encrypt((des_cblock *)cipher, (des_cblock *)clear, | |
105 | - key_schedule, 0); | |
106 | + DES_ecb_encrypt((DES_cblock *)cipher, (DES_cblock *)clear, | |
107 | + &key_schedule, 0); | |
108 | return (1); | |
109 | } | |
110 |