]>
Commit | Line | Data |
---|---|---|
e23f9969 JR |
1 | --- XFree86-4.0.1/xc/config/cf/xf86site.def~ Wed Nov 8 18:24:28 2000 |
2 | +++ XFree86-4.0.1/xc/config/cf/xf86site.def Wed Nov 8 18:37:12 2000 | |
3 | @@ -555,8 +555,8 @@ | |
4 | /* | |
5 | * If you want XDMAUTH support (if you have Wraphelp.c), uncomment this. | |
6 | * | |
7 | -#define HasXdmAuth YES | |
8 | */ | |
9 | +#define HasXdmAuth YES | |
10 | ||
11 | /* | |
12 | * If you have Linux DECnet support, and want to build XFree86 with support | |
13 | --- /dev/null Tue May 27 20:49:58 1997 | |
14 | +++ XFree86-4.0.1/xc/lib/Xdmcp/Wraphelp.c Sat Feb 26 02:04:11 2000 | |
15 | @@ -0,0 +1,401 @@ | |
16 | +/* | |
17 | + * This program implements the | |
18 | + * Proposed Federal Information Processing | |
19 | + * Data Encryption Standard. | |
20 | + * See Federal Register, March 17, 1975 (40FR12134) | |
21 | + */ | |
22 | + | |
23 | +/* | |
24 | + * Initial permutation, | |
25 | + */ | |
26 | +static char IP[] = { | |
27 | + 58,50,42,34,26,18,10, 2, | |
28 | + 60,52,44,36,28,20,12, 4, | |
29 | + 62,54,46,38,30,22,14, 6, | |
30 | + 64,56,48,40,32,24,16, 8, | |
31 | + 57,49,41,33,25,17, 9, 1, | |
32 | + 59,51,43,35,27,19,11, 3, | |
33 | + 61,53,45,37,29,21,13, 5, | |
34 | + 63,55,47,39,31,23,15, 7, | |
35 | +}; | |
36 | + | |
37 | +/* | |
38 | + * Final permutation, FP = IP^(-1) | |
39 | + */ | |
40 | +static char FP[] = { | |
41 | + 40, 8,48,16,56,24,64,32, | |
42 | + 39, 7,47,15,55,23,63,31, | |
43 | + 38, 6,46,14,54,22,62,30, | |
44 | + 37, 5,45,13,53,21,61,29, | |
45 | + 36, 4,44,12,52,20,60,28, | |
46 | + 35, 3,43,11,51,19,59,27, | |
47 | + 34, 2,42,10,50,18,58,26, | |
48 | + 33, 1,41, 9,49,17,57,25, | |
49 | +}; | |
50 | + | |
51 | +/* | |
52 | + * Permuted-choice 1 from the key bits | |
53 | + * to yield C and D. | |
54 | + * Note that bits 8,16... are left out: | |
55 | + * They are intended for a parity check. | |
56 | + */ | |
57 | +static char PC1_C[] = { | |
58 | + 57,49,41,33,25,17, 9, | |
59 | + 1,58,50,42,34,26,18, | |
60 | + 10, 2,59,51,43,35,27, | |
61 | + 19,11, 3,60,52,44,36, | |
62 | +}; | |
63 | + | |
64 | +static char PC1_D[] = { | |
65 | + 63,55,47,39,31,23,15, | |
66 | + 7,62,54,46,38,30,22, | |
67 | + 14, 6,61,53,45,37,29, | |
68 | + 21,13, 5,28,20,12, 4, | |
69 | +}; | |
70 | + | |
71 | +/* | |
72 | + * Sequence of shifts used for the key schedule. | |
73 | +*/ | |
74 | +static char shifts[] = { | |
75 | + 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1, | |
76 | +}; | |
77 | + | |
78 | +/* | |
79 | + * Permuted-choice 2, to pick out the bits from | |
80 | + * the CD array that generate the key schedule. | |
81 | + */ | |
82 | +static char PC2_C[] = { | |
83 | + 14,17,11,24, 1, 5, | |
84 | + 3,28,15, 6,21,10, | |
85 | + 23,19,12, 4,26, 8, | |
86 | + 16, 7,27,20,13, 2, | |
87 | +}; | |
88 | + | |
89 | +static char PC2_D[] = { | |
90 | + 41,52,31,37,47,55, | |
91 | + 30,40,51,45,33,48, | |
92 | + 44,49,39,56,34,53, | |
93 | + 46,42,50,36,29,32, | |
94 | +}; | |
95 | + | |
96 | +/* | |
97 | + * The C and D arrays used to calculate the key schedule. | |
98 | + */ | |
99 | + | |
100 | +static char C[28]; | |
101 | +static char D[28]; | |
102 | + | |
103 | +/* | |
104 | + * The key schedule. | |
105 | + * Generated from the key. | |
106 | + */ | |
107 | +static char KS[16][48]; | |
108 | + | |
109 | +/* | |
110 | + * The E bit-selection table. | |
111 | + */ | |
112 | +static char E[48]; | |
113 | +static char e[] = { | |
114 | + 32, 1, 2, 3, 4, 5, | |
115 | + 4, 5, 6, 7, 8, 9, | |
116 | + 8, 9,10,11,12,13, | |
117 | + 12,13,14,15,16,17, | |
118 | + 16,17,18,19,20,21, | |
119 | + 20,21,22,23,24,25, | |
120 | + 24,25,26,27,28,29, | |
121 | + 28,29,30,31,32, 1, | |
122 | +}; | |
123 | + | |
124 | +/* | |
125 | + * Set up the key schedule from the key. | |
126 | + */ | |
127 | + | |
128 | +static | |
129 | +setkey(key) | |
130 | +char *key; | |
131 | +{ | |
132 | + int i, j, k; | |
133 | + int t; | |
134 | + char *ptr; | |
135 | + | |
136 | + /* | |
137 | + * First, generate C and D by permuting | |
138 | + * the key. The low order bit of each | |
139 | + * 8-bit char is not used, so C and D are only 28 | |
140 | + * bits apiece. | |
141 | + */ | |
142 | + for (i=0; i<28; i++) { | |
143 | + C[i] = key[PC1_C[i]-1]; | |
144 | + D[i] = key[PC1_D[i]-1]; | |
145 | + } | |
146 | + /* | |
147 | + * To generate Ki, rotate C and D according | |
148 | + * to schedule and pick up a permutation | |
149 | + * using PC2. | |
150 | + */ | |
151 | + for (i=0; i<16; i++) { | |
152 | + /* | |
153 | + * rotate. | |
154 | + */ | |
155 | + for (k=0; k<shifts[i]; k++) { | |
156 | + t = C[0]; | |
157 | + ptr = C; | |
158 | + for (j=0; j<28-1; j++) | |
159 | + { | |
160 | + *ptr = ptr[1]; | |
161 | + ptr++; | |
162 | + } | |
163 | + C[27] = t; | |
164 | + t = D[0]; | |
165 | + ptr = D; | |
166 | + for (j=0; j<28-1; j++) | |
167 | + { | |
168 | + *ptr = ptr[1]; | |
169 | + ptr++; | |
170 | + } | |
171 | + D[27] = t; | |
172 | + } | |
173 | + /* | |
174 | + * get Ki. Note C and D are concatenated. | |
175 | + */ | |
176 | + ptr = &KS[i][0]; | |
177 | + for (j=0; j<24; j++) { | |
178 | + ptr[j] = C[PC2_C[j]-1]; | |
179 | + ptr[j+24] = D[PC2_D[j]-28-1]; | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + for(i=0;i<48;i++) | |
184 | + E[i] = e[i]; | |
185 | +} | |
186 | + | |
187 | +/* | |
188 | + * The 8 selection functions. | |
189 | + * For some reason, they give a 0-origin | |
190 | + * index, unlike everything else. | |
191 | + */ | |
192 | +static char S[8][64] = { | |
193 | + 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7, | |
194 | + 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8, | |
195 | + 4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0, | |
196 | + 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13, | |
197 | + | |
198 | + 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10, | |
199 | + 3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5, | |
200 | + 0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15, | |
201 | + 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9, | |
202 | + | |
203 | + 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8, | |
204 | + 13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1, | |
205 | + 13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7, | |
206 | + 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12, | |
207 | + | |
208 | + 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15, | |
209 | + 13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9, | |
210 | + 10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4, | |
211 | + 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14, | |
212 | + | |
213 | + 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9, | |
214 | + 14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6, | |
215 | + 4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14, | |
216 | + 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3, | |
217 | + | |
218 | + 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11, | |
219 | + 10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8, | |
220 | + 9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6, | |
221 | + 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13, | |
222 | + | |
223 | + 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1, | |
224 | + 13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6, | |
225 | + 1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2, | |
226 | + 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12, | |
227 | + | |
228 | + 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7, | |
229 | + 1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2, | |
230 | + 7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8, | |
231 | + 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11, | |
232 | +}; | |
233 | + | |
234 | +/* | |
235 | + * P is a permutation on the selected combination | |
236 | + * of the current L and key. | |
237 | + */ | |
238 | +static char P[] = { | |
239 | + 16, 7,20,21, | |
240 | + 29,12,28,17, | |
241 | + 1,15,23,26, | |
242 | + 5,18,31,10, | |
243 | + 2, 8,24,14, | |
244 | + 32,27, 3, 9, | |
245 | + 19,13,30, 6, | |
246 | + 22,11, 4,25, | |
247 | +}; | |
248 | + | |
249 | +/* | |
250 | + * The current block, divided into 2 halves. | |
251 | + */ | |
252 | + | |
253 | +static char L[64]; | |
254 | +#define R (L + 32) | |
255 | +static char tempL[32]; | |
256 | +static char f[32]; | |
257 | + | |
258 | +/* | |
259 | + * The combination of the key and the input, before selection. | |
260 | + */ | |
261 | +static char preS[48]; | |
262 | + | |
263 | +/* | |
264 | + * The payoff: encrypt a block. | |
265 | + */ | |
266 | + | |
267 | +static | |
268 | +encrypt (block, edflag) | |
269 | +char *block; | |
270 | +{ | |
271 | + int i, ii; | |
272 | + register t, j, k; | |
273 | + | |
274 | + /* | |
275 | + * First, permute the bits in the input | |
276 | + */ | |
277 | + for (j=0; j<64; j++) | |
278 | + L[j] = block[IP[j]-1]; | |
279 | + /* | |
280 | + * Perform an encryption operation 16 times. | |
281 | + */ | |
282 | + for (ii=0; ii<16; ii++) { | |
283 | +/* print_bits ("L R", L); */ | |
284 | + /* | |
285 | + * Set direction | |
286 | + */ | |
287 | + if (edflag) | |
288 | + i = 15-ii; | |
289 | + else | |
290 | + i = ii; | |
291 | + /* | |
292 | + * Save the R array, | |
293 | + * which will be the new L. | |
294 | + */ | |
295 | + for (j=0; j<32; j++) | |
296 | + tempL[j] = R[j]; | |
297 | + /* | |
298 | + * Expand R to 48 bits using the E selector; | |
299 | + * exclusive-or with the current key bits. | |
300 | + */ | |
301 | + for (j=0; j<48; j++) | |
302 | + preS[j] = R[E[j]-1] ^ KS[i][j]; | |
303 | + /* | |
304 | + * The pre-select bits are now considered | |
305 | + * in 8 groups of 6 bits each. | |
306 | + * The 8 selection functions map these | |
307 | + * 6-bit quantities into 4-bit quantities | |
308 | + * and the results permuted | |
309 | + * to make an f(R, K). | |
310 | + * The indexing into the selection functions | |
311 | + * is peculiar; it could be simplified by | |
312 | + * rewriting the tables. | |
313 | + */ | |
314 | + for (j=0; j<8; j++) { | |
315 | + t = 6*j; | |
316 | + k = S[j][(preS[t+0]<<5)+ | |
317 | + (preS[t+1]<<3)+ | |
318 | + (preS[t+2]<<2)+ | |
319 | + (preS[t+3]<<1)+ | |
320 | + (preS[t+4]<<0)+ | |
321 | + (preS[t+5]<<4)]; | |
322 | + t = 4*j; | |
323 | + f[t+0] = (k>>3)&01; | |
324 | + f[t+1] = (k>>2)&01; | |
325 | + f[t+2] = (k>>1)&01; | |
326 | + f[t+3] = (k>>0)&01; | |
327 | + } | |
328 | + /* | |
329 | + * The new R is L ^ f(R, K). | |
330 | + * The f here has to be permuted first, though. | |
331 | + */ | |
332 | + for (j=0; j<32; j++) | |
333 | + R[j] = L[j] ^ f[P[j]-1]; | |
334 | + /* | |
335 | + * Finally, the new L (the original R) | |
336 | + * is copied back. | |
337 | + */ | |
338 | + for (j=0; j<32; j++) | |
339 | + L[j] = tempL[j]; | |
340 | + } | |
341 | + /* | |
342 | + * The output L and R are reversed. | |
343 | + */ | |
344 | + for (j=0; j<32; j++) { | |
345 | + t = L[j]; | |
346 | + L[j] = R[j]; | |
347 | + R[j] = t; | |
348 | + } | |
349 | + /* | |
350 | + * The final output | |
351 | + * gets the inverse permutation of the very original. | |
352 | + */ | |
353 | + for (j=0; j<64; j++) | |
354 | + block[j] = L[FP[j]-1]; | |
355 | +} | |
356 | + | |
357 | +static | |
358 | +bytes_to_bits (bytes, bits) | |
359 | + unsigned char *bytes; | |
360 | + char *bits; | |
361 | +{ | |
362 | + int bit, byte, value; | |
363 | + | |
364 | + for (byte = 0; byte < 8; byte++) | |
365 | + { | |
366 | + value = *bytes++; | |
367 | + for (bit = 0; bit < 8; bit++) | |
368 | + *bits++ = (value >> (7-bit)) & 1; | |
369 | + } | |
370 | +} | |
371 | + | |
372 | +static | |
373 | +bits_to_bytes (bits, bytes) | |
374 | + char *bits; | |
375 | + unsigned char *bytes; | |
376 | +{ | |
377 | + int bit, byte, value; | |
378 | + | |
379 | + for (byte = 0; byte < 8; byte++) | |
380 | + { | |
381 | + value = 0; | |
382 | + for (bit = 0; bit < 8; bit++) | |
383 | + value |= *bits++ << (7-bit); | |
384 | + *bytes++ = value; | |
385 | + } | |
386 | +} | |
387 | + | |
388 | +/* | |
389 | + * Interface compatible with Kerberos DES implementation | |
390 | + */ | |
391 | + | |
392 | +# include "Wrap.h" | |
393 | + | |
394 | +/*ARGSUSED*/ | |
395 | +_XdmcpAuthSetup (key, schedule) | |
396 | + auth_cblock key; | |
397 | + auth_wrapper_schedule schedule; | |
398 | +{ | |
399 | + char expand_key[64]; | |
400 | + | |
401 | + bytes_to_bits ((unsigned char *) key, expand_key); | |
402 | + setkey (expand_key); | |
403 | +} | |
404 | + | |
405 | +/*ARGSUSED*/ | |
406 | +_XdmcpAuthDoIt (input, output, schedule, edflag) | |
407 | + auth_cblock input, output; | |
408 | + auth_wrapper_schedule schedule; | |
409 | + int edflag; | |
410 | +{ | |
411 | + char expand_input[64]; | |
412 | + | |
413 | + bytes_to_bits ((unsigned char *) input, expand_input); | |
414 | + encrypt (expand_input, !edflag); | |
415 | + bits_to_bytes (expand_input, (unsigned char *) output); | |
416 | +} |