Lines 1-5
Link Here
|
1 |
--- tunip.c.orig Tue Sep 21 15:20:40 1999 |
1 |
--- tunip.c.orig 1999-09-21 22:20:40 UTC |
2 |
+++ tunip.c Thu Jul 20 04:26:39 2006 |
2 |
+++ tunip.c |
3 |
@@ -35,6 +35,8 @@ |
3 |
@@ -35,6 +35,8 @@ |
4 |
#include <unistd.h> |
4 |
#include <unistd.h> |
5 |
#include <fcntl.h> |
5 |
#include <fcntl.h> |
Lines 26-32
Link Here
|
26 |
#define _PATH_DEV_RANDOM "/dev/random" |
26 |
#define _PATH_DEV_RANDOM "/dev/random" |
27 |
|
27 |
|
28 |
#ifdef USE_ETHERTAP |
28 |
#ifdef USE_ETHERTAP |
29 |
@@ -100,6 +104,7 @@ |
29 |
@@ -100,6 +104,7 @@ struct ethtap_header ethtap; |
30 |
#endif |
30 |
#endif |
31 |
|
31 |
|
32 |
unsigned char buf[MAX_HEADER+MAX_PACKET]; |
32 |
unsigned char buf[MAX_HEADER+MAX_PACKET]; |
Lines 34-41
Link Here
|
34 |
|
34 |
|
35 |
typedef union { |
35 |
typedef union { |
36 |
MD5_CTX md5; |
36 |
MD5_CTX md5; |
37 |
@@ -131,7 +136,9 @@ |
37 |
@@ -124,14 +129,16 @@ typedef struct hash_method { |
38 |
des_key_schedule k3; |
38 |
|
|
|
39 |
typedef union { |
40 |
BF_KEY bf; |
41 |
- des_key_schedule des; |
42 |
+ DES_key_schedule des; |
43 |
struct { |
44 |
- des_key_schedule k1; |
45 |
- des_key_schedule k2; |
46 |
- des_key_schedule k3; |
47 |
+ DES_key_schedule k1; |
48 |
+ DES_key_schedule k2; |
49 |
+ DES_key_schedule k3; |
39 |
} des3; |
50 |
} des3; |
40 |
CAST_KEY cast; |
51 |
CAST_KEY cast; |
41 |
+#ifndef NO_IDEA |
52 |
+#ifndef NO_IDEA |
Lines 44-50
Link Here
|
44 |
} crypt_key; |
55 |
} crypt_key; |
45 |
|
56 |
|
46 |
typedef struct crypt_method { |
57 |
typedef struct crypt_method { |
47 |
@@ -304,12 +311,14 @@ |
58 |
@@ -304,12 +311,14 @@ void cast_cbc_encrypt(unsigned char *iv, |
48 |
void cast_cbc_decrypt(unsigned char *iv, crypt_key *dk, |
59 |
void cast_cbc_decrypt(unsigned char *iv, crypt_key *dk, |
49 |
unsigned char *ct, unsigned int len); |
60 |
unsigned char *ct, unsigned int len); |
50 |
int cast_setkey(unsigned char *b, unsigned int len, crypt_key *k); |
61 |
int cast_setkey(unsigned char *b, unsigned int len, crypt_key *k); |
Lines 59-65
Link Here
|
59 |
void my_des_cbc_encrypt(unsigned char *iv, crypt_key *ek, |
70 |
void my_des_cbc_encrypt(unsigned char *iv, crypt_key *ek, |
60 |
unsigned char *t, unsigned int len); |
71 |
unsigned char *t, unsigned int len); |
61 |
void my_des_cbc_decrypt(unsigned char *iv, crypt_key *dk, |
72 |
void my_des_cbc_decrypt(unsigned char *iv, crypt_key *dk, |
62 |
@@ -379,14 +388,20 @@ |
73 |
@@ -379,14 +388,20 @@ hash_method_t hash_ripemd160 = { |
63 |
|
74 |
|
64 |
hash_method_t *hash_list = &hash_ripemd160; |
75 |
hash_method_t *hash_list = &hash_ripemd160; |
65 |
|
76 |
|
Lines 80-86
Link Here
|
80 |
"cast_cbc", 8, 8, |
91 |
"cast_cbc", 8, 8, |
81 |
cast_cbc_encrypt, cast_cbc_decrypt, |
92 |
cast_cbc_encrypt, cast_cbc_decrypt, |
82 |
cast_setkey, cast_setkey |
93 |
cast_setkey, cast_setkey |
83 |
@@ -704,13 +719,22 @@ |
94 |
@@ -704,13 +719,22 @@ void tun_new(struct tun_method *this, |
84 |
*/ |
95 |
*/ |
85 |
int tun_send_ip(struct tun_method *this, struct encap_method *encap, int fd) |
96 |
int tun_send_ip(struct tun_method *this, struct encap_method *encap, int fd) |
86 |
{ |
97 |
{ |
Lines 104-110
Link Here
|
104 |
sent = write(fd, encap->buf, encap->buflen); |
115 |
sent = write(fd, encap->buf, encap->buflen); |
105 |
if (sent != encap->buflen) |
116 |
if (sent != encap->buflen) |
106 |
syslog(LOG_ERR, "truncated in: %d -> %d\n", encap->buflen, sent); |
117 |
syslog(LOG_ERR, "truncated in: %d -> %d\n", encap->buflen, sent); |
107 |
@@ -1120,6 +1144,7 @@ |
118 |
@@ -1120,6 +1144,7 @@ void config_read(FILE *cf) |
108 |
} |
119 |
} |
109 |
} else if (strcmp(arg, "if") == 0) { |
120 |
} else if (strcmp(arg, "if") == 0) { |
110 |
int fd; |
121 |
int fd; |
Lines 112-118
Link Here
|
112 |
struct sa_desc *local_sa, *remote_sa; |
123 |
struct sa_desc *local_sa, *remote_sa; |
113 |
struct peer_desc *peer; |
124 |
struct peer_desc *peer; |
114 |
|
125 |
|
115 |
@@ -1128,6 +1153,7 @@ |
126 |
@@ -1128,6 +1153,7 @@ void config_read(FILE *cf) |
116 |
perror(arg); |
127 |
perror(arg); |
117 |
continue; |
128 |
continue; |
118 |
} |
129 |
} |
Lines 120-126
Link Here
|
120 |
|
131 |
|
121 |
local_sa = NULL; |
132 |
local_sa = NULL; |
122 |
remote_sa = NULL; |
133 |
remote_sa = NULL; |
123 |
@@ -1974,6 +2000,7 @@ |
134 |
@@ -1974,6 +2000,7 @@ int cast_setkey(unsigned char *b, unsign |
124 |
return 0; |
135 |
return 0; |
125 |
} |
136 |
} |
126 |
|
137 |
|
Lines 128-134
Link Here
|
128 |
void my_idea_cbc_encrypt(unsigned char *iv, crypt_key *ek, |
139 |
void my_idea_cbc_encrypt(unsigned char *iv, crypt_key *ek, |
129 |
unsigned char *t, unsigned int len) |
140 |
unsigned char *t, unsigned int len) |
130 |
{ |
141 |
{ |
131 |
@@ -2002,6 +2029,7 @@ |
142 |
@@ -2002,11 +2029,12 @@ int my_idea_set_decrypt_key(unsigned cha |
132 |
idea_set_decrypt_key(&k->idea, &k->idea); |
143 |
idea_set_decrypt_key(&k->idea, &k->idea); |
133 |
return 0; |
144 |
return 0; |
134 |
} |
145 |
} |
Lines 136-143
Link Here
|
136 |
|
147 |
|
137 |
void my_des_cbc_encrypt(unsigned char *iv, crypt_key *ek, |
148 |
void my_des_cbc_encrypt(unsigned char *iv, crypt_key *ek, |
138 |
unsigned char *t, unsigned int len) |
149 |
unsigned char *t, unsigned int len) |
139 |
@@ -2081,6 +2109,11 @@ |
150 |
{ |
|
|
151 |
- des_cbc_encrypt(t, t, len, ek->des, iv, DES_ENCRYPT); |
152 |
+ DES_cbc_encrypt(t, t, len, &ek->des, iv, DES_ENCRYPT); |
153 |
} |
154 |
|
155 |
void my_des_cbc_decrypt(unsigned char *iv, crypt_key *dk, |
156 |
@@ -2018,7 +2046,7 @@ void my_des_cbc_decrypt(unsigned char *i |
157 |
for (i = 0; i < len; i++) printf(" %02x", ct[i]); |
158 |
printf("\n"); |
159 |
#endif |
160 |
- des_cbc_encrypt(ct, ct, len, dk->des, iv, DES_DECRYPT); |
161 |
+ DES_cbc_encrypt(ct, ct, len, &dk->des, iv, DES_DECRYPT); |
162 |
#if 0 |
163 |
printf("%d bytes after decrypt\n", len); |
164 |
for (i = 0; i < len; i++) printf(" %02x", ct[i]); |
165 |
@@ -2029,23 +2057,23 @@ void my_des_cbc_decrypt(unsigned char *i |
166 |
int my_des_setkey(unsigned char *b, unsigned int len, crypt_key *k) |
167 |
{ |
168 |
if (len == 8) |
169 |
- return des_set_key(b, k->des); |
170 |
+ return DES_set_key(b, &k->des); |
171 |
return -1; |
172 |
} |
173 |
|
174 |
void my_des3_cbc_encrypt(unsigned char *iv, crypt_key *ek, |
175 |
unsigned char *t, unsigned int len) |
176 |
{ |
177 |
- des_ede3_cbc_encrypt(t, t, len, |
178 |
- ek->des3.k1, ek->des3.k2, ek->des3.k3, |
179 |
+ DES_ede3_cbc_encrypt(t, t, len, |
180 |
+ &ek->des3.k1, &ek->des3.k2, &ek->des3.k3, |
181 |
iv, DES_ENCRYPT); |
182 |
} |
183 |
|
184 |
void my_des3_cbc_decrypt(unsigned char *iv, crypt_key *dk, |
185 |
unsigned char *ct, unsigned int len) |
186 |
{ |
187 |
- des_ede3_cbc_encrypt(ct, ct, len, |
188 |
- dk->des3.k1, dk->des3.k2, dk->des3.k3, |
189 |
+ DES_ede3_cbc_encrypt(ct, ct, len, |
190 |
+ &dk->des3.k1, &dk->des3.k2, &dk->des3.k3, |
191 |
iv, DES_DECRYPT); |
192 |
} |
193 |
|
194 |
@@ -2054,11 +2082,11 @@ int my_des3_setkey(unsigned char *b, uns |
195 |
if (len != 24) |
196 |
return -1; |
197 |
|
198 |
- if (des_set_key(b, k->des3.k1) != 0) |
199 |
+ if (DES_set_key(b, &k->des3.k1) != 0) |
200 |
return -1; |
201 |
- if (des_set_key(b+8, k->des3.k2) != 0) |
202 |
+ if (DES_set_key(b+8, &k->des3.k2) != 0) |
203 |
return -1; |
204 |
- if (des_set_key(b+16, k->des3.k3) != 0) |
205 |
+ if (DES_set_key(b+16, &k->des3.k3) != 0) |
206 |
return -1; |
207 |
|
140 |
return 0; |
208 |
return 0; |
|
|
209 |
@@ -2081,6 +2109,11 @@ int null_setkey(unsigned char *b, unsign |
210 |
return 0; |
141 |
} |
211 |
} |
142 |
|
212 |
|
143 |
+void usage() |
213 |
+void usage() |
Lines 148-154
Link Here
|
148 |
int main(int argc, char **argv) |
218 |
int main(int argc, char **argv) |
149 |
{ |
219 |
{ |
150 |
time_t t; |
220 |
time_t t; |
151 |
@@ -2088,9 +2121,14 @@ |
221 |
@@ -2088,9 +2121,14 @@ int main(int argc, char **argv) |
152 |
int pack, i; |
222 |
int pack, i; |
153 |
struct sockaddr_in from; |
223 |
struct sockaddr_in from; |
154 |
struct stat sb; |
224 |
struct stat sb; |
Lines 163-169
Link Here
|
163 |
openlog ("pipsecd", LOG_PID, LOG_DAEMON); |
233 |
openlog ("pipsecd", LOG_PID, LOG_DAEMON); |
164 |
syslog (LOG_NOTICE, "pipsecd starting"); |
234 |
syslog (LOG_NOTICE, "pipsecd starting"); |
165 |
|
235 |
|
166 |
@@ -2113,7 +2151,21 @@ |
236 |
@@ -2113,7 +2151,21 @@ int main(int argc, char **argv) |
167 |
if (encap_icmp_new(&encap_meth[ENCAP_ICMP], IPPROTO_ICMP) == -1) |
237 |
if (encap_icmp_new(&encap_meth[ENCAP_ICMP], IPPROTO_ICMP) == -1) |
168 |
exit(1); |
238 |
exit(1); |
169 |
|
239 |
|
Lines 186-192
Link Here
|
186 |
if (f == NULL) { |
256 |
if (f == NULL) { |
187 |
perror("configuration file"); |
257 |
perror("configuration file"); |
188 |
exit(1); |
258 |
exit(1); |
189 |
@@ -2123,8 +2175,8 @@ |
259 |
@@ -2123,8 +2175,8 @@ int main(int argc, char **argv) |
190 |
fclose(f); |
260 |
fclose(f); |
191 |
|
261 |
|
192 |
/* Execute startup script, if any */ |
262 |
/* Execute startup script, if any */ |