home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / kit / part03 < prev    next >
Encoding:
Text File  |  1991-12-18  |  15.1 KB  |  583 lines

  1. Newsgroups: comp.sources.unix
  2. From: ram@eiffel.com (Raphael Manfredi)
  3. Subject: v25i051: kit - the ultimate mailing kit, Part03/04
  4. Sender: sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: ram@eiffel.com (Raphael Manfredi)
  8. Posting-Number: Volume 25, Issue 51
  9. Archive-Name: kit/part03
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 3 (of 4)."
  18. # Contents:  des/des.c
  19. # Wrapped by vixie@cognition.pa.dec.com on Thu Dec 19 21:18:30 1991
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'des/des.c' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'des/des.c'\"
  23. else
  24. echo shar: Extracting \"'des/des.c'\" \(13388 characters\)
  25. sed "s/^X//" >'des/des.c' <<'END_OF_FILE'
  26. X/* Sofware DES functions
  27. X * written 12 Dec 1986 by Phil Karn, KA9Q; large sections adapted from
  28. X * the 1977 public-domain program by Jim Gillogly
  29. X */
  30. X
  31. X/*
  32. X * $Id: des.c,v 2.0.1.1 91/04/01 15:39:35 ram Exp $
  33. X *
  34. X * $Log:    des.c,v $
  35. X * Revision 2.0.1.1  91/04/01  15:39:35  ram
  36. X * patch1: created
  37. X * 
  38. X */
  39. X
  40. X#define    NULL    0
  41. X
  42. X#include "../config.h"
  43. X
  44. X#if BYTEORDER == 0x1234
  45. X#define LITTLE_ENDIAN
  46. X#endif
  47. X
  48. X#ifdef    LITTLE_ENDIAN
  49. unsigned long byteswap();
  50. X#endif
  51. X
  52. X/* Tables defined in the Data Encryption Standard documents */
  53. X
  54. X/* initial permutation IP */
  55. static char ip[] = {
  56. X    58, 50, 42, 34, 26, 18, 10,  2,
  57. X    60, 52, 44, 36, 28, 20, 12,  4,
  58. X    62, 54, 46, 38, 30, 22, 14,  6,
  59. X    64, 56, 48, 40, 32, 24, 16,  8,
  60. X    57, 49, 41, 33, 25, 17,  9,  1,
  61. X    59, 51, 43, 35, 27, 19, 11,  3,
  62. X    61, 53, 45, 37, 29, 21, 13,  5,
  63. X    63, 55, 47, 39, 31, 23, 15,  7
  64. X};
  65. X
  66. X/* final permutation IP^-1 */
  67. static char fp[] = {
  68. X    40,  8, 48, 16, 56, 24, 64, 32,
  69. X    39,  7, 47, 15, 55, 23, 63, 31,
  70. X    38,  6, 46, 14, 54, 22, 62, 30,
  71. X    37,  5, 45, 13, 53, 21, 61, 29,
  72. X    36,  4, 44, 12, 52, 20, 60, 28,
  73. X    35,  3, 43, 11, 51, 19, 59, 27,
  74. X    34,  2, 42, 10, 50, 18, 58, 26,
  75. X    33,  1, 41,  9, 49, 17, 57, 25
  76. X};
  77. X
  78. X/* expansion operation matrix
  79. X * This is for reference only; it is unused in the code
  80. X * as the f() function performs it implicitly for speed
  81. X */
  82. X#ifdef notdef
  83. static char ei[] = {
  84. X    32,  1,  2,  3,  4,  5,
  85. X     4,  5,  6,  7,  8,  9,
  86. X     8,  9, 10, 11, 12, 13,
  87. X    12, 13, 14, 15, 16, 17,
  88. X    16, 17, 18, 19, 20, 21,
  89. X    20, 21, 22, 23, 24, 25,
  90. X    24, 25, 26, 27, 28, 29,
  91. X    28, 29, 30, 31, 32,  1 
  92. X};
  93. X#endif
  94. X
  95. X/* permuted choice table (key) */
  96. static char pc1[] = {
  97. X    57, 49, 41, 33, 25, 17,  9,
  98. X     1, 58, 50, 42, 34, 26, 18,
  99. X    10,  2, 59, 51, 43, 35, 27,
  100. X    19, 11,  3, 60, 52, 44, 36,
  101. X
  102. X    63, 55, 47, 39, 31, 23, 15,
  103. X     7, 62, 54, 46, 38, 30, 22,
  104. X    14,  6, 61, 53, 45, 37, 29,
  105. X    21, 13,  5, 28, 20, 12,  4
  106. X};
  107. X
  108. X/* number left rotations of pc1 */
  109. static char totrot[] = {
  110. X    1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28
  111. X};
  112. X
  113. X/* permuted choice key (table) */
  114. static char pc2[] = {
  115. X    14, 17, 11, 24,  1,  5,
  116. X     3, 28, 15,  6, 21, 10,
  117. X    23, 19, 12,  4, 26,  8,
  118. X    16,  7, 27, 20, 13,  2,
  119. X    41, 52, 31, 37, 47, 55,
  120. X    30, 40, 51, 45, 33, 48,
  121. X    44, 49, 39, 56, 34, 53,
  122. X    46, 42, 50, 36, 29, 32
  123. X};
  124. X
  125. X/* The (in)famous S-boxes */
  126. static char si[8][64] = {
  127. X    /* S1 */
  128. X    14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7,
  129. X     0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8,
  130. X     4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0,
  131. X    15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13,
  132. X
  133. X    /* S2 */
  134. X    15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10,
  135. X     3, 13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9, 11,  5,
  136. X     0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15,
  137. X    13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9,
  138. X
  139. X    /* S3 */
  140. X    10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8,
  141. X    13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1,
  142. X    13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7,
  143. X     1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12,
  144. X
  145. X    /* S4 */
  146. X     7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4, 15,
  147. X    13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,  9,
  148. X    10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,  4,
  149. X     3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2, 14,
  150. X
  151. X    /* S5 */
  152. X     2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9,
  153. X    14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6,
  154. X     4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14,
  155. X    11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3,
  156. X
  157. X    /* S6 */
  158. X    12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11,
  159. X    10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8,
  160. X     9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6,
  161. X     4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13,
  162. X
  163. X    /* S7 */
  164. X     4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1,
  165. X    13,  0, 11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6,
  166. X     1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2,
  167. X     6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12,
  168. X
  169. X    /* S8 */
  170. X    13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7,
  171. X     1, 15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2,
  172. X     7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8,
  173. X     2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11
  174. X};
  175. X
  176. X/* 32-bit permutation function P used on the output of the S-boxes */
  177. static char p32i[] = {    
  178. X    16,  7, 20, 21,
  179. X    29, 12, 28, 17,
  180. X     1, 15, 23, 26,
  181. X     5, 18, 31, 10,
  182. X     2,  8, 24, 14,
  183. X    32, 27,  3,  9,
  184. X    19, 13, 30,  6,
  185. X    22, 11,  4, 25
  186. X};
  187. X/* End of DES-defined tables */
  188. X
  189. X/* Lookup tables initialized once only at startup by desinit() */
  190. static long (*sp)[64];        /* Combined S and P boxes */
  191. X
  192. static char (*iperm)[16][8];    /* Initial and final permutations */
  193. static char (*fperm)[16][8];
  194. X
  195. X/* 8 6-bit subkeys for each of 16 rounds, initialized by setkey() */
  196. static unsigned char (*kn)[8];
  197. X
  198. X/* bit 0 is left-most in byte */
  199. static int bytebit[] = {
  200. X    0200,0100,040,020,010,04,02,01
  201. X};
  202. X
  203. static int nibblebit[] = {
  204. X     010,04,02,01
  205. X};
  206. static int desmode;
  207. X
  208. X/* Allocate space and initialize DES lookup arrays
  209. X * mode == 0: standard Data Encryption Algorithm
  210. X * mode == 1: DEA without initial and final permutations for speed
  211. X * mode == 2: DEA without permutations and with 128-byte key (completely
  212. X *            independent subkeys for each round)
  213. X */
  214. desinit(mode)
  215. int mode;
  216. X{
  217. X    char *malloc();
  218. X
  219. X    if(sp != NULL){
  220. X        /* Already initialized */
  221. X        return 0;
  222. X    }
  223. X    desmode = mode;
  224. X    
  225. X    if((sp = (long (*)[64])malloc(sizeof(long) * 8 * 64)) == NULL){
  226. X        return -1;
  227. X    }
  228. X    spinit();
  229. X    kn = (unsigned char (*)[8])malloc(sizeof(char) * 8 * 16);
  230. X    if(kn == NULL){
  231. X        free((char *)sp);
  232. X        return -1;
  233. X    }
  234. X    if(mode == 1 || mode == 2)    /* No permutations */
  235. X        return 0;
  236. X
  237. X    iperm = (char (*)[16][8])malloc(sizeof(char) * 16 * 16 * 8);
  238. X    if(iperm == NULL){
  239. X        free((char *)sp);
  240. X        free((char *)kn);
  241. X        return -1;
  242. X    }
  243. X    perminit(iperm,ip);
  244. X
  245. X    fperm = (char (*)[16][8])malloc(sizeof(char) * 16 * 16 * 8);
  246. X    if(fperm == NULL){
  247. X        free((char *)sp);
  248. X        free((char *)kn);
  249. X        free((char *)iperm);
  250. X        return -1;
  251. X    }
  252. X    perminit(fperm,fp);
  253. X    
  254. X    return 0;
  255. X}
  256. X/* Free up storage used by DES */
  257. desdone()
  258. X{
  259. X    if(sp == NULL)
  260. X        return;    /* Already done */
  261. X
  262. X    free((char *)sp);
  263. X    free((char *)kn);
  264. X    if(iperm != NULL)
  265. X        free((char *)iperm);
  266. X    if(fperm != NULL)
  267. X        free((char *)fperm);
  268. X
  269. X    sp = NULL;
  270. X    iperm = NULL;
  271. X    fperm = NULL;
  272. X    kn = NULL;
  273. X}
  274. X/* Set key (initialize key schedule array) */
  275. setkey(key)
  276. char *key;            /* 64 bits (will use only 56) */
  277. X{
  278. X    char pc1m[56];        /* place to modify pc1 into */
  279. X    char pcr[56];        /* place to rotate pc1 into */
  280. X    register int i,j,l;
  281. X    int m;
  282. X
  283. X    /* In mode 2, the 128 bytes of subkey are set directly from the
  284. X     * user's key, allowing him to use completely independent
  285. X     * subkeys for each round. Note that the user MUST specify a
  286. X     * full 128 bytes.
  287. X     *
  288. X     * I would like to think that this technique gives the NSA a real
  289. X     * headache, but I'm not THAT naive.
  290. X     */
  291. X    if(desmode == 2){
  292. X        for(i=0;i<16;i++)
  293. X            for(j=0;j<8;j++)
  294. X                kn[i][j] = *key++;
  295. X        return;
  296. X    }
  297. X    /* Clear key schedule */
  298. X    for (i=0; i<16; i++)
  299. X        for (j=0; j<8; j++)
  300. X            kn[i][j]=0;
  301. X
  302. X    for (j=0; j<56; j++) {        /* convert pc1 to bits of key */
  303. X        l=pc1[j]-1;        /* integer bit location     */
  304. X        m = l & 07;        /* find bit         */
  305. X        pc1m[j]=(key[l>>3] &    /* find which key byte l is in */
  306. X            bytebit[m])    /* and which bit of that byte */
  307. X            ? 1 : 0;    /* and store 1-bit result */
  308. X    }
  309. X    for (i=0; i<16; i++) {        /* key chunk for each iteration */
  310. X        for (j=0; j<56; j++)    /* rotate pc1 the right amount */
  311. X            pcr[j] = pc1m[(l=j+totrot[i])<(j<28? 28 : 56) ? l: l-28];
  312. X            /* rotate left and right halves independently */
  313. X        for (j=0; j<48; j++){    /* select bits individually */
  314. X            /* check bit that goes to kn[j] */
  315. X            if (pcr[pc2[j]-1]){
  316. X                /* mask it in if it's there */
  317. X                l= j % 6;
  318. X                kn[i][j/6] |= bytebit[l] >> 2;
  319. X            }
  320. X        }
  321. X    }
  322. X}
  323. X/* In-place encryption of 64-bit block */
  324. endes(block)
  325. char *block;
  326. X{
  327. X    register int i;
  328. X    unsigned long work[2];         /* Working data storage */
  329. X    long tmp;
  330. X
  331. X    permute(block,iperm,(char *)work);    /* Initial Permutation */
  332. X#ifdef LITTLE_ENDIAN
  333. X    work[0] = byteswap(work[0]);
  334. X    work[1] = byteswap(work[1]);
  335. X#endif
  336. X
  337. X    /* Do the 16 rounds */
  338. X    for (i=0; i<16; i++)
  339. X        round(i,work);
  340. X
  341. X    /* Left/right half swap */
  342. X    tmp = work[0];
  343. X    work[0] = work[1];    
  344. X    work[1] = tmp;
  345. X
  346. X#ifdef LITTLE_ENDIAN
  347. X    work[0] = byteswap(work[0]);
  348. X    work[1] = byteswap(work[1]);
  349. X#endif
  350. X    permute((char *)work,fperm,block);    /* Inverse initial permutation */
  351. X}
  352. X/* In-place decryption of 64-bit block */
  353. dedes(block)
  354. char *block;
  355. X{
  356. X    register int i;
  357. X    unsigned long work[2];    /* Working data storage */
  358. X    long tmp;
  359. X
  360. X    permute(block,iperm,(char *)work);    /* Initial permutation */
  361. X
  362. X#ifdef LITTLE_ENDIAN
  363. X    work[0] = byteswap(work[0]);
  364. X    work[1] = byteswap(work[1]);
  365. X#endif
  366. X
  367. X    /* Left/right half swap */
  368. X    tmp = work[0];
  369. X    work[0] = work[1];    
  370. X    work[1] = tmp;
  371. X
  372. X    /* Do the 16 rounds in reverse order */
  373. X    for (i=15; i >= 0; i--)
  374. X        round(i,work);
  375. X
  376. X#ifdef LITTLE_ENDIAN
  377. X    work[0] = byteswap(work[0]);
  378. X    work[1] = byteswap(work[1]);
  379. X#endif
  380. X
  381. X    permute((char *)work,fperm,block);    /* Inverse initial permutation */
  382. X}
  383. X
  384. X/* Permute inblock with perm */
  385. static
  386. permute(inblock,perm,outblock)
  387. char *inblock, *outblock;        /* result into outblock,64 bits */
  388. char perm[16][16][8];            /* 2K bytes defining perm. */
  389. X{
  390. X    register int i,j;
  391. X    register char *ib, *ob;        /* ptr to input or output block */
  392. X    register char *p, *q;
  393. X
  394. X    if(perm == NULL){
  395. X        /* No permutation, just copy */
  396. X        for(i=8; i!=0; i--)
  397. X            *outblock++ = *inblock++;
  398. X        return;
  399. X    }
  400. X    /* Clear output block     */
  401. X    for (i=8, ob = outblock; i != 0; i--)
  402. X        *ob++ = 0;
  403. X
  404. X    ib = inblock;
  405. X    for (j = 0; j < 16; j += 2, ib++) { /* for each input nibble */
  406. X        ob = outblock;
  407. X        p = perm[j][(*ib >> 4) & 017];
  408. X        q = perm[j + 1][*ib & 017];
  409. X        for (i = 8; i != 0; i--){   /* and each output byte */
  410. X            *ob++ |= *p++ | *q++;    /* OR the masks together*/
  411. X        }
  412. X    }
  413. X}
  414. X
  415. X/* Do one DES cipher round */
  416. static
  417. round(num,block)
  418. int num;                /* i.e. the num-th one     */
  419. unsigned long *block;
  420. X{
  421. X    long f();
  422. X
  423. X    /* The rounds are numbered from 0 to 15. On even rounds
  424. X     * the right half is fed to f() and the result exclusive-ORs
  425. X     * the left half; on odd rounds the reverse is done.
  426. X     */
  427. X    if(num & 1){
  428. X        block[1] ^= f(block[0],kn[num]);
  429. X    } else {
  430. X        block[0] ^= f(block[1],kn[num]);
  431. X    }
  432. X}
  433. X/* The nonlinear function f(r,k), the heart of DES */
  434. static
  435. long
  436. f(r,subkey)
  437. unsigned long r;        /* 32 bits */
  438. unsigned char subkey[8];    /* 48-bit key for this round */
  439. X{
  440. X    register unsigned long rval,rt;
  441. X#ifdef    TRACE
  442. X    unsigned char *cp;
  443. X    int i;
  444. X
  445. X    printf("f(%08lx, %02x %02x %02x %02x %02x %02x %02x %02x) = ",
  446. X        r,
  447. X        subkey[0], subkey[1], subkey[2],
  448. X        subkey[3], subkey[4], subkey[5],
  449. X        subkey[6], subkey[7]);
  450. X#endif
  451. X    /* Run E(R) ^ K through the combined S & P boxes
  452. X     * This code takes advantage of a convenient regularity in
  453. X     * E, namely that each group of 6 bits in E(R) feeding
  454. X     * a single S-box is a contiguous segment of R.
  455. X     */
  456. X    rt = (r >> 1) | ((r & 1) ? 0x80000000 : 0);
  457. X    rval = 0;
  458. X    rval |= sp[0][((rt >> 26) ^ *subkey++) & 0x3f];
  459. X    rval |= sp[1][((rt >> 22) ^ *subkey++) & 0x3f];
  460. X    rval |= sp[2][((rt >> 18) ^ *subkey++) & 0x3f];
  461. X    rval |= sp[3][((rt >> 14) ^ *subkey++) & 0x3f];
  462. X    rval |= sp[4][((rt >> 10) ^ *subkey++) & 0x3f];
  463. X    rval |= sp[5][((rt >> 6) ^ *subkey++) & 0x3f];
  464. X    rval |= sp[6][((rt >> 2) ^ *subkey++) & 0x3f];
  465. X    rt = (r << 1) | ((r & 0x80000000) ? 1 : 0);
  466. X    rval |= sp[7][(rt ^ *subkey) & 0x3f];
  467. X#ifdef    TRACE
  468. X    printf(" %08lx\n",rval);
  469. X#endif
  470. X    return rval;
  471. X}
  472. X/* initialize a perm array */
  473. static
  474. perminit(perm,p)
  475. char perm[16][16][8];            /* 64-bit, either init or final */
  476. char p[64];
  477. X{
  478. X    register int l, j, k;
  479. X    int i,m;
  480. X
  481. X    /* Clear the permutation array */
  482. X    for (i=0; i<16; i++)
  483. X        for (j=0; j<16; j++)
  484. X            for (k=0; k<8; k++)
  485. X                perm[i][j][k]=0;
  486. X
  487. X    for (i=0; i<16; i++)        /* each input nibble position */
  488. X        for (j = 0; j < 16; j++)/* each possible input nibble */
  489. X        for (k = 0; k < 64; k++)/* each output bit position */
  490. X        {   l = p[k] - 1;    /* where does this bit come from*/
  491. X            if ((l >> 2) != i)  /* does it come from input posn?*/
  492. X            continue;    /* if not, bit k is 0     */
  493. X            if (!(j & nibblebit[l & 3]))
  494. X            continue;    /* any such bit in input? */
  495. X            m = k & 07;    /* which bit is this in the byte*/
  496. X            perm[i][j][k>>3] |= bytebit[m];
  497. X        }
  498. X}
  499. X
  500. X/* Initialize the lookup table for the combined S and P boxes */
  501. static int
  502. spinit()
  503. X{
  504. X    char pbox[32];
  505. X    int p,i,s,j,rowcol;
  506. X    long val;
  507. X
  508. X    /* Compute pbox, the inverse of p32i.
  509. X     * This is easier to work with
  510. X     */
  511. X    for(p=0;p<32;p++){
  512. X        for(i=0;i<32;i++){
  513. X            if(p32i[i]-1 == p){
  514. X                pbox[p] = i;
  515. X                break;
  516. X            }
  517. X        }
  518. X    }
  519. X    for(s = 0; s < 8; s++){            /* For each S-box */
  520. X        for(i=0; i<64; i++){        /* For each possible input */
  521. X            val = 0;
  522. X            /* The row number is formed from the first and last
  523. X             * bits; the column number is from the middle 4
  524. X             */
  525. X            rowcol = (i & 32) | ((i & 1) ? 16 : 0) | ((i >> 1) & 0xf);
  526. X            for(j=0;j<4;j++){    /* For each output bit */
  527. X                if(si[s][rowcol] & (8 >> j)){
  528. X                 val |= 1L << (31 - pbox[4*s + j]);
  529. X                }
  530. X            }
  531. X            sp[s][i] = val;
  532. X
  533. X#ifdef    DEBUG
  534. X            printf("sp[%d][%2d] = %08lx\n",s,i,sp[s][i]);
  535. X#endif
  536. X        }
  537. X    }
  538. X}
  539. X#ifdef    LITTLE_ENDIAN
  540. X/* Byte swap a long */
  541. static
  542. unsigned long
  543. byteswap(x)
  544. unsigned long x;
  545. X{
  546. X    register char *cp,tmp;
  547. X
  548. X    cp = (char *)&x;
  549. X    tmp = cp[3];
  550. X    cp[3] = cp[0];
  551. X    cp[0] = tmp;
  552. X
  553. X    tmp = cp[2];
  554. X    cp[2] = cp[1];
  555. X    cp[1] = tmp;
  556. X
  557. X    return x;
  558. X}
  559. X#endif
  560. END_OF_FILE
  561. if test 13388 -ne `wc -c <'des/des.c'`; then
  562.     echo shar: \"'des/des.c'\" unpacked with wrong size!
  563. fi
  564. # end of 'des/des.c'
  565. fi
  566. echo shar: End of archive 3 \(of 4\).
  567. cp /dev/null ark3isdone
  568. MISSING=""
  569. for I in 1 2 3 4 ; do
  570.     if test ! -f ark${I}isdone ; then
  571.     MISSING="${MISSING} ${I}"
  572.     fi
  573. done
  574. if test "${MISSING}" = "" ; then
  575.     echo You have unpacked all 4 archives.
  576.     rm -f ark[1-9]isdone
  577. else
  578.     echo You still need to unpack the following archives:
  579.     echo "        " ${MISSING}
  580. fi
  581. ##  End of shell archive.
  582. exit 0
  583.