home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / dec / 5842 < prev    next >
Encoding:
Text File  |  1992-11-08  |  41.4 KB  |  1,206 lines

  1. Xref: sparky comp.sys.dec:5842 comp.unix.ultrix:8166 comp.unix.osf.osf1:30
  2. Newsgroups: comp.sys.dec,comp.unix.ultrix,comp.unix.osf.osf1
  3. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!ugle.unit.no!imf.unit.no!arnej
  4. From: arnej@imf.unit.no (Arne Henrik Juul)
  5. Subject: X11R5 for DEC OSF/1 V1.0 [LONG]
  6. Message-ID: <ARNEJ.92Nov9005519@khym.imf.unit.no>
  7. Followup-To: comp.unix.osf.osf1
  8. Sender: news@ugle.unit.no (NetNews Administrator)
  9. Organization: Norwegian Institute of Technology
  10. Date: 9 Nov 92 00:55:19
  11. Lines: 1193
  12.  
  13.  
  14.  
  15. (NOTE crossposting and follow-up!)
  16.  
  17.  
  18. I have finished my diffs (and tested them, too!) for compiling
  19. X11R5 patchlevel 17 on the DECstation 3100 / DEC OSF/1 V1.0 platform.
  20.  
  21. Preliminaries:
  22.  
  23. You need GCC, 2.3.1 preferred. This compiles out-of-the-box configured
  24. for "mips-dec-osf1".
  25.  
  26. You need the MIT distribution of X11R5, with patches 1-17 applied.
  27.  
  28. The system include file /usr/include/sys/shm.h has a small error,
  29. which cause the demo program x11perf to fail. A patch is included
  30. that you might want to apply. I made a local version in the gcc
  31. include directory (.../lib/gcc-lib/mips-dec-osf1/2.3.1/include/sys)
  32. and made my changes there.
  33.  
  34. After you apply these patches, you will probably want to edit site.h
  35. to suit your local conventions. We prefer to install all of X under
  36. /local, with binaries in /local/bin (together with gcc, emacs, etc).
  37. Also you might want to change the value of InstallXdmConfig, etc.
  38.  
  39. Patches are also available via anonymous FTP to flipper.pvv.unit.no,
  40. directory /pub/decosf/X11R5.
  41.  
  42. These patches are of course offered on a 'works for me' basis,
  43. but feel free to mail me if you have any problems with them.
  44.  
  45.    --  Arne H. Juul,   arnej@lise.unit.no
  46.  
  47.  
  48. PATCH for /usr/include/sys/shm.h:
  49.  
  50. *** shm.h.orig    Sun Nov  8 18:27:09 1992
  51. --- shm.h    Sun Nov  8 18:28:47 1992
  52. ***************
  53. *** 143,157 ****
  54.           shmmni,        /* number of shared memory identifiers */
  55.           shmseg;        /* max attached shared memory segments per process */
  56.   };
  57.   #endif /* _KERNEL */
  58.   
  59.   #endif /* _OSF_SOURCE */
  60.   
  61. - extern struct shmid_internal shmem[];
  62. - extern struct shminfo shminfo;
  63.   #endif /* _SYS_SHM_H_ */
  64. --- 143,152 ----
  65.           shmmni,        /* number of shared memory identifiers */
  66.           shmseg;        /* max attached shared memory segments per process */
  67.   };
  68. + extern struct shmid_internal shmem[];
  69. + extern struct shminfo shminfo;
  70.   #endif /* _KERNEL */
  71.   
  72.   #endif /* _OSF_SOURCE */
  73.   
  74.   #endif /* _SYS_SHM_H_ */
  75.  
  76.  
  77. PATCH for X11R5 patchlevel 17:
  78.  
  79. diff -rcN X11R5/mit/clients/xconsole/xconsole.c mit/clients/xconsole/xconsole.c
  80. *** X11R5/mit/clients/xconsole/xconsole.c    Thu Jul 25 19:24:34 1991
  81. --- mit/clients/xconsole/xconsole.c    Fri Nov  6 21:47:05 1992
  82. ***************
  83. *** 105,111 ****
  84.       {"-exitOnFail", "*exitOnFail",    XrmoptionNoArg,        "TRUE"},
  85.   };
  86.   
  87. ! #ifdef ultrix
  88.   #define USE_FILE
  89.   #define FILE_NAME   "/dev/xcons"
  90.   #endif
  91. --- 105,111 ----
  92.       {"-exitOnFail", "*exitOnFail",    XrmoptionNoArg,        "TRUE"},
  93.   };
  94.   
  95. ! #if defined(ultrix) || (defined(__osf__) && defined(MIPSEL))
  96.   #define USE_FILE
  97.   #define FILE_NAME   "/dev/xcons"
  98.   #endif
  99. diff -rcN X11R5/mit/clients/xload/get_load.c mit/clients/xload/get_load.c
  100. *** X11R5/mit/clients/xload/get_load.c    Thu Jul 25 19:21:17 1991
  101. --- mit/clients/xload/get_load.c    Fri Nov  6 23:39:33 1992
  102. ***************
  103. *** 56,62 ****
  104.   #    endif /* i386 */
  105.   #endif
  106.   
  107. ! #if defined(umips) || (defined(ultrix) && defined(mips))
  108.   #include <sys/fixpoint.h>
  109.   #endif
  110.   
  111. --- 56,62 ----
  112.   #    endif /* i386 */
  113.   #endif
  114.   
  115. ! #if defined(umips) || (defined(ultrix) && defined(mips) && !defined(__osf__))
  116.   #include <sys/fixpoint.h>
  117.   #endif
  118.   
  119. ***************
  120. *** 561,567 ****
  121.       (void) lseek(kmem, loadavg_seek, 0);
  122.   #endif
  123.   
  124. ! #if defined(sun) || defined (UTEK) || defined(sequent) || defined(alliant) || defined(SVR4) || defined(sgi) || defined(hcx)
  125.       {
  126.           long temp;
  127.           (void) read(kmem, (char *)&temp, sizeof(long));
  128. --- 561,570 ----
  129.       (void) lseek(kmem, loadavg_seek, 0);
  130.   #endif
  131.   
  132. ! #if defined(sun) || defined (UTEK) || defined(sequent) || defined(alliant) || defined(SVR4) || defined(sgi) || defined(hcx) || defined(__osf__)
  133. ! #ifndef FSCALE
  134. ! #define FSCALE 256.0
  135. ! #endif
  136.       {
  137.           long temp;
  138.           (void) read(kmem, (char *)&temp, sizeof(long));
  139. diff -rcN X11R5/mit/clients/xterm/main.c mit/clients/xterm/main.c
  140. *** X11R5/mit/clients/xterm/main.c    Mon May  4 14:43:01 1992
  141. --- mit/clients/xterm/main.c    Fri Nov  6 23:38:18 1992
  142. ***************
  143. *** 66,71 ****
  144. --- 66,75 ----
  145.   #define ATT
  146.   #define USE_TERMIOS
  147.   #endif
  148. + #ifdef __osf__
  149. + #define USE_SYSV_UTMP
  150. + #endif
  151.     
  152.   #ifdef SYSV386
  153.   #define USE_SYSV_UTMP
  154. ***************
  155. *** 192,203 ****
  156. --- 196,214 ----
  157.   #endif
  158.   
  159.   #ifndef UTMP_FILENAME
  160. + #ifdef UTMP_FILE
  161. + #define UTMP_FILENAME UTMP_FILE
  162. + #else
  163.   #define UTMP_FILENAME "/etc/utmp"
  164.   #endif
  165. + #endif
  166.   #ifndef LASTLOG_FILENAME
  167.   #define LASTLOG_FILENAME "/usr/adm/lastlog"  /* only on BSD systems */
  168.   #endif
  169.   #ifndef WTMP_FILENAME
  170. + #ifdef WTMP_FILE
  171. + #define WTMP_FILENAME WTMP_FILE
  172. + #else
  173.   #if defined(SYSV)
  174.   #define WTMP_FILENAME "/etc/wtmp"
  175.   #else
  176. ***************
  177. *** 204,209 ****
  178. --- 215,221 ----
  179.   #define WTMP_FILENAME "/usr/adm/wtmp"
  180.   #endif
  181.   #endif
  182. + #endif
  183.   
  184.   #include <signal.h>
  185.   
  186. ***************
  187. *** 357,363 ****
  188.   extern struct utmp *getutent();
  189.   extern struct utmp *getutid();
  190.   extern struct utmp *getutline();
  191. ! extern void pututline();
  192.   extern void setutent();
  193.   extern void endutent();
  194.   extern void utmpname();
  195. --- 369,375 ----
  196.   extern struct utmp *getutent();
  197.   extern struct utmp *getutid();
  198.   extern struct utmp *getutline();
  199. ! /* extern void pututline(); */ /* Include file incorrect in DEC OSF/1 V1.0 */
  200.   extern void setutent();
  201.   extern void endutent();
  202.   extern void utmpname();
  203. ***************
  204. *** 1758,1767 ****
  205.   #endif
  206.   #ifdef USE_SYSV_TERMIO
  207.           char numbuf[12];
  208.   #if defined(UTMP) && defined(USE_SYSV_UTMP)
  209.           char *ptyname;
  210.   #endif
  211. - #endif    /* USE_SYSV_TERMIO */
  212.   
  213.   #ifdef USE_USG_PTYS
  214.   #if defined(SYSV) && defined(SYSV386)
  215. --- 1770,1779 ----
  216.   #endif
  217.   #ifdef USE_SYSV_TERMIO
  218.           char numbuf[12];
  219. + #endif    /* USE_SYSV_TERMIO */
  220.   #if defined(UTMP) && defined(USE_SYSV_UTMP)
  221.           char *ptyname;
  222.   #endif
  223.   
  224.   #ifdef USE_USG_PTYS
  225.   #if defined(SYSV) && defined(SYSV386)
  226. diff -rcN X11R5/mit/config/Imake.tmpl mit/config/Imake.tmpl
  227. *** X11R5/mit/config/Imake.tmpl    Mon Nov 25 21:44:55 1991
  228. --- mit/config/Imake.tmpl    Fri Nov  6 00:06:42 1992
  229. ***************
  230. *** 63,68 ****
  231. --- 63,74 ----
  232.   #define VaxArchitecture
  233.   #endif
  234.   
  235. + #ifdef __osf__
  236. + #define MacroIncludeFile <osf1.cf>
  237. + #define MacroFile osf1.cf
  238. + #define OSFArchitecture
  239. + #endif
  240.   #ifdef sun
  241.   #define MacroIncludeFile <sun.cf>
  242.   #define MacroFile sun.cf
  243. diff -rcN X11R5/mit/config/imakemdep.h mit/config/imakemdep.h
  244. *** X11R5/mit/config/imakemdep.h    Sun Aug 25 20:39:59 1991
  245. --- mit/config/imakemdep.h    Fri Nov  6 00:13:51 1992
  246. ***************
  247. *** 156,161 ****
  248. --- 156,164 ----
  249.   #ifdef unix
  250.       "-Uunix",    /* remove unix symbol so that filename unix.c okay */
  251.   #endif
  252. + #ifdef __osf__
  253. +     "-D__osf__",
  254. + #endif
  255.   #ifdef M4330
  256.       "-DM4330",    /* Tektronix */
  257.   #endif
  258. ***************
  259. *** 268,273 ****
  260. --- 271,279 ----
  261.   #endif
  262.   #ifdef sun
  263.       {"sun", "1"},
  264. + #endif
  265. + #ifdef __osf__
  266. +     {"__osf__", "1"},
  267.   #endif
  268.   #ifdef hpux
  269.       {"hpux", "1"},
  270. diff -rcN X11R5/mit/config/noop.rules mit/config/noop.rules
  271. *** X11R5/mit/config/noop.rules    Sat Feb 23 18:22:13 1991
  272. --- mit/config/noop.rules    Fri Nov  6 00:48:03 1992
  273. ***************
  274. *** 0 ****
  275. --- 1 ----
  276. diff -rcN X11R5/mit/config/osf1.cf mit/config/osf1.cf
  277. *** X11R5/mit/config/osf1.cf
  278. --- mit/config/osf1.cf    Fri Nov  6 22:18:25 1992
  279. ***************
  280. *** 0 ****
  281. --- 1,29 ----
  282. + /*
  283. +  * SET VERSION NUMBERS BEFORE MAKING MAKEFILES
  284. +  */
  285. + #define OSName            OSF1
  286. + #define OSMajorVersion    1
  287. + #define OSMinorVersion    0
  288. + #define SystemV NO
  289. + #define HasVoidSignalReturn YES
  290. + #define HasPutenv YES
  291. + #define HasBsearch YES
  292. + #define Malloc0ReturnsNull YES
  293. + #undef ExtensionDefines
  294. + #define ExtensionDefines -DSHAPE -DMITSHM -DMULTIBUFFER -DMITMISC
  295. + #define HasShm YES
  296. + #define    BootstrapCFlags -D_BSD -D__osf__ -Dmips -DMIPSEL
  297. + #define XdecServer YES
  298. + #define StandardDefines
  299. + #define DefaultCCOptions -D_BSD -Dmips -DMIPSEL
  300. + #define ServerDefines StandardDefines ExtensionDefines -DXDMCP
  301. + #define CcCmd gcc -ansi
  302. + #define ImakeCcCmd gcc -ansi
  303. + /**/# platform:  DEC OSF/1 V1.0
  304. + /**/# operating system:  OSName
  305. diff -rcN X11R5/mit/config/site.def mit/config/site.def
  306. *** X11R5/mit/config/site.def    Thu Aug  1 08:29:28 1991
  307. --- mit/config/site.def    Fri Nov  6 22:16:31 1992
  308. ***************
  309. *** 25,41 ****
  310.   
  311.   #ifdef BeforeVendorCF
  312.   
  313. - /* #define HasGcc YES */
  314.   #endif /* BeforeVendorCF */
  315.   
  316.   #ifdef AfterVendorCF
  317.   
  318. - /*
  319.   #ifdef ProjectRoot
  320.   #undef ProjectRoot
  321.   #endif
  322. ! #define ProjectRoot /usr/X11R5
  323. ! */
  324.   
  325.   #endif /* AfterVendorCF */
  326. --- 25,42 ----
  327.   
  328.   #ifdef BeforeVendorCF
  329.   
  330.   #endif /* BeforeVendorCF */
  331.   
  332.   #ifdef AfterVendorCF
  333.   
  334.   #ifdef ProjectRoot
  335.   #undef ProjectRoot
  336.   #endif
  337. ! #define ProjectRoot /local
  338. ! #define HasXdmAuth YES
  339. ! #define BuildPex YES
  340. ! #define MotifBC YES
  341. ! #define InstallFSConfig YES
  342. ! #define    InstallXdmConfig NO
  343.   
  344.   #endif /* AfterVendorCF */
  345. diff -rcN X11R5/mit/extensions/server/shm.c mit/extensions/server/shm.c
  346. *** X11R5/mit/extensions/server/shm.c    Fri Jul 12 14:55:42 1991
  347. --- mit/extensions/server/shm.c    Fri Nov  6 19:34:24 1992
  348. ***************
  349. *** 49,58 ****
  350. --- 49,61 ----
  351.       unsigned long size;
  352.   } ShmDescRec, *ShmDescPtr;
  353.   
  354. + #ifndef __osf__
  355. + /* OSF/1 has a proper prototype for this function. */
  356.   #if NeedFunctionPrototypes && !defined(ultrix)
  357.   void *shmat(int, void*, int);
  358.   #else
  359.   char *shmat();
  360. + #endif
  361.   #endif
  362.   static void miShmPutImage(), fbShmPutImage();
  363.   static PixmapPtr fbShmCreatePixmap();
  364. diff -rcN X11R5/mit/lib/Xdmcp/Wraphelp.c mit/lib/Xdmcp/Wraphelp.c
  365. *** X11R5/mit/lib/Xdmcp/Wraphelp.c
  366. --- mit/lib/Xdmcp/Wraphelp.c    Fri Nov  6 07:10:10 1992
  367. ***************
  368. *** 0 ****
  369. --- 1,773 ----
  370. + /*
  371. +  * Wraphelp.c - DES for Xdm authentication.
  372. +  */
  373. + /* Dennis Ferguson, University of Toronto */
  374. + #include <X11/Xos.h>
  375. + #include <X11/X.h>
  376. + #include <X11/Xmd.h>
  377. + #include <X11/Xdmcp.h>
  378. + /*
  379. +  * This is a concatentation of several files from an existing library.
  380. +  * Please ignore funny sounding comments.
  381. +  */
  382. + #include "Wrap.h"
  383. + /*
  384. +  * Include the following declaration in any code which uses the
  385. +  * DES_SP_ENCRYPT_ROUND() and DES_SP_DECRYPT_ROUND() macros below.
  386. +  * This may be declared const if you wish, as long as you change the
  387. +  * declaration in des_table.c as well.
  388. +  *
  389. +  * extern unsigned long _Auth_SP_Table[8][64];
  390. +  */
  391. + /*
  392. +  * Use standard shortform to reference the table to save typing
  393. +  */
  394. + #define    SP    _Auth_SP_Table
  395. + /*
  396. +  * Code to do a DES round using the tables.  Note that the E expansion
  397. +  * is easy to compute algorithmically, especially if done out-of-order.
  398. +  * Take a look at its form and compare it to everything involving temp
  399. +  * below.
  400. +  *
  401. +  * Be careful when comparing the results of the inner DES loop to other
  402. +  * implementations.  To save a rotation inside the loop, "left" and "right"
  403. +  * are kept rotated 11 bits to the right (i.e. by ((x) >> 11) | (x) << 21).
  404. +  * The SP table is similarly rotated to maintain this.  We make it the
  405. +  * responsibility of the IP code to do the initial rotation, and the FP
  406. +  * code to undo it, as integrating this can save an instruction or so.
  407. +  * In any event, if you want to do a step-by-step comparison of the results
  408. +  * with another DES implementation you will need to rotate the intermediate
  409. +  * results 11 bits to the left to make them match the standard.
  410. +  *
  411. +  * Note too that the SP table has been reordered to match the order of
  412. +  * the keys (if the original order of SP was 12345678, the reordered
  413. +  * table is 71354682).  This is unnecessary, but was done since some
  414. +  * compilers seem to like you going through the matrix from beginning
  415. +  * to end.
  416. +  *
  417. +  * There is a difference in the best way to do this depending on whether
  418. +  * one is encrypting or decrypting.  If encrypting we move forward through
  419. +  * the keys and hence should move forward through the table.  If decrypting
  420. +  * we go back.  Part of the need for this comes from trying to emulate
  421. +  * existing software which generates a single key schedule and uses it
  422. +  * both for encrypting and decrypting.  Generating separate encryption
  423. +  * and decryption key schedules would allow one to use the same code
  424. +  * for both.
  425. +  *
  426. +  * left, right and temp should be unsigned long values.  left and right
  427. +  * should be the high and low order parts of the cipher block at the
  428. +  * current stage of processing (this makes sense if you read the spec).
  429. +  * kp should be an unsigned long pointer which points at the current
  430. +  * set of subkeys in the key schedule.  It is advanced to the next set
  431. +  * (i.e. by 8 bytes) when this is done.
  432. +  *
  433. +  * This occurs in the innermost loop of the DES function.  The four
  434. +  * variables should really be in registers.
  435. +  *
  436. +  * When using this, the inner loop of the DES function might look like:
  437. +  *
  438. +  *    for (i = 0; i < 8; i++) {
  439. +  *        DES_SP_{EN,DE}CRYPT_ROUND(left, right, temp, kp);
  440. +  *        DES_SP_{EN,DE}CRYPT_ROUND(right, left, temp, kp);
  441. +  *    }
  442. +  *
  443. +  * Note the trick above.  You are supposed to do 16 rounds, swapping
  444. +  * left and right at the end of each round.  By doing two rounds at
  445. +  * a time and swapping left and right in the code we can avoid the
  446. +  * swaps altogether.
  447. +  */
  448. + #define    DES_SP_ENCRYPT_ROUND(left, right, temp, kp) \
  449. +     (temp) = (right) ^ *(kp)++; \
  450. +     (left) ^= SP[0][((temp) >> 24) & 0x3f] \
  451. +         | SP[1][((temp) >> 16) & 0x3f] \
  452. +         | SP[2][((temp) >>  8) & 0x3f] \
  453. +         | SP[3][((temp)      ) & 0x3f]; \
  454. +     (temp) = (((right) >> 12) | ((right) << 20)) ^ *(kp)++; \
  455. +     (left) ^= SP[4][((temp) >> 24) & 0x3f] \
  456. +         | SP[5][((temp) >> 16) & 0x3f] \
  457. +         | SP[6][((temp) >>  8) & 0x3f] \
  458. +         | SP[7][((temp)      ) & 0x3f]
  459. + #define    DES_SP_DECRYPT_ROUND(left, right, temp, kp) \
  460. +     (temp) = (((right) >> 12) | ((right) << 20)) ^ *(--(kp)); \
  461. +     (left) ^= SP[7][((temp)      ) & 0x3f] \
  462. +         | SP[6][((temp) >>  8) & 0x3f] \
  463. +         | SP[5][((temp) >> 16) & 0x3f] \
  464. +         | SP[4][((temp) >> 24) & 0x3f]; \
  465. +     (temp) = (right) ^ *(--(kp)); \
  466. +     (left) ^= SP[3][((temp)      ) & 0x3f] \
  467. +         | SP[2][((temp) >>  8) & 0x3f] \
  468. +         | SP[1][((temp) >> 16) & 0x3f] \
  469. +         | SP[0][((temp) >> 24) & 0x3f]
  470. + /*
  471. +  * The following implements the initial permutation, followed by
  472. +  * an 11 bit right rotation of both halves to keep the inner loop
  473. +  * happy.  This sequence was shown to me by Richard Outerbridge.
  474. +  */
  475. + #define    DES_INITIAL_PERM(left, right, temp) \
  476. +     (temp) = (((left) >> 4) ^ right) & 0x0f0f0f0f; \
  477. +     (right) ^= (temp); \
  478. +     (left) ^= (temp) << 4; \
  479. +     (temp) = (((left) >> 16) ^ (right)) & 0x0000ffff; \
  480. +     (right) ^= (temp); \
  481. +     (left) ^= (temp) << 16; \
  482. +     (temp) = (((right) >> 2) ^ (left)) & 0x33333333; \
  483. +     (left) ^= (temp); \
  484. +     (right) ^= ((temp) << 2); \
  485. +     (temp) = (((right) >> 8) ^ (left)) & 0x00ff00ff; \
  486. +     (left) ^= (temp); \
  487. +     (right) ^= (temp) << 8; \
  488. +     (temp) = (((left) >> 1) ^ (right)) & 0x55555555; \
  489. +     (right) ^= (temp); \
  490. +     (left) ^= ((temp) << 1); \
  491. +     (left) = (((left) >> 11) | ((left) << 21)); \
  492. +     (right) = (((right) >> 11) | ((right) << 21))
  493. + /*
  494. +  * Here is the final permutation, which is simply the inverse of
  495. +  * the initial permuation.  Note that there is a tiny trick here.
  496. +  * We are supposed to swap left and right before doing the final
  497. +  * permutation.  We instead do the swap in the first five lines
  498. +  * below (compare to the last five lines above), for free.
  499. +  */
  500. + #define DES_FINAL_PERM(left, right, temp) \
  501. +     (temp) = (((left) << 11) | ((left) >> 21)); \
  502. +     (left) = (((right) << 11) | ((right) >> 21)); \
  503. +     (right) = (((left) >> 1) ^ (temp)) & 0x55555555; \
  504. +     (left) ^= (right) << 1; \
  505. +     (right) ^= (temp); \
  506. +     (temp) = (((right) >> 8) ^ (left)) & 0x00ff00ff; \
  507. +     (left) ^= (temp); \
  508. +     (right) ^= (temp) << 8; \
  509. +     (temp) = (((right) >> 2) ^ (left)) & 0x33333333; \
  510. +     (left) ^= (temp); \
  511. +     (right) ^= ((temp) << 2); \
  512. +     (temp) = (((left) >> 16) ^ (right)) & 0x0000ffff; \
  513. +     (right) ^= (temp); \
  514. +     (left) ^= (temp) << 16; \
  515. +     (temp) = (((left) >> 4) ^ right) & 0x0f0f0f0f; \
  516. +     (right) ^= (temp); \
  517. +     (left) ^= ((temp) << 4)
  518. + /*
  519. +  * Finally, as a sample of how all this might be held together, the
  520. +  * following two macros do in-place encryptions and decryptions.  left
  521. +  * and right are two unsigned long variables which at the beginning
  522. +  * are expected to hold the clear (encrypted) block in host byte order
  523. +  * (left the high order four bytes, right the low order).  At the end
  524. +  * they will contain the encrypted (clear) block.  temp is an unsigned long
  525. +  * used as a temporary.  kp is an unsigned long pointer pointing at
  526. +  * the start of the key schedule.  All these should be in registers.
  527. +  *
  528. +  * You can probably sometimes do better than these by rewriting for
  529. +  * particular situations.  These aren't bad, though.
  530. +  */
  531. + #define    DES_DO_ENCRYPT(left, right, temp, kp) \
  532. +     do { \
  533. +         register int i; \
  534. +         DES_INITIAL_PERM((left), (right), (temp)); \
  535. +         for (i = 0; i < 8; i++) { \
  536. +             DES_SP_ENCRYPT_ROUND((left), (right), (temp), (kp)); \
  537. +             DES_SP_ENCRYPT_ROUND((right), (left), (temp), (kp)); \
  538. +         } \
  539. +         DES_FINAL_PERM((left), (right), (temp)); \
  540. +         (kp) -= (2 * 16); \
  541. +     } while (0)
  542. + #define    DES_DO_DECRYPT(left, right, temp, kp) \
  543. +     do { \
  544. +         register int i; \
  545. +         DES_INITIAL_PERM((left), (right), (temp)); \
  546. +         (kp) += (2 * 16); \
  547. +         for (i = 0; i < 8; i++) { \
  548. +             DES_SP_DECRYPT_ROUND((left), (right), (temp), (kp)); \
  549. +             DES_SP_DECRYPT_ROUND((right), (left), (temp), (kp)); \
  550. +         } \
  551. +         DES_FINAL_PERM((left), (right), (temp)); \
  552. +     } while (0)
  553. + /*
  554. +  * These are handy dandy utility thingies for straightening out bytes.
  555. +  * Included here because they're used a couple of places.
  556. +  */
  557. + #define    GET_HALF_BLOCK(lr, ip) \
  558. +     (lr) = ((unsigned long)(*(ip)++)) << 24; \
  559. +     (lr) |= ((unsigned long)(*(ip)++)) << 16; \
  560. +     (lr) |= ((unsigned long)(*(ip)++)) << 8; \
  561. +     (lr) |= (unsigned long)(*(ip)++)
  562. + #define    PUT_HALF_BLOCK(lr, op) \
  563. +     *(op)++ = ((lr) >> 24) & 0xff; \
  564. +     *(op)++ = ((lr) >> 16) & 0xff; \
  565. +     *(op)++ = ((lr) >> 8) & 0xff; \
  566. +     *(op)++ = (lr) & 0xff
  567. + /*
  568. +  * These tables may be declared const if you want.  Many compilers
  569. +  * don't support this, though.
  570. +  */
  571. + /*
  572. +  * The DES algorithm which uses these is intended to be fairly speedy
  573. +  * at the expense of some memory.  All the standard hacks are used.
  574. +  * The S boxes and the P permutation are precomputed into one table.
  575. +  * The E box never actually appears explicitly since it is easy to apply
  576. +  * this algorithmically as needed.  This should run pretty fast on machines
  577. +  * with 32 bit words and bit field/multiple bit shift instructions which
  578. +  * are fast.
  579. +  *
  580. +  * [There used to be tables used to do the initial and final permutations
  581. +  *  here.  These were deleted in favour of algorithmic code (table-free). ]
  582. +  */
  583. + /*
  584. +  * The SP table is actually the S boxes and the P permutation
  585. +  * table combined.  This table is actually reordered from the
  586. +  * spec, to match the order of key application we follow.  Each
  587. +  * entry has also been rotated right by 11 bits, to remove a
  588. +  * rotation from the inner loop.
  589. +  */
  590. + static unsigned long _Auth_SP_Table[8][64] = {
  591. +     0x00000200, 0x00204200, 0x80204000, 0x00000000,    /* 7 */
  592. +     0x80000000, 0x80204000, 0x80200200, 0x80004200,
  593. +     0x80204200, 0x00000200, 0x00000000, 0x00204000,
  594. +     0x00200000, 0x00004000, 0x00204200, 0x80200000,
  595. +     0x80004000, 0x80200200, 0x00200200, 0x80004000,
  596. +     0x00204000, 0x00004200, 0x80004200, 0x00200200,
  597. +     0x00004200, 0x80000000, 0x80200000, 0x80204200,
  598. +     0x80000200, 0x00200000, 0x00004000, 0x80000200,
  599. +     0x00004000, 0x80000200, 0x00000200, 0x80204000,
  600. +     0x80204000, 0x00204200, 0x00204200, 0x00200000,
  601. +     0x00200200, 0x00004000, 0x80004000, 0x00000200,
  602. +     0x80004200, 0x80200000, 0x80200200, 0x80004200,
  603. +     0x80200000, 0x00204000, 0x80204200, 0x00004200,
  604. +     0x80000200, 0x00000000, 0x00200000, 0x80204200,
  605. +     0x00000000, 0x80200200, 0x00004200, 0x80000000,
  606. +     0x00204000, 0x80004000, 0x80000000, 0x00200200,
  607. +     0x40001010, 0x00000000, 0x00000010, 0x40401010,    /* 1 */
  608. +     0x00401010, 0x40400010, 0x00400000, 0x00000010,
  609. +     0x40000000, 0x40001010, 0x40401010, 0x40000000,
  610. +     0x40401000, 0x00401010, 0x00001000, 0x00400000,
  611. +     0x40400000, 0x40001000, 0x40001000, 0x40000010,
  612. +     0x40000010, 0x00001010, 0x00001010, 0x40401000,
  613. +     0x00400010, 0x00401000, 0x00401000, 0x00400010,
  614. +     0x00000000, 0x40400000, 0x40400010, 0x00001000,
  615. +     0x00000010, 0x40401010, 0x00400000, 0x00001010,
  616. +     0x40001010, 0x00001000, 0x00001000, 0x40000000,
  617. +     0x00401010, 0x00000010, 0x40000010, 0x00401000,
  618. +     0x40000000, 0x00400000, 0x40401000, 0x40400010,
  619. +     0x40401010, 0x00400010, 0x00001010, 0x40401000,
  620. +     0x00401000, 0x40400000, 0x40400010, 0x40001010,
  621. +     0x40400000, 0x40001000, 0x40001000, 0x00000000,
  622. +     0x00400010, 0x40000010, 0x00000000, 0x00401010,
  623. +     0x20800000, 0x20008020, 0x00000000, 0x00808020,    /* 3 */
  624. +     0x20008000, 0x00000000, 0x20800020, 0x20008000,
  625. +     0x00800020, 0x00808000, 0x00808000, 0x00000020,
  626. +     0x20808020, 0x00800020, 0x00008020, 0x20800000,
  627. +     0x00008000, 0x00800000, 0x20008020, 0x20000000,
  628. +     0x20000020, 0x00008020, 0x00808020, 0x20800020,
  629. +     0x20808000, 0x20000020, 0x00000020, 0x20808000,
  630. +     0x00800000, 0x20808020, 0x20000000, 0x00008000,
  631. +     0x20008020, 0x00008000, 0x00800020, 0x20800000,
  632. +     0x00000020, 0x20008020, 0x20008000, 0x00000000,
  633. +     0x20000000, 0x00800020, 0x20808020, 0x20008000,
  634. +     0x00808000, 0x20000000, 0x00000000, 0x00808020,
  635. +     0x20808000, 0x00000020, 0x00008000, 0x20808020,
  636. +     0x00800000, 0x20800020, 0x20000020, 0x00808000,
  637. +     0x00008020, 0x20808000, 0x20800000, 0x00008020,
  638. +     0x20800020, 0x00800000, 0x00808020, 0x20000020,
  639. +     0x10000000, 0x10002080, 0x00002080, 0x10042000,    /* 5 */
  640. +     0x00000080, 0x10000000, 0x00040000, 0x00002080,
  641. +     0x10040080, 0x00000080, 0x10002000, 0x10040080,
  642. +     0x10042000, 0x00042080, 0x10000080, 0x00040000,
  643. +     0x00002000, 0x00040080, 0x00040080, 0x00000000,
  644. +     0x10040000, 0x10042080, 0x10042080, 0x10002000,
  645. +     0x00042080, 0x10040000, 0x00000000, 0x00042000,
  646. +     0x10002080, 0x00002000, 0x00042000, 0x10000080,
  647. +     0x00000080, 0x10042000, 0x10000000, 0x00002000,
  648. +     0x00040000, 0x00002080, 0x10042000, 0x10040080,
  649. +     0x10002000, 0x00040000, 0x00042080, 0x10002080,
  650. +     0x10040080, 0x10000000, 0x00002000, 0x00042080,
  651. +     0x10042080, 0x10000080, 0x00042000, 0x10042080,
  652. +     0x00002080, 0x00000000, 0x00040080, 0x00042000,
  653. +     0x10000080, 0x10002000, 0x10040000, 0x00000080,
  654. +     0x00000000, 0x00040080, 0x10002080, 0x10040000,
  655. +     0x00100802, 0x08100002, 0x08100002, 0x08000000,    /* 4 */
  656. +     0x08000802, 0x08100800, 0x00100800, 0x00100002,
  657. +     0x00000000, 0x00000802, 0x00000802, 0x08100802,
  658. +     0x08100000, 0x00000000, 0x08000800, 0x00100800,
  659. +     0x00100000, 0x00000002, 0x00000800, 0x00100802,
  660. +     0x08000000, 0x00000800, 0x00100002, 0x08000002,
  661. +     0x08100800, 0x00100000, 0x08000002, 0x08000800,
  662. +     0x00000002, 0x08000802, 0x08100802, 0x08100000,
  663. +     0x08000800, 0x00100800, 0x00000802, 0x08100802,
  664. +     0x08100000, 0x00000000, 0x00000000, 0x00000802,
  665. +     0x08000002, 0x08000800, 0x08100800, 0x00100000,
  666. +     0x00100802, 0x08100002, 0x08100002, 0x08000000,
  667. +     0x08100802, 0x08100000, 0x00100000, 0x00000002,
  668. +     0x00100800, 0x00100002, 0x08000802, 0x08100800,
  669. +     0x00100002, 0x08000002, 0x00000800, 0x00100802,
  670. +     0x08000000, 0x00000800, 0x00000002, 0x08000802,
  671. +     0x01020000, 0x00020400, 0x00000004, 0x01020404,    /* 6 */
  672. +     0x00020400, 0x01000000, 0x01020404, 0x00000400,
  673. +     0x00020004, 0x01000404, 0x00000400, 0x01020000,
  674. +     0x01000400, 0x00020004, 0x00020000, 0x01000004,
  675. +     0x00000000, 0x01000400, 0x01020004, 0x00000004,
  676. +     0x00000404, 0x01020004, 0x01000000, 0x01020400,
  677. +     0x01020400, 0x00000000, 0x01000404, 0x00020404,
  678. +     0x01000004, 0x00000404, 0x00020404, 0x00020000,
  679. +     0x00020004, 0x01000000, 0x01020400, 0x00000404,
  680. +     0x01020404, 0x00000400, 0x01000004, 0x01020000,
  681. +     0x00000400, 0x00020004, 0x00020000, 0x01000004,
  682. +     0x01020000, 0x01020404, 0x00000404, 0x00020400,
  683. +     0x01000404, 0x00020404, 0x00000000, 0x01020400,
  684. +     0x01000000, 0x00000004, 0x00020400, 0x01000404,
  685. +     0x00000004, 0x01000400, 0x01020004, 0x00000000,
  686. +     0x00020404, 0x00020000, 0x01000400, 0x01020004,
  687. +     0x04010001, 0x00000001, 0x00000040, 0x04010041,    /* 8 */
  688. +     0x00010000, 0x04010001, 0x04000000, 0x00010000,
  689. +     0x04000040, 0x00010040, 0x04010041, 0x00000041,
  690. +     0x00010041, 0x04000041, 0x00000001, 0x04000000,
  691. +     0x00010040, 0x04010000, 0x00010001, 0x04000001,
  692. +     0x00000041, 0x04000040, 0x04010040, 0x00010041,
  693. +     0x04000001, 0x00000000, 0x00000000, 0x04010040,
  694. +     0x04010000, 0x00010001, 0x04000041, 0x00000040,
  695. +     0x04000041, 0x00000040, 0x00010041, 0x00000001,
  696. +     0x04000000, 0x04010040, 0x00000001, 0x04000041,
  697. +     0x00010001, 0x04000000, 0x04010000, 0x00010040,
  698. +     0x04010040, 0x00010000, 0x00000040, 0x04010001,
  699. +     0x00000000, 0x04010041, 0x04000040, 0x04010000,
  700. +     0x00010040, 0x00010001, 0x04010001, 0x00000000,
  701. +     0x04010041, 0x00000041, 0x00000041, 0x04000001,
  702. +     0x04000001, 0x04000040, 0x00010000, 0x00010041,
  703. +     0x02080108, 0x00080008, 0x00000008, 0x02000108,    /* 2 */
  704. +     0x00000100, 0x02000000, 0x02080100, 0x02080008,
  705. +     0x02080000, 0x02080108, 0x00080108, 0x00080000,
  706. +     0x00080008, 0x00000100, 0x02000000, 0x02080100,
  707. +     0x00000108, 0x02000100, 0x02080008, 0x00000000,
  708. +     0x00080000, 0x00000008, 0x02000108, 0x00080100,
  709. +     0x02000100, 0x02080000, 0x00000000, 0x00000108,
  710. +     0x02000008, 0x00080108, 0x00080100, 0x02000008,
  711. +     0x00000000, 0x02000108, 0x02080100, 0x00000100,
  712. +     0x02080008, 0x00080100, 0x00080108, 0x00000008,
  713. +     0x00080100, 0x00080008, 0x02000000, 0x02080108,
  714. +     0x02000108, 0x02000000, 0x00000008, 0x00080000,
  715. +     0x02000008, 0x00080108, 0x00000100, 0x02080000,
  716. +     0x02000100, 0x02080008, 0x02080000, 0x02000100,
  717. +     0x00000108, 0x00000000, 0x00080008, 0x02000008,
  718. +     0x00080000, 0x02080100, 0x02080108, 0x00000108
  719. + };
  720. + /*
  721. +  * XdmcpAuthDoIt - {en,de}crypt a block in ECB mode
  722. +  */
  723. + void
  724. + _XdmcpAuthDoIt(in, out, schedule, encrypt)
  725. +     auth_cblock *in;
  726. +     auth_cblock *out;
  727. +     auth_wrapper_schedule schedule;
  728. +     int encrypt;
  729. + {
  730. +     register unsigned long left, right;
  731. +     register unsigned long temp;
  732. +     register int i;
  733. +     {
  734. +         /*
  735. +          * Need a temporary for copying the data in
  736. +          */
  737. +         register unsigned char *datap;
  738. +         /*
  739. +          * Copy the input block into the registers
  740. +          */
  741. +         datap = (unsigned char *)in;
  742. +         GET_HALF_BLOCK(left, datap);
  743. +         GET_HALF_BLOCK(right, datap);
  744. +     }
  745. +     /*
  746. +      * Do the initial permutation.
  747. +      */
  748. +     DES_INITIAL_PERM(left, right, temp);
  749. +     /*
  750. +      * Now the rounds.  Use different code depending on whether it
  751. +      * is an encryption or a decryption (gross, should keep both
  752. +      * sets of keys in the key schedule instead).
  753. +      */
  754. +     if (encrypt) {
  755. +         register unsigned long *kp;
  756. +         kp = (unsigned long *)schedule;
  757. +         for (i = 0; i < 8; i++) {
  758. +             DES_SP_ENCRYPT_ROUND(left, right, temp, kp);
  759. +             DES_SP_ENCRYPT_ROUND(right, left, temp, kp);
  760. +         }
  761. +     } else {
  762. +         register unsigned long *kp;
  763. +         /*
  764. +          * Point kp past end of schedule
  765. +          */
  766. +         kp = ((unsigned long *)schedule) + (2 * 16);;
  767. +         for (i = 0; i < 8; i++) {
  768. +             DES_SP_DECRYPT_ROUND(left, right, temp, kp);
  769. +             DES_SP_DECRYPT_ROUND(right, left, temp, kp);
  770. +         }
  771. +     }
  772. +     /*
  773. +      * Do the final permutation
  774. +      */
  775. +     DES_FINAL_PERM(left, right, temp);
  776. +     /*
  777. +      * Finally, copy the result out a byte at a time
  778. +      */
  779. +     {
  780. +         register unsigned char *datap;
  781. +         datap = (unsigned char *)out;
  782. +         PUT_HALF_BLOCK(left, datap);
  783. +         PUT_HALF_BLOCK(right, datap);
  784. +     }
  785. + }
  786. + /*
  787. +  * Permuted choice 1 tables.  These are used to extract bits
  788. +  * from the left and right parts of the key to form Ci and Di.
  789. +  * The code that uses these tables knows which bits from which
  790. +  * part of each key are used to form Ci and Di.
  791. +  */
  792. + static unsigned long PC1_CL[8] = {
  793. +     0x00000000, 0x00000010, 0x00001000, 0x00001010,
  794. +     0x00100000, 0x00100010, 0x00101000, 0x00101010
  795. + };
  796. + static unsigned long PC1_DL[16] = {
  797. +     0x00000000, 0x00100000, 0x00001000, 0x00101000,
  798. +     0x00000010, 0x00100010, 0x00001010, 0x00101010,
  799. +     0x00000001, 0x00100001, 0x00001001, 0x00101001,
  800. +     0x00000011, 0x00100011, 0x00001011, 0x00101011
  801. + };
  802. + static unsigned long PC1_CR[16] = {
  803. +     0x00000000, 0x00000001, 0x00000100, 0x00000101,
  804. +     0x00010000, 0x00010001, 0x00010100, 0x00010101,
  805. +     0x01000000, 0x01000001, 0x01000100, 0x01000101,
  806. +     0x01010000, 0x01010001, 0x01010100, 0x01010101
  807. + };
  808. + static unsigned long PC1_DR[8] = {
  809. +     0x00000000, 0x01000000, 0x00010000, 0x01010000,
  810. +     0x00000100, 0x01000100, 0x00010100, 0x01010100
  811. + };
  812. + /*
  813. +  * At the start of some iterations of the key schedule we do
  814. +  * a circular left shift by one place, while for others we do a shift by
  815. +  * two places.  This has bits set for the iterations where we do 2 bit
  816. +  * shifts, starting at the low order bit.
  817. +  */
  818. + #define    TWO_BIT_SHIFTS    0x7efc
  819. + /*
  820. +  * Permuted choice 2 tables.  The first actually produces the low order
  821. +  * 24 bits of the subkey Ki from the 28 bit value of Ci.  The second produces
  822. +  * the high order 24 bits from Di.  The tables are indexed by six bit
  823. +  * segments of Ci and Di respectively.  The code is handcrafted to compute
  824. +  * the appropriate 6 bit chunks.
  825. +  *
  826. +  * Note that for ease of computation, the 24 bit values are produced with
  827. +  * six bits going into each byte.  Note also that the table has been byte
  828. +  * rearranged to produce keys which match the order we will apply them
  829. +  * in in the des code.
  830. +  */
  831. + static unsigned long PC2_C[4][64] = {
  832. +     0x00000000, 0x00000004, 0x00010000, 0x00010004,
  833. +     0x00000400, 0x00000404, 0x00010400, 0x00010404,
  834. +     0x00000020, 0x00000024, 0x00010020, 0x00010024,
  835. +     0x00000420, 0x00000424, 0x00010420, 0x00010424,
  836. +     0x01000000, 0x01000004, 0x01010000, 0x01010004,
  837. +     0x01000400, 0x01000404, 0x01010400, 0x01010404,
  838. +     0x01000020, 0x01000024, 0x01010020, 0x01010024,
  839. +     0x01000420, 0x01000424, 0x01010420, 0x01010424,
  840. +     0x00020000, 0x00020004, 0x00030000, 0x00030004,
  841. +     0x00020400, 0x00020404, 0x00030400, 0x00030404,
  842. +     0x00020020, 0x00020024, 0x00030020, 0x00030024,
  843. +     0x00020420, 0x00020424, 0x00030420, 0x00030424,
  844. +     0x01020000, 0x01020004, 0x01030000, 0x01030004,
  845. +     0x01020400, 0x01020404, 0x01030400, 0x01030404,
  846. +     0x01020020, 0x01020024, 0x01030020, 0x01030024,
  847. +     0x01020420, 0x01020424, 0x01030420, 0x01030424,
  848. +     0x00000000, 0x02000000, 0x00000800, 0x02000800,
  849. +     0x00080000, 0x02080000, 0x00080800, 0x02080800,
  850. +     0x00000001, 0x02000001, 0x00000801, 0x02000801,
  851. +     0x00080001, 0x02080001, 0x00080801, 0x02080801,
  852. +     0x00000100, 0x02000100, 0x00000900, 0x02000900,
  853. +     0x00080100, 0x02080100, 0x00080900, 0x02080900,
  854. +     0x00000101, 0x02000101, 0x00000901, 0x02000901,
  855. +     0x00080101, 0x02080101, 0x00080901, 0x02080901,
  856. +     0x10000000, 0x12000000, 0x10000800, 0x12000800,
  857. +     0x10080000, 0x12080000, 0x10080800, 0x12080800,
  858. +     0x10000001, 0x12000001, 0x10000801, 0x12000801,
  859. +     0x10080001, 0x12080001, 0x10080801, 0x12080801,
  860. +     0x10000100, 0x12000100, 0x10000900, 0x12000900,
  861. +     0x10080100, 0x12080100, 0x10080900, 0x12080900,
  862. +     0x10000101, 0x12000101, 0x10000901, 0x12000901,
  863. +     0x10080101, 0x12080101, 0x10080901, 0x12080901,
  864. +     0x00000000, 0x00040000, 0x00002000, 0x00042000,
  865. +     0x00100000, 0x00140000, 0x00102000, 0x00142000,
  866. +     0x20000000, 0x20040000, 0x20002000, 0x20042000,
  867. +     0x20100000, 0x20140000, 0x20102000, 0x20142000,
  868. +     0x00000008, 0x00040008, 0x00002008, 0x00042008,
  869. +     0x00100008, 0x00140008, 0x00102008, 0x00142008,
  870. +     0x20000008, 0x20040008, 0x20002008, 0x20042008,
  871. +     0x20100008, 0x20140008, 0x20102008, 0x20142008,
  872. +     0x00200000, 0x00240000, 0x00202000, 0x00242000,
  873. +     0x00300000, 0x00340000, 0x00302000, 0x00342000,
  874. +     0x20200000, 0x20240000, 0x20202000, 0x20242000,
  875. +     0x20300000, 0x20340000, 0x20302000, 0x20342000,
  876. +     0x00200008, 0x00240008, 0x00202008, 0x00242008,
  877. +     0x00300008, 0x00340008, 0x00302008, 0x00342008,
  878. +     0x20200008, 0x20240008, 0x20202008, 0x20242008,
  879. +     0x20300008, 0x20340008, 0x20302008, 0x20342008,
  880. +     0x00000000, 0x00000010, 0x08000000, 0x08000010,
  881. +     0x00000200, 0x00000210, 0x08000200, 0x08000210,
  882. +     0x00000002, 0x00000012, 0x08000002, 0x08000012,
  883. +     0x00000202, 0x00000212, 0x08000202, 0x08000212,
  884. +     0x04000000, 0x04000010, 0x0c000000, 0x0c000010,
  885. +     0x04000200, 0x04000210, 0x0c000200, 0x0c000210,
  886. +     0x04000002, 0x04000012, 0x0c000002, 0x0c000012,
  887. +     0x04000202, 0x04000212, 0x0c000202, 0x0c000212,
  888. +     0x00001000, 0x00001010, 0x08001000, 0x08001010,
  889. +     0x00001200, 0x00001210, 0x08001200, 0x08001210,
  890. +     0x00001002, 0x00001012, 0x08001002, 0x08001012,
  891. +     0x00001202, 0x00001212, 0x08001202, 0x08001212,
  892. +     0x04001000, 0x04001010, 0x0c001000, 0x0c001010,
  893. +     0x04001200, 0x04001210, 0x0c001200, 0x0c001210,
  894. +     0x04001002, 0x04001012, 0x0c001002, 0x0c001012,
  895. +     0x04001202, 0x04001212, 0x0c001202, 0x0c001212
  896. + };
  897. + static unsigned long PC2_D[4][64] = {
  898. +     0x00000000, 0x02000000, 0x00020000, 0x02020000,
  899. +     0x00000100, 0x02000100, 0x00020100, 0x02020100,
  900. +     0x00000008, 0x02000008, 0x00020008, 0x02020008,
  901. +     0x00000108, 0x02000108, 0x00020108, 0x02020108,
  902. +     0x00200000, 0x02200000, 0x00220000, 0x02220000,
  903. +     0x00200100, 0x02200100, 0x00220100, 0x02220100,
  904. +     0x00200008, 0x02200008, 0x00220008, 0x02220008,
  905. +     0x00200108, 0x02200108, 0x00220108, 0x02220108,
  906. +     0x00000200, 0x02000200, 0x00020200, 0x02020200,
  907. +     0x00000300, 0x02000300, 0x00020300, 0x02020300,
  908. +     0x00000208, 0x02000208, 0x00020208, 0x02020208,
  909. +     0x00000308, 0x02000308, 0x00020308, 0x02020308,
  910. +     0x00200200, 0x02200200, 0x00220200, 0x02220200,
  911. +     0x00200300, 0x02200300, 0x00220300, 0x02220300,
  912. +     0x00200208, 0x02200208, 0x00220208, 0x02220208,
  913. +     0x00200308, 0x02200308, 0x00220308, 0x02220308,
  914. +     0x00000000, 0x00001000, 0x00000020, 0x00001020,
  915. +     0x00100000, 0x00101000, 0x00100020, 0x00101020,
  916. +     0x08000000, 0x08001000, 0x08000020, 0x08001020,
  917. +     0x08100000, 0x08101000, 0x08100020, 0x08101020,
  918. +     0x00000004, 0x00001004, 0x00000024, 0x00001024,
  919. +     0x00100004, 0x00101004, 0x00100024, 0x00101024,
  920. +     0x08000004, 0x08001004, 0x08000024, 0x08001024,
  921. +     0x08100004, 0x08101004, 0x08100024, 0x08101024,
  922. +     0x00000400, 0x00001400, 0x00000420, 0x00001420,
  923. +     0x00100400, 0x00101400, 0x00100420, 0x00101420,
  924. +     0x08000400, 0x08001400, 0x08000420, 0x08001420,
  925. +     0x08100400, 0x08101400, 0x08100420, 0x08101420,
  926. +     0x00000404, 0x00001404, 0x00000424, 0x00001424,
  927. +     0x00100404, 0x00101404, 0x00100424, 0x00101424,
  928. +     0x08000404, 0x08001404, 0x08000424, 0x08001424,
  929. +     0x08100404, 0x08101404, 0x08100424, 0x08101424,
  930. +     0x00000000, 0x10000000, 0x00010000, 0x10010000,
  931. +     0x00000002, 0x10000002, 0x00010002, 0x10010002,
  932. +     0x00002000, 0x10002000, 0x00012000, 0x10012000,
  933. +     0x00002002, 0x10002002, 0x00012002, 0x10012002,
  934. +     0x00040000, 0x10040000, 0x00050000, 0x10050000,
  935. +     0x00040002, 0x10040002, 0x00050002, 0x10050002,
  936. +     0x00042000, 0x10042000, 0x00052000, 0x10052000,
  937. +     0x00042002, 0x10042002, 0x00052002, 0x10052002,
  938. +     0x20000000, 0x30000000, 0x20010000, 0x30010000,
  939. +     0x20000002, 0x30000002, 0x20010002, 0x30010002,
  940. +     0x20002000, 0x30002000, 0x20012000, 0x30012000,
  941. +     0x20002002, 0x30002002, 0x20012002, 0x30012002,
  942. +     0x20040000, 0x30040000, 0x20050000, 0x30050000,
  943. +     0x20040002, 0x30040002, 0x20050002, 0x30050002,
  944. +     0x20042000, 0x30042000, 0x20052000, 0x30052000,
  945. +     0x20042002, 0x30042002, 0x20052002, 0x30052002,
  946. +     0x00000000, 0x04000000, 0x00000001, 0x04000001,
  947. +     0x01000000, 0x05000000, 0x01000001, 0x05000001,
  948. +     0x00000010, 0x04000010, 0x00000011, 0x04000011,
  949. +     0x01000010, 0x05000010, 0x01000011, 0x05000011,
  950. +     0x00080000, 0x04080000, 0x00080001, 0x04080001,
  951. +     0x01080000, 0x05080000, 0x01080001, 0x05080001,
  952. +     0x00080010, 0x04080010, 0x00080011, 0x04080011,
  953. +     0x01080010, 0x05080010, 0x01080011, 0x05080011,
  954. +     0x00000800, 0x04000800, 0x00000801, 0x04000801,
  955. +     0x01000800, 0x05000800, 0x01000801, 0x05000801,
  956. +     0x00000810, 0x04000810, 0x00000811, 0x04000811,
  957. +     0x01000810, 0x05000810, 0x01000811, 0x05000811,
  958. +     0x00080800, 0x04080800, 0x00080801, 0x04080801,
  959. +     0x01080800, 0x05080800, 0x01080801, 0x05080801,
  960. +     0x00080810, 0x04080810, 0x00080811, 0x04080811,
  961. +     0x01080810, 0x05080810, 0x01080811, 0x05080811
  962. + };
  963. + /*
  964. +  * Permute the key to give us our key schedule.
  965. +  */
  966. + void
  967. + _XdmcpAuthSetup(key, schedule)
  968. +     auth_cblock *key;
  969. +     auth_wrapper_schedule schedule;
  970. + {
  971. +     register unsigned long c, d;
  972. +     {
  973. +     /*
  974. +      * Need a pointer for the keys and a temporary long
  975. +      */
  976. +     register unsigned char *k;
  977. +     register unsigned long tmp;
  978. +     /*
  979. +      * Fetch the key into something we can work with
  980. +      */
  981. +     k = (unsigned char *)key;
  982. +     /*
  983. +      * The first permutted choice gives us the 28 bits for C0 and
  984. +      * 28 for D0.  C0 gets 12 bits from the left key and 16 from
  985. +      * the right, while D0 gets 16 from the left and 12 from the
  986. +      * right.  The code knows which bits go where.
  987. +      */
  988. +     tmp = ((unsigned long)(*(k)++)) << 24;
  989. +     tmp |= ((unsigned long)(*(k)++)) << 16;
  990. +     tmp |= ((unsigned long)(*(k)++)) << 8;
  991. +     tmp |= (unsigned long)(*(k)++);        /* left part of key */
  992. +     c =  PC1_CL[(tmp >> 29) & 0x7]
  993. +       | (PC1_CL[(tmp >> 21) & 0x7] << 1)
  994. +       | (PC1_CL[(tmp >> 13) & 0x7] << 2)
  995. +       | (PC1_CL[(tmp >>  5) & 0x7] << 3);
  996. +     d =  PC1_DL[(tmp >> 25) & 0xf]
  997. +       | (PC1_DL[(tmp >> 17) & 0xf] << 1)
  998. +       | (PC1_DL[(tmp >>  9) & 0xf] << 2)
  999. +       | (PC1_DL[(tmp >>  1) & 0xf] << 3);
  1000. +     tmp = ((unsigned long)(*(k)++)) << 24;
  1001. +     tmp |= ((unsigned long)(*(k)++)) << 16;
  1002. +     tmp |= ((unsigned long)(*(k)++)) << 8;
  1003. +     tmp |= (unsigned long)(*(k)++);        /* right part of key */
  1004. +     c |= PC1_CR[(tmp >> 28) & 0xf]
  1005. +       | (PC1_CR[(tmp >> 20) & 0xf] << 1)
  1006. +       | (PC1_CR[(tmp >> 12) & 0xf] << 2)
  1007. +       | (PC1_CR[(tmp >>  4) & 0xf] << 3);
  1008. +     d |= PC1_DR[(tmp >> 25) & 0x7]
  1009. +       | (PC1_DR[(tmp >> 17) & 0x7] << 1)
  1010. +       | (PC1_DR[(tmp >>  9) & 0x7] << 2)
  1011. +       | (PC1_DR[(tmp >>  1) & 0x7] << 3);
  1012. +     }
  1013. +     {
  1014. +     /*
  1015. +      * Need several temporaries in here
  1016. +      */
  1017. +     register unsigned long ltmp, rtmp;
  1018. +     register unsigned long *k;
  1019. +     register int two_bit_shifts;
  1020. +     register int i;
  1021. +     /*
  1022. +      * Now iterate to compute the key schedule.  Note that we
  1023. +      * record the entire set of subkeys in 6 bit chunks since
  1024. +      * they are used that way.  At 6 bits/char, we need
  1025. +      * 48/6 char's/subkey * 16 subkeys/encryption == 128 bytes.
  1026. +      * The schedule must be this big.
  1027. +      */
  1028. +     k = (unsigned long *)schedule;
  1029. +     two_bit_shifts = TWO_BIT_SHIFTS;
  1030. +     for (i = 16; i > 0; i--) {
  1031. +         /*
  1032. +          * Do the rotation.  One bit and two bit rotations
  1033. +          * are done separately.  Note C and D are 28 bits.
  1034. +          */
  1035. +         if (two_bit_shifts & 0x1) {
  1036. +         c = ((c << 2) & 0xffffffc) | (c >> 26);
  1037. +         d = ((d << 2) & 0xffffffc) | (d >> 26);
  1038. +         } else {
  1039. +         c = ((c << 1) & 0xffffffe) | (c >> 27);
  1040. +         d = ((d << 1) & 0xffffffe) | (d >> 27);
  1041. +         }
  1042. +         two_bit_shifts >>= 1;
  1043. +         /*
  1044. +          * Apply permutted choice 2 to C to get the first
  1045. +          * 24 bits worth of keys.  Note that bits 9, 18, 22
  1046. +          * and 25 (using DES numbering) in C are unused.  The
  1047. +          * shift-mask stuff is done to delete these bits from
  1048. +          * the indices, since this cuts the table size in half.
  1049. +          *
  1050. +          * The table is torqued, by the way.  If the standard
  1051. +          * byte order for this (high to low order) is 1234,
  1052. +          * the table actually gives us 4132.
  1053. +          */
  1054. +         ltmp = PC2_C[0][((c >> 22) & 0x3f)]
  1055. +              | PC2_C[1][((c >> 15) & 0xf) | ((c >> 16) & 0x30)]
  1056. +              | PC2_C[2][((c >>  4) & 0x3) | ((c >>  9) & 0x3c)]
  1057. +              | PC2_C[3][((c      ) & 0x7) | ((c >>  4) & 0x38)];
  1058. +         /*
  1059. +          * Apply permutted choice 2 to D to get the other half.
  1060. +          * Here, bits 7, 10, 15 and 26 go unused.  The sqeezing
  1061. +          * actually turns out to be cheaper here.
  1062. +          *
  1063. +          * This table is similarly torqued.  If the standard
  1064. +          * byte order is 5678, the table has the bytes permuted
  1065. +          * to give us 7685.
  1066. +          */
  1067. +         rtmp = PC2_D[0][((d >> 22) & 0x3f)]
  1068. +              | PC2_D[1][((d >> 14) & 0xf) | ((d >> 15) & 0x30)]
  1069. +              | PC2_D[2][((d >>  7) & 0x3f)]
  1070. +              | PC2_D[3][((d      ) & 0x3) | ((d >>  1) & 0x3c)];
  1071. +         /*
  1072. +          * Make up two words of the key schedule, with a
  1073. +          * byte order which is convenient for the DES
  1074. +          * inner loop.  The high order (first) word will
  1075. +          * hold bytes 7135 (high to low order) while the
  1076. +          * second holds bytes 4682.
  1077. +          */
  1078. +         *k++ = (ltmp & 0x00ffff00) | (rtmp & 0xff0000ff);
  1079. +         *k++ = (ltmp & 0xff0000ff) | (rtmp & 0x00ffff00);
  1080. +     }
  1081. +     }
  1082. + }
  1083. diff -rcN X11R5/mit/server/ddx/dec/cfbpmax/cfbpmax_io.c mit/server/ddx/dec/cfbpmax/cfbpmax_io.c
  1084. *** X11R5/mit/server/ddx/dec/cfbpmax/cfbpmax_io.c    Tue Jun 11 01:19:01 1991
  1085. --- mit/server/ddx/dec/cfbpmax/cfbpmax_io.c    Fri Nov  6 23:40:17 1992
  1086. ***************
  1087. *** 31,38 ****
  1088. --- 31,40 ----
  1089.   #include <sys/tty.h>
  1090.   #include <errno.h>
  1091.   #include <sys/devio.h>
  1092. + #ifndef __osf__
  1093.   #include <io/tc/pmioctl.h>
  1094.   #include <io/tc/dc7085reg.h>
  1095. + #endif
  1096.   
  1097.   #include "misc.h"
  1098.   #include "X.h"
  1099. diff -rcN X11R5/mit/extensions/server/PEX/ddpex/mi/level1/Imakefile mit/extensions/server/PEX/ddpex/mi/level1/Imakefile
  1100. *** X11R5/mit/extensions/server/PEX/ddpex/mi/level1/Imakefile    Wed Jul 24 21:57:43 1991
  1101. --- mit/extensions/server/PEX/ddpex/mi/level1/Imakefile    Sat Nov  7 19:05:30 1992
  1102. ***************
  1103. *** 57,69 ****
  1104.       miPck1Prim.c
  1105.   
  1106.   OBJS = miDDCtoGC.o \
  1107. !     miListUtil.o \ 
  1108.       miLvl1Tab.o \
  1109.       miRndFArea.o \
  1110.       miRndPLine.o \
  1111.       miRndMarkr.o \
  1112.       miRndText.o \
  1113. !     miRndTStrip.o \ 
  1114.       miPck1Prim.o
  1115.   
  1116.   NormalLibraryObjectRule()
  1117. --- 57,69 ----
  1118.       miPck1Prim.c
  1119.   
  1120.   OBJS = miDDCtoGC.o \
  1121. !     miListUtil.o \
  1122.       miLvl1Tab.o \
  1123.       miRndFArea.o \
  1124.       miRndPLine.o \
  1125.       miRndMarkr.o \
  1126.       miRndText.o \
  1127. !     miRndTStrip.o \
  1128.       miPck1Prim.o
  1129.   
  1130.   NormalLibraryObjectRule()
  1131.