home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume29 / libdes / patch01 < prev    next >
Encoding:
Internet Message Format  |  1992-04-15  |  53.7 KB

  1. From: eay@psych.psy.uq.oz.au (Eric Young)
  2. Newsgroups: comp.sources.misc
  3. Subject: v29i074: libdes - DES encryption library, Patch01
  4. Message-ID: <1992Apr15.094827.25293@aber.ac.uk>
  5. Date: 15 Apr 92 09:48:27 GMT
  6. Approved: aem@aber.ac.uk
  7. X-Md4-Signature: 0aeffb6027240d3c49748f8196918267
  8.  
  9. Submitted-by: eay@psych.psy.uq.oz.au (Eric Young)
  10. Posting-number: Volume 29, Issue 74
  11. Archive-name: libdes/patch01
  12. Environment: UNIX
  13. Patch-To: libdes: Volume 29, Issue 43-46
  14.  
  15. This is a patch file that incorporates suggestions I have received
  16. since libdes was first posted.
  17.  
  18. to apply the patch, run the following
  19.  
  20. /bin/rm sp.h
  21. patch -p1 <patch1
  22.  
  23. - Makefile support for installation
  24. - Posix/SYSV support, for systems without bcopy, bzero etc.
  25. - des(1) has been given new options allowing the use of keys longer
  26.   than 8 bytes.
  27. - Modifications so libdes should compile under VMS
  28. - Changes to speed.c so that it should compile on systems without
  29.   SIGALRM and can be build on systems without times(3).
  30. - A 5% speedup (on a sparc2) in ecb_encrypt().
  31.  
  32. diff -r -c old/INSTALLATION new/INSTALLATION
  33. *** old/INSTALLATION    Mon Apr 13 10:05:17 1992
  34. --- new/INSTALLATION    Mon Apr 13 12:44:24 1992
  35. ***************
  36. *** 1,22 ****
  37.   Check the CC and CFLAGS lines in the makefile
  38. - Check the HZ value for the times(3) function.  If it is not 60 then
  39. - you will need to change its value in speed.c
  40.   
  41. ! If possible use gcc v 2.0.
  42.   Turn on the maximum optimising
  43.   
  44. ! type './make'
  45.   
  46.   run './destest' to check things are ok.
  47.   run './rpw' to check the tty code for reading passwords works.
  48.   run './speed' to see how fast those optimisations make the library run :-)
  49.   
  50. ! You will need to install by hand
  51. ! libdes.a      to /usr/local/lib/libdes.a
  52. ! des.h         to /usr/include/des.h
  53. ! des          to /usr/local/bin/des
  54. ! des_crypt.man to /usr/local/man/man3/des_crypt.3
  55. ! des.man       to /usr/local/man/man1/des.1
  56.   
  57.   des(1) should be compatable with sunOS's but I have been unable to
  58.   test it.
  59. --- 1,27 ----
  60.   Check the CC and CFLAGS lines in the makefile
  61.   
  62. ! If your C library does not suport the times(3) function, change the
  63. ! #define TIMES to
  64. ! #undef TIMES in speed.c
  65. ! If it does, check the HZ value for the times(3) function.
  66. ! If your system does not define CLK_TCK it will be assumed to
  67. ! be 60.
  68. ! If possible use gcc v 2.1.
  69.   Turn on the maximum optimising
  70.   
  71. ! type 'make'
  72.   
  73.   run './destest' to check things are ok.
  74.   run './rpw' to check the tty code for reading passwords works.
  75.   run './speed' to see how fast those optimisations make the library run :-)
  76.   
  77. ! A make install will by default install
  78. ! libdes.a      in /usr/local/lib/libdes.a
  79. ! des           in /usr/local/bin/des
  80. ! des_crypt.man in /usr/local/man/man3/des_crypt.3
  81. ! des.man       in /usr/local/man/man1/des.1
  82. ! des.h         in /usr/include/des.h
  83.   
  84.   des(1) should be compatable with sunOS's but I have been unable to
  85.   test it.
  86. Only in old: MANIFEST
  87. diff -r -c old/README new/README
  88. *** old/README    Mon Apr 13 10:05:18 1992
  89. --- new/README    Mon Apr 13 12:17:38 1992
  90. ***************
  91. *** 12,22 ****
  92.   destest should be run after compilation to test the des routines.
  93.   rpw should be run after compilation to test the read password routines.
  94.   The des program is a replacement for the sun des command.  I believe it
  95. ! conforms to the sun binary but I am unable to test it.
  96.   
  97.   The Imakefile is setup for use in the kerberos distribution.
  98.   
  99. ! These routines are best compiled with gcc v 2.0 or any other good
  100.   optimising compiler.
  101.   Just turn you optimiser up to the highest settings and run destest
  102.   after the build to make sure everything works.
  103. --- 12,22 ----
  104.   destest should be run after compilation to test the des routines.
  105.   rpw should be run after compilation to test the read password routines.
  106.   The des program is a replacement for the sun des command.  I believe it
  107. ! conforms to the sun binary.
  108.   
  109.   The Imakefile is setup for use in the kerberos distribution.
  110.   
  111. ! These routines are best compiled with gcc v 2.1 or any other good
  112.   optimising compiler.
  113.   Just turn you optimiser up to the highest settings and run destest
  114.   after the build to make sure everything works.
  115. ***************
  116. *** 24,30 ****
  117.   I believe these routines are about the fastest DES routines that use
  118.   small lookup tables (4.5k) that are publicly available.
  119.   The fcrypt routine is faster than ufc's fcrypt (when compiling with
  120. ! gcc2 -O2) on the sparc 2 (1340 vs 1270) but is not so good on other machines
  121.   (on a sun3/260 168 vs 336).
  122.   
  123.   Eric Young (eay@psych.psy.uq.oz.au)
  124. --- 24,30 ----
  125.   I believe these routines are about the fastest DES routines that use
  126.   small lookup tables (4.5k) that are publicly available.
  127.   The fcrypt routine is faster than ufc's fcrypt (when compiling with
  128. ! gcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines
  129.   (on a sun3/260 168 vs 336).
  130.   
  131.   Eric Young (eay@psych.psy.uq.oz.au)
  132. diff -r -c old/VERSION new/VERSION
  133. *** old/VERSION    Mon Apr 13 10:05:19 1992
  134. --- new/VERSION    Mon Apr 13 12:20:26 1992
  135. ***************
  136. *** 1,4 ****
  137. ! Version 1.9 24/03/91 eay
  138.       Now contains a fast small crypt replacement.
  139.       Added des(1) command.
  140.       Added des_rw_mode so people can use cbc encryption with
  141. --- 1,20 ----
  142. ! Version 1.92 13/04/92 eay
  143. !     Changed D_ENCRYPT so that the rotation of R occures outside of
  144. !      the loop.  This required rotating all the longs in sp.h (now
  145. !      called spr.h). Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
  146. !     speed.c has been changed so it will work without SIGALRM.  If
  147. !      times(3) is not present it will try to use ftime() instead.
  148. ! Version 1.91 08/04/92 eay
  149. !     Added -E/-D options to des(1) so it can use string_to_key.
  150. !     Added SVR4 mods suggested by witr@rwwa.COM
  151. !     Added VMS mods suggested by brennan@coco.cchs.su.oz.AU.  If
  152. !     anyone knows how to turn of tty echo in VMS please tell me or
  153. !     implement it yourself :-).
  154. !     Changed FILE *IN/*OUT to *DES_IN/*DES_OUT since it appears VMS
  155. !     does not like IN/OUT being used.
  156. ! Version 1.9 24/03/92 eay
  157.       Now contains a fast small crypt replacement.
  158.       Added des(1) command.
  159.       Added des_rw_mode so people can use cbc encryption with
  160. diff -r -c old/des.c new/des.c
  161. *** old/des.c    Mon Apr 13 10:05:27 1992
  162. --- new/des.c    Wed Apr  8 10:49:03 1992
  163. ***************
  164. *** 1,16 ****
  165.   /* des.c */
  166.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  167.   #include <stdio.h>
  168.   #include <sys/types.h>
  169.   #include <sys/stat.h>
  170.   #include "des.h"
  171.   
  172.   #define VERIFY  1
  173.   #define KEYSIZ    8
  174. ! char key[KEYSIZ+1];
  175. ! int encrypt;
  176.   char *in=NULL,*out=NULL;
  177. ! FILE *IN,*OUT;
  178.   
  179.   int eflag,dflag,kflag,bflag,fflag,sflag,error;
  180.   
  181. --- 1,31 ----
  182.   /* des.c */
  183.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  184.   #include <stdio.h>
  185. + #ifdef VMS
  186. + #include <types.h>
  187. + #include <stat.h>
  188. + #else
  189.   #include <sys/types.h>
  190.   #include <sys/stat.h>
  191. + #endif
  192.   #include "des.h"
  193.   
  194. + #if defined(__STDC__) || defined(VMS)
  195. + #include <string.h>
  196. + #define bcopy(f,t,n)    memcpy(t,f,(size_t)(n))
  197. + #define bzero(s,n)    memset(s,0,(size_t)(n))
  198. + #define bcmp(a,b,n)    memcmp(a, b,(size_t)(n))
  199. + #define index(s,c)    strchr(s,c)
  200. + #endif
  201.   #define VERIFY  1
  202.   #define KEYSIZ    8
  203. ! #define KEYSIZB 1024 /* should hit tty line limit first :-) */
  204. ! char key[KEYSIZB+1];
  205. ! int encrypt,longk=0;
  206.   char *in=NULL,*out=NULL;
  207. ! FILE *DES_IN,*DES_OUT;
  208.   
  209.   int eflag,dflag,kflag,bflag,fflag,sflag,error;
  210.   
  211. ***************
  212. *** 22,28 ****
  213.       struct stat ins,outs;
  214.   
  215.       eflag=dflag=kflag=bflag=fflag=sflag=0,error=0;
  216. !     memset(key,0,sizeof(key));
  217.   
  218.       for (i=1; i<argc; i++)
  219.           {
  220. --- 37,43 ----
  221.       struct stat ins,outs;
  222.   
  223.       eflag=dflag=kflag=bflag=fflag=sflag=0,error=0;
  224. !     bzero(key,sizeof(key));
  225.   
  226.       for (i=1; i<argc; i++)
  227.           {
  228. ***************
  229. *** 34,42 ****
  230. --- 49,65 ----
  231.               case 'e':
  232.                   eflag=1;
  233.                   break;
  234. +             case 'E':
  235. +                 eflag=1;
  236. +                 longk=1;
  237. +                 break;
  238.               case 'd':
  239.                   dflag=1;
  240.                   break;
  241. +             case 'D':
  242. +                 dflag=1;
  243. +                 longk=1;
  244. +                 break;
  245.               case 'b':
  246.                   bflag=1;
  247.                   break;
  248. ***************
  249. *** 58,64 ****
  250.                       int j;
  251.   
  252.                       i++;
  253. !                     strncpy(key,argv[i],KEYSIZ);
  254.                       for (j=strlen(argv[i])-1; j>=0; j--)
  255.                           argv[i][j]='\0';
  256.                       }
  257. --- 81,87 ----
  258.                       int j;
  259.   
  260.                       i++;
  261. !                     strncpy(key,argv[i],KEYSIZB);
  262.                       for (j=strlen(argv[i])-1; j>=0; j--)
  263.                           argv[i][j]='\0';
  264.                       }
  265. ***************
  266. *** 100,106 ****
  267.               }
  268.   
  269.       if (!kflag)
  270. !         if (des_read_pw_string(key,KEYSIZ+1,"Enter key:",eflag?VERIFY:0))
  271.               {
  272.               fputs("password error\n",stderr);
  273.               exit(2);
  274. --- 123,129 ----
  275.               }
  276.   
  277.       if (!kflag)
  278. !         if (des_read_pw_string(key,KEYSIZB+1,"Enter key:",eflag?VERIFY:0))
  279.               {
  280.               fputs("password error\n",stderr);
  281.               exit(2);
  282. ***************
  283. *** 107,114 ****
  284.               }
  285.   
  286.       if (in == NULL)
  287. !         IN=stdin;
  288. !     else if ((IN=fopen(in,"r")) == NULL)
  289.           {
  290.           perror("opening input file");
  291.           exit(4);
  292. --- 130,137 ----
  293.               }
  294.   
  295.       if (in == NULL)
  296. !         DES_IN=stdin;
  297. !     else if ((DES_IN=fopen(in,"r")) == NULL)
  298.           {
  299.           perror("opening input file");
  300.           exit(4);
  301. ***************
  302. *** 115,122 ****
  303.           }
  304.   
  305.       if (out == NULL)
  306. !         OUT=stdout;
  307. !     else if ((OUT=fopen(out,"w")) == NULL)
  308.           {
  309.           perror("opening output file");
  310.           exit(5);
  311. --- 138,145 ----
  312.           }
  313.   
  314.       if (out == NULL)
  315. !         DES_OUT=stdout;
  316. !     else if ((DES_OUT=fopen(out,"w")) == NULL)
  317.           {
  318.           perror("opening output file");
  319.           exit(5);
  320. ***************
  321. *** 123,136 ****
  322.           }
  323.   
  324.       doencryption();
  325. !     fclose(IN);
  326. !     fclose(OUT);
  327.       exit(0);
  328.       }
  329.   
  330.   usage()
  331.       {
  332. !     fputs("des -e | -d [ -bfs ] [ -k key ] [ input-file [ output-file]\n",
  333.           stderr);
  334.       exit(1);
  335.       }
  336. --- 146,159 ----
  337.           }
  338.   
  339.       doencryption();
  340. !     fclose(DES_IN);
  341. !     fclose(DES_OUT);
  342.       exit(0);
  343.       }
  344.   
  345.   usage()
  346.       {
  347. !     fputs("des (-e|-E) | (-d|-D) [ -bfs ] [ -k key ] [ input-file [ output-file]\n",
  348.           stderr);
  349.       exit(1);
  350.       }
  351. ***************
  352. *** 142,165 ****
  353.       des_key_schedule ks;
  354.       char iv[8];
  355.       int i,j,k,l,ll,last,ex=0;
  356.   
  357. !     for (i=0; i<KEYSIZ; i++)
  358.           {
  359. !         l=0;
  360. !         k=key[i];
  361. !         for (j=0; j<8; j++)
  362.               {
  363. !             if (k&1) l++;
  364. !             k>>=1;
  365.               }
  366. -         if (l & 1)
  367. -             key[i]=key[i]&0x7f;
  368. -         else
  369. -             key[i]=key[i]|0x80;
  370. -         }
  371.   
  372. !     des_set_key(key,ks);
  373. !     memset(key,0,sizeof(key));
  374.   
  375.       l=1;
  376.       /* first read */
  377. --- 165,195 ----
  378.       des_key_schedule ks;
  379.       char iv[8];
  380.       int i,j,k,l,ll,last,ex=0;
  381. +     des_cblock kk;
  382.   
  383. !     if (longk)
  384.           {
  385. !         des_string_to_key(key,kk);
  386. !         }
  387. !     else
  388. !         for (i=0; i<KEYSIZ; i++)
  389.               {
  390. !             l=0;
  391. !             k=key[i];
  392. !             for (j=0; j<8; j++)
  393. !                 {
  394. !                 if (k&1) l++;
  395. !                 k>>=1;
  396. !                 }
  397. !             if (l & 1)
  398. !                 kk[i]=key[i]&0x7f;
  399. !             else
  400. !                 kk[i]=key[i]|0x80;
  401.               }
  402.   
  403. !     des_set_key(kk,ks);
  404. !     bzero(key,sizeof(key));
  405. !     bzero(kk,sizeof(kk));
  406.   
  407.       l=1;
  408.       /* first read */
  409. ***************
  410. *** 167,173 ****
  411.           {
  412.           for (;;)
  413.               {
  414. !             l=fread(buf,1,1024*8,IN);
  415.               if (l < 0)
  416.                   {
  417.                   perror("read error");
  418. --- 197,203 ----
  419.           {
  420.           for (;;)
  421.               {
  422. !             l=fread(buf,1,1024*8,DES_IN);
  423.               if (l < 0)
  424.                   {
  425.                   perror("read error");
  426. ***************
  427. *** 174,180 ****
  428.                   exit(6);
  429.                   }
  430.   
  431. !             if (feof(IN))
  432.                   {
  433.                   last=l%8;
  434.                   srand(time(NULL));
  435. --- 204,210 ----
  436.                   exit(6);
  437.                   }
  438.   
  439. !             if (feof(DES_IN))
  440.                   {
  441.                   last=l%8;
  442.                   srand(time(NULL));
  443. ***************
  444. *** 201,207 ****
  445.               i=0;
  446.               while (i != l)
  447.                   {
  448. !                 j=fwrite(obuf,1,l-i,OUT);
  449.                   if (j == -1)
  450.                       {
  451.                       perror("Write error");
  452. --- 231,237 ----
  453.               i=0;
  454.               while (i != l)
  455.                   {
  456. !                 j=fwrite(obuf,1,l-i,DES_OUT);
  457.                   if (j == -1)
  458.                       {
  459.                       perror("Write error");
  460. ***************
  461. *** 209,215 ****
  462.                       }
  463.                   i+=j;
  464.                   }
  465. !             if (feof(IN)) break;
  466.               }
  467.           }
  468.       else /* decrypt */
  469. --- 239,245 ----
  470.                       }
  471.                   i+=j;
  472.                   }
  473. !             if (feof(DES_IN)) break;
  474.               }
  475.           }
  476.       else /* decrypt */
  477. ***************
  478. *** 218,224 ****
  479.           for (;;)
  480.               {
  481.               if (ex) {
  482. !                 l=fread(buf,1,1024*8,IN);
  483.                   ex=0;
  484.                   }
  485.               if (l < 0)
  486. --- 248,254 ----
  487.           for (;;)
  488.               {
  489.               if (ex) {
  490. !                 l=fread(buf,1,1024*8,DES_IN);
  491.                   ex=0;
  492.                   }
  493.               if (l < 0)
  494. ***************
  495. *** 241,248 ****
  496.                   if (l >= 8) bcopy(&(buf[l-8]),iv,8);
  497.                   }
  498.   
  499. !             if (!ex) ll=fread(buf,1,1024*8,IN);
  500. !             if (feof(IN) && (ll == 0))
  501.                   {
  502.                   last=obuf[l-1];
  503.                   if ((last > 7) || (last < 0))
  504. --- 271,278 ----
  505.                   if (l >= 8) bcopy(&(buf[l-8]),iv,8);
  506.                   }
  507.   
  508. !             ll=fread(buf,1,1024*8,DES_IN);
  509. !             if (feof(DES_IN) && (ll == 0))
  510.                   {
  511.                   last=obuf[l-1];
  512.                   if ((last > 7) || (last < 0))
  513. ***************
  514. *** 256,262 ****
  515.               i=0;
  516.               while (i != l)
  517.                   {
  518. !                 j=fwrite(obuf,1,l-i,OUT);
  519.                   if (j == -1)
  520.                       {
  521.                       perror("Write error");
  522. --- 286,292 ----
  523.               i=0;
  524.               while (i != l)
  525.                   {
  526. !                 j=fwrite(obuf,1,l-i,DES_OUT);
  527.                   if (j == -1)
  528.                       {
  529.                       perror("Write error");
  530. ***************
  531. *** 265,271 ****
  532.                   i+=j;
  533.                   }
  534.               l=ll;
  535. !             if ((l == 0) && feof(IN)) break;
  536.               }
  537.           }
  538.       }
  539. --- 295,301 ----
  540.                   i+=j;
  541.                   }
  542.               l=ll;
  543. !             if ((l == 0) && feof(DES_IN)) break;
  544.               }
  545.           }
  546.       }
  547. diff -r -c old/des.man new/des.man
  548. *** old/des.man    Mon Apr 13 10:05:20 1992
  549. --- new/des.man    Mon Apr 13 12:52:50 1992
  550. ***************
  551. *** 3,11 ****
  552. --- 3,17 ----
  553.   des - encrypt or decrypt data using Data Encryption Standard
  554.   .SH SYNOPSIS
  555.   .B des
  556. + (
  557.   .B \-e
  558.   |
  559. + .B \-E
  560. + ) | (
  561.   .B \-d
  562. + |
  563. + .B \-D
  564. + )
  565.   [
  566.   .B \-bfs
  567.   ] [
  568. ***************
  569. *** 21,29 ****
  570.   encrypts and decrypts data using the
  571.   Data Encryption Standard algorithm.
  572.   One of
  573. ! .B \-e
  574.   (for encrypt) or
  575. ! .B \-d
  576.   (for decrypt) must be specified.
  577.   .LP
  578.   Two standard encryption modes are supported by the
  579. --- 27,35 ----
  580.   encrypts and decrypts data using the
  581.   Data Encryption Standard algorithm.
  582.   One of
  583. ! .B \-e, \-E
  584.   (for encrypt) or
  585. ! .B \-d, \-D
  586.   (for decrypt) must be specified.
  587.   .LP
  588.   Two standard encryption modes are supported by the
  589. ***************
  590. *** 37,43 ****
  591.   .B DES
  592.   algorithm is obtained by prompting the user unless the
  593.   .B `\-k
  594. ! .I key '
  595.   option is given.
  596.   If the key is an argument to the
  597.   .B des
  598. --- 43,49 ----
  599.   .B DES
  600.   algorithm is obtained by prompting the user unless the
  601.   .B `\-k
  602. ! .I key'
  603.   option is given.
  604.   If the key is an argument to the
  605.   .B des
  606. ***************
  607. *** 62,72 ****
  608.   Select ECB
  609.   (eight bytes at a time) encryption mode.
  610.   .TP
  611.   .B \-d
  612. ! Decrypt data.
  613.   .TP
  614. ! .B \-e
  615. ! Encrypt data.
  616.   .TP
  617.   .B \-f
  618.   Does nothing - allowed for compatibility with sunOS des(1) command.
  619. --- 68,86 ----
  620.   Select ECB
  621.   (eight bytes at a time) encryption mode.
  622.   .TP
  623. + .B \-e
  624. + Encrypt data using an 8 byte key in a maner compatible with sunOS
  625. + des(1).
  626. + .TP
  627. + .B \-E
  628. + Encrypt data using a key of nearly unlimited length (1024 bytes).
  629. + This will product a more secure encryption.
  630. + .TP
  631.   .B \-d
  632. ! Decrypt data that was encrypted with the \-e option.
  633.   .TP
  634. ! .B \-D
  635. ! Decrypt data that was encrypted with the \-E option.
  636.   .TP
  637.   .B \-f
  638.   Does nothing - allowed for compatibility with sunOS des(1) command.
  639. ***************
  640. *** 74,80 ****
  641.   .B \-s
  642.   Does nothing - allowed for compatibility with sunOS des(1) command.
  643.   .TP
  644. ! .I \-k " key"
  645.   Use the encryption 
  646.   .I key
  647.   specified.
  648. --- 88,94 ----
  649.   .B \-s
  650.   Does nothing - allowed for compatibility with sunOS des(1) command.
  651.   .TP
  652. ! .I "\-k key"
  653.   Use the encryption 
  654.   .I key
  655.   specified.
  656. ***************
  657. *** 83,93 ****
  658.   .B des_crypt(3)
  659.   .SH BUGS
  660.   .LP
  661.   It would be better to use a real 56-bit key rather than an
  662. ! ASCII-based
  663. ! 56-bit pattern.  Knowing that the key was derived from ASCII
  664. ! radically reduces
  665. ! the time necessary for a brute-force cryptographic attack.
  666.   .SH AUTHOR
  667.   .LP
  668.   Eric Young (eay@psych.psy.uq.oz.au), Psychology Department,
  669. --- 97,115 ----
  670.   .B des_crypt(3)
  671.   .SH BUGS
  672.   .LP
  673. + The problem with using the
  674. + .B -e
  675. + option is the short key length.
  676.   It would be better to use a real 56-bit key rather than an
  677. ! ASCII-based 56-bit pattern.  Knowing that the key was derived from ASCII
  678. ! radically reduces the time necessary for a brute-force cryptographic attack.
  679. ! My attempt to remove this problem is to add an alternative text-key to
  680. ! DES-key function.  This alternative function (accessed via
  681. ! .B -E
  682. ! and
  683. ! .B -D
  684. ! )
  685. ! used DES to help generate the key.
  686.   .SH AUTHOR
  687.   .LP
  688.   Eric Young (eay@psych.psy.uq.oz.au), Psychology Department,
  689. diff -r -c old/des_local.h new/des_local.h
  690. *** old/des_local.h    Mon Apr 13 10:05:21 1992
  691. --- new/des_local.h    Wed Apr  8 09:48:23 1992
  692. ***************
  693. *** 3,8 ****
  694. --- 3,16 ----
  695.   #include <stdio.h>
  696.   #include "des.h"
  697.   
  698. + #if defined(__STDC__) || defined(VMS)
  699. + #include <string.h>
  700. + #define bcopy(b1,b2,len) memcpy(b2, b1, (size_t)(len))
  701. + #define bzero(b,len) memset(b, 0, (size_t)(len))
  702. + #define bcmp(b1,b2,len) memcmp(b1, b2, (size_t)(len))
  703. + #define index(s1,char) strchr(s1,char)
  704. + #endif
  705.   typedef unsigned char uchar;
  706.   typedef unsigned short ushort;
  707.   typedef unsigned int uint;
  708. diff -r -c old/ecb_encrypt.c new/ecb_encrypt.c
  709. *** old/ecb_encrypt.c    Mon Apr 13 10:05:22 1992
  710. --- new/ecb_encrypt.c    Mon Apr 13 12:55:09 1992
  711. ***************
  712. *** 1,7 ****
  713.   /* ecb_encrypt.c */
  714.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  715.   #include "des_local.h"
  716. ! #include "sp.h"
  717.   
  718.   int des_ecb_encrypt(input,output,ks,encrypt)
  719.   des_cblock *input;
  720. --- 1,7 ----
  721.   /* ecb_encrypt.c */
  722.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  723.   #include "des_local.h"
  724. ! #include "spr.h"
  725.   
  726.   int des_ecb_encrypt(input,output,ks,encrypt)
  727.   des_cblock *input;
  728. ***************
  729. *** 28,36 ****
  730.       }
  731.   
  732.   #define D_ENCRYPT(L,R,S)    \
  733. !     t=(R<<1)|(R>>31); \
  734. !     u=(t^s[S  ]); \
  735. !     t=(t^s[S+1]); \
  736.       t=(t>>4)|(t<<28); \
  737.       L^=    des_SPtrans[1][(t    )&0x3f]| \
  738.           des_SPtrans[3][(t>> 8)&0x3f]| \
  739. --- 28,35 ----
  740.       }
  741.   
  742.   #define D_ENCRYPT(L,R,S)    \
  743. !     u=(R^s[S  ]); \
  744. !     t=(R^s[S+1]); \
  745.       t=(t>>4)|(t<<28); \
  746.       L^=    des_SPtrans[1][(t    )&0x3f]| \
  747.           des_SPtrans[3][(t>> 8)&0x3f]| \
  748. ***************
  749. *** 101,113 ****
  750.       PERM_OP(r,l,t, 2,0x33333333);
  751.       PERM_OP(l,r,t, 8,0x00ff00ff);
  752.       PERM_OP(r,l,t, 1,0x55555555);
  753. !     /* r and l are reversed - remember that :-) */
  754. !     t=l;
  755. !     l=r;
  756. !     r=t;
  757.   
  758. !     s=(ulong *)ks;
  759.   
  760.       /* I don't know if it is worth the effort of loop unrolling the
  761.        * inner loop */
  762.       if (encrypt)
  763. --- 100,119 ----
  764.       PERM_OP(r,l,t, 2,0x33333333);
  765.       PERM_OP(l,r,t, 8,0x00ff00ff);
  766.       PERM_OP(r,l,t, 1,0x55555555);
  767. !     /* r and l are reversed - remember that :-) - fix
  768. !      * it in the next step */
  769.   
  770. !     /* Things have been modified so that the initial rotate is
  771. !      * done outside the loop.  This required the 
  772. !      * des_SPtrans values in sp.h to be rotated 1 bit to the right.
  773. !      * One perl script later and things have a 5% speed up on a sparc2.
  774. !      * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
  775. !      * for pointing this out. */
  776. !     t=(r<<1)|(r>>31);
  777. !     r=(l<<1)|(l>>31); 
  778. !     l=t;
  779.   
  780. +     s=(ulong *)ks;
  781.       /* I don't know if it is worth the effort of loop unrolling the
  782.        * inner loop */
  783.       if (encrypt)
  784. ***************
  785. *** 126,131 ****
  786. --- 132,139 ----
  787.               D_ENCRYPT(r,l,i-2); /* 15 */
  788.               }
  789.           }
  790. +     l=(l>>1)|(l<<31);
  791. +     r=(r>>1)|(r<<31);
  792.   
  793.       /* swap l and r
  794.        * we will not do the swap so just remember they are
  795. diff -r -c old/fcrypt.c new/fcrypt.c
  796. *** old/fcrypt.c    Mon Apr 13 10:05:31 1992
  797. --- new/fcrypt.c    Mon Apr 13 09:59:25 1992
  798. ***************
  799. *** 39,186 ****
  800.   
  801.   static unsigned long SPtrans[8][64]={
  802.   /* nibble 0 */
  803. ! 0x00410100, 0x00010000, 0x40400000, 0x40410100,
  804. ! 0x00400000, 0x40010100, 0x40010000, 0x40400000,
  805. ! 0x40010100, 0x00410100, 0x00410000, 0x40000100,
  806. ! 0x40400100, 0x00400000, 0x00000000, 0x40010000,
  807. ! 0x00010000, 0x40000000, 0x00400100, 0x00010100,
  808. ! 0x40410100, 0x00410000, 0x40000100, 0x00400100,
  809. ! 0x40000000, 0x00000100, 0x00010100, 0x40410000,
  810. ! 0x00000100, 0x40400100, 0x40410000, 0x00000000,
  811. ! 0x00000000, 0x40410100, 0x00400100, 0x40010000,
  812. ! 0x00410100, 0x00010000, 0x40000100, 0x00400100,
  813. ! 0x40410000, 0x00000100, 0x00010100, 0x40400000,
  814. ! 0x40010100, 0x40000000, 0x40400000, 0x00410000,
  815. ! 0x40410100, 0x00010100, 0x00410000, 0x40400100,
  816. ! 0x00400000, 0x40000100, 0x40010000, 0x00000000,
  817. ! 0x00010000, 0x00400000, 0x40400100, 0x00410100,
  818. ! 0x40000000, 0x40410000, 0x00000100, 0x40010100,
  819.   /* nibble 1 */
  820. ! 0x08021002, 0x00000000, 0x00021000, 0x08020000,
  821. ! 0x08000002, 0x00001002, 0x08001000, 0x00021000,
  822. ! 0x00001000, 0x08020002, 0x00000002, 0x08001000,
  823. ! 0x00020002, 0x08021000, 0x08020000, 0x00000002,
  824. ! 0x00020000, 0x08001002, 0x08020002, 0x00001000,
  825. ! 0x00021002, 0x08000000, 0x00000000, 0x00020002,
  826. ! 0x08001002, 0x00021002, 0x08021000, 0x08000002,
  827. ! 0x08000000, 0x00020000, 0x00001002, 0x08021002,
  828. ! 0x00020002, 0x08021000, 0x08001000, 0x00021002,
  829. ! 0x08021002, 0x00020002, 0x08000002, 0x00000000,
  830. ! 0x08000000, 0x00001002, 0x00020000, 0x08020002,
  831. ! 0x00001000, 0x08000000, 0x00021002, 0x08001002,
  832. ! 0x08021000, 0x00001000, 0x00000000, 0x08000002,
  833. ! 0x00000002, 0x08021002, 0x00021000, 0x08020000,
  834. ! 0x08020002, 0x00020000, 0x00001002, 0x08001000,
  835. ! 0x08001002, 0x00000002, 0x08020000, 0x00021000,
  836.   /* nibble 2 */
  837. ! 0x20800000, 0x00808020, 0x00000020, 0x20800020,
  838. ! 0x20008000, 0x00800000, 0x20800020, 0x00008020,
  839. ! 0x00800020, 0x00008000, 0x00808000, 0x20000000,
  840. ! 0x20808020, 0x20000020, 0x20000000, 0x20808000,
  841. ! 0x00000000, 0x20008000, 0x00808020, 0x00000020,
  842. ! 0x20000020, 0x20808020, 0x00008000, 0x20800000,
  843. ! 0x20808000, 0x00800020, 0x20008020, 0x00808000,
  844. ! 0x00008020, 0x00000000, 0x00800000, 0x20008020,
  845. ! 0x00808020, 0x00000020, 0x20000000, 0x00008000,
  846. ! 0x20000020, 0x20008000, 0x00808000, 0x20800020,
  847. ! 0x00000000, 0x00808020, 0x00008020, 0x20808000,
  848. ! 0x20008000, 0x00800000, 0x20808020, 0x20000000,
  849. ! 0x20008020, 0x20800000, 0x00800000, 0x20808020,
  850. ! 0x00008000, 0x00800020, 0x20800020, 0x00008020,
  851. ! 0x00800020, 0x00000000, 0x20808000, 0x20000020,
  852. ! 0x20800000, 0x20008020, 0x00000020, 0x00808000,
  853.   /* nibble 3 */
  854. ! 0x00080201, 0x02000200, 0x00000001, 0x02080201,
  855. ! 0x00000000, 0x02080000, 0x02000201, 0x00080001,
  856. ! 0x02080200, 0x02000001, 0x02000000, 0x00000201,
  857. ! 0x02000001, 0x00080201, 0x00080000, 0x02000000,
  858. ! 0x02080001, 0x00080200, 0x00000200, 0x00000001,
  859. ! 0x00080200, 0x02000201, 0x02080000, 0x00000200,
  860. ! 0x00000201, 0x00000000, 0x00080001, 0x02080200,
  861. ! 0x02000200, 0x02080001, 0x02080201, 0x00080000,
  862. ! 0x02080001, 0x00000201, 0x00080000, 0x02000001,
  863. ! 0x00080200, 0x02000200, 0x00000001, 0x02080000,
  864. ! 0x02000201, 0x00000000, 0x00000200, 0x00080001,
  865. ! 0x00000000, 0x02080001, 0x02080200, 0x00000200,
  866. ! 0x02000000, 0x02080201, 0x00080201, 0x00080000,
  867. ! 0x02080201, 0x00000001, 0x02000200, 0x00080201,
  868. ! 0x00080001, 0x00080200, 0x02080000, 0x02000201,
  869. ! 0x00000201, 0x02000000, 0x02000001, 0x02080200,
  870.   /* nibble 4 */
  871. ! 0x01000000, 0x00002000, 0x00000080, 0x01002084,
  872. ! 0x01002004, 0x01000080, 0x00002084, 0x01002000,
  873. ! 0x00002000, 0x00000004, 0x01000004, 0x00002080,
  874. ! 0x01000084, 0x01002004, 0x01002080, 0x00000000,
  875. ! 0x00002080, 0x01000000, 0x00002004, 0x00000084,
  876. ! 0x01000080, 0x00002084, 0x00000000, 0x01000004,
  877. ! 0x00000004, 0x01000084, 0x01002084, 0x00002004,
  878. ! 0x01002000, 0x00000080, 0x00000084, 0x01002080,
  879. ! 0x01002080, 0x01000084, 0x00002004, 0x01002000,
  880. ! 0x00002000, 0x00000004, 0x01000004, 0x01000080,
  881. ! 0x01000000, 0x00002080, 0x01002084, 0x00000000,
  882. ! 0x00002084, 0x01000000, 0x00000080, 0x00002004,
  883. ! 0x01000084, 0x00000080, 0x00000000, 0x01002084,
  884. ! 0x01002004, 0x01002080, 0x00000084, 0x00002000,
  885. ! 0x00002080, 0x01002004, 0x01000080, 0x00000084,
  886. ! 0x00000004, 0x00002084, 0x01002000, 0x01000004,
  887.   /* nibble 5 */
  888. ! 0x10000008, 0x00040008, 0x00000000, 0x10040400,
  889. ! 0x00040008, 0x00000400, 0x10000408, 0x00040000,
  890. ! 0x00000408, 0x10040408, 0x00040400, 0x10000000,
  891. ! 0x10000400, 0x10000008, 0x10040000, 0x00040408,
  892. ! 0x00040000, 0x10000408, 0x10040008, 0x00000000,
  893. ! 0x00000400, 0x00000008, 0x10040400, 0x10040008,
  894. ! 0x10040408, 0x10040000, 0x10000000, 0x00000408,
  895. ! 0x00000008, 0x00040400, 0x00040408, 0x10000400,
  896. ! 0x00000408, 0x10000000, 0x10000400, 0x00040408,
  897. ! 0x10040400, 0x00040008, 0x00000000, 0x10000400,
  898. ! 0x10000000, 0x00000400, 0x10040008, 0x00040000,
  899. ! 0x00040008, 0x10040408, 0x00040400, 0x00000008,
  900. ! 0x10040408, 0x00040400, 0x00040000, 0x10000408,
  901. ! 0x10000008, 0x10040000, 0x00040408, 0x00000000,
  902. ! 0x00000400, 0x10000008, 0x10000408, 0x10040400,
  903. ! 0x10040000, 0x00000408, 0x00000008, 0x10040008,
  904.   /* nibble 6 */
  905. ! 0x00000800, 0x00000040, 0x00200040, 0x80200000,
  906. ! 0x80200840, 0x80000800, 0x00000840, 0x00000000,
  907. ! 0x00200000, 0x80200040, 0x80000040, 0x00200800,
  908. ! 0x80000000, 0x00200840, 0x00200800, 0x80000040,
  909. ! 0x80200040, 0x00000800, 0x80000800, 0x80200840,
  910. ! 0x00000000, 0x00200040, 0x80200000, 0x00000840,
  911. ! 0x80200800, 0x80000840, 0x00200840, 0x80000000,
  912. ! 0x80000840, 0x80200800, 0x00000040, 0x00200000,
  913. ! 0x80000840, 0x00200800, 0x80200800, 0x80000040,
  914. ! 0x00000800, 0x00000040, 0x00200000, 0x80200800,
  915. ! 0x80200040, 0x80000840, 0x00000840, 0x00000000,
  916. ! 0x00000040, 0x80200000, 0x80000000, 0x00200040,
  917. ! 0x00000000, 0x80200040, 0x00200040, 0x00000840,
  918. ! 0x80000040, 0x00000800, 0x80200840, 0x00200000,
  919. ! 0x00200840, 0x80000000, 0x80000800, 0x80200840,
  920. ! 0x80200000, 0x00200840, 0x00200800, 0x80000800,
  921.   /* nibble 7 */
  922. ! 0x04100010, 0x04104000, 0x00004010, 0x00000000,
  923. ! 0x04004000, 0x00100010, 0x04100000, 0x04104010,
  924. ! 0x00000010, 0x04000000, 0x00104000, 0x00004010,
  925. ! 0x00104010, 0x04004010, 0x04000010, 0x04100000,
  926. ! 0x00004000, 0x00104010, 0x00100010, 0x04004000,
  927. ! 0x04104010, 0x04000010, 0x00000000, 0x00104000,
  928. ! 0x04000000, 0x00100000, 0x04004010, 0x04100010,
  929. ! 0x00100000, 0x00004000, 0x04104000, 0x00000010,
  930. ! 0x00100000, 0x00004000, 0x04000010, 0x04104010,
  931. ! 0x00004010, 0x04000000, 0x00000000, 0x00104000,
  932. ! 0x04100010, 0x04004010, 0x04004000, 0x00100010,
  933. ! 0x04104000, 0x00000010, 0x00100010, 0x04004000,
  934. ! 0x04104010, 0x00100000, 0x04100000, 0x04000010,
  935. ! 0x00104000, 0x00004010, 0x04004010, 0x04100000,
  936. ! 0x00000010, 0x04104000, 0x00104010, 0x00000000,
  937. ! 0x04000000, 0x04100010, 0x00004000, 0x00104010};
  938.   static ulong skb[8][64]={
  939.   /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
  940.   0x00000000,0x00000010,0x20000000,0x20000010,
  941. --- 39,179 ----
  942.   
  943.   static unsigned long SPtrans[8][64]={
  944.   /* nibble 0 */
  945. ! 0x00820200, 0x00020000, 0x80800000, 0x80820200,
  946. ! 0x00800000, 0x80020200, 0x80020000, 0x80800000,
  947. ! 0x80020200, 0x00820200, 0x00820000, 0x80000200,
  948. ! 0x80800200, 0x00800000, 0x00000000, 0x80020000,
  949. ! 0x00020000, 0x80000000, 0x00800200, 0x00020200,
  950. ! 0x80820200, 0x00820000, 0x80000200, 0x00800200,
  951. ! 0x80000000, 0x00000200, 0x00020200, 0x80820000,
  952. ! 0x00000200, 0x80800200, 0x80820000, 0x00000000,
  953. ! 0x00000000, 0x80820200, 0x00800200, 0x80020000,
  954. ! 0x00820200, 0x00020000, 0x80000200, 0x00800200,
  955. ! 0x80820000, 0x00000200, 0x00020200, 0x80800000,
  956. ! 0x80020200, 0x80000000, 0x80800000, 0x00820000,
  957. ! 0x80820200, 0x00020200, 0x00820000, 0x80800200,
  958. ! 0x00800000, 0x80000200, 0x80020000, 0x00000000,
  959. ! 0x00020000, 0x00800000, 0x80800200, 0x00820200,
  960. ! 0x80000000, 0x80820000, 0x00000200, 0x80020200,
  961.   /* nibble 1 */
  962. ! 0x10042004, 0x00000000, 0x00042000, 0x10040000,
  963. ! 0x10000004, 0x00002004, 0x10002000, 0x00042000,
  964. ! 0x00002000, 0x10040004, 0x00000004, 0x10002000,
  965. ! 0x00040004, 0x10042000, 0x10040000, 0x00000004,
  966. ! 0x00040000, 0x10002004, 0x10040004, 0x00002000,
  967. ! 0x00042004, 0x10000000, 0x00000000, 0x00040004,
  968. ! 0x10002004, 0x00042004, 0x10042000, 0x10000004,
  969. ! 0x10000000, 0x00040000, 0x00002004, 0x10042004,
  970. ! 0x00040004, 0x10042000, 0x10002000, 0x00042004,
  971. ! 0x10042004, 0x00040004, 0x10000004, 0x00000000,
  972. ! 0x10000000, 0x00002004, 0x00040000, 0x10040004,
  973. ! 0x00002000, 0x10000000, 0x00042004, 0x10002004,
  974. ! 0x10042000, 0x00002000, 0x00000000, 0x10000004,
  975. ! 0x00000004, 0x10042004, 0x00042000, 0x10040000,
  976. ! 0x10040004, 0x00040000, 0x00002004, 0x10002000,
  977. ! 0x10002004, 0x00000004, 0x10040000, 0x00042000,
  978.   /* nibble 2 */
  979. ! 0x41000000, 0x01010040, 0x00000040, 0x41000040,
  980. ! 0x40010000, 0x01000000, 0x41000040, 0x00010040,
  981. ! 0x01000040, 0x00010000, 0x01010000, 0x40000000,
  982. ! 0x41010040, 0x40000040, 0x40000000, 0x41010000,
  983. ! 0x00000000, 0x40010000, 0x01010040, 0x00000040,
  984. ! 0x40000040, 0x41010040, 0x00010000, 0x41000000,
  985. ! 0x41010000, 0x01000040, 0x40010040, 0x01010000,
  986. ! 0x00010040, 0x00000000, 0x01000000, 0x40010040,
  987. ! 0x01010040, 0x00000040, 0x40000000, 0x00010000,
  988. ! 0x40000040, 0x40010000, 0x01010000, 0x41000040,
  989. ! 0x00000000, 0x01010040, 0x00010040, 0x41010000,
  990. ! 0x40010000, 0x01000000, 0x41010040, 0x40000000,
  991. ! 0x40010040, 0x41000000, 0x01000000, 0x41010040,
  992. ! 0x00010000, 0x01000040, 0x41000040, 0x00010040,
  993. ! 0x01000040, 0x00000000, 0x41010000, 0x40000040,
  994. ! 0x41000000, 0x40010040, 0x00000040, 0x01010000,
  995.   /* nibble 3 */
  996. ! 0x00100402, 0x04000400, 0x00000002, 0x04100402,
  997. ! 0x00000000, 0x04100000, 0x04000402, 0x00100002,
  998. ! 0x04100400, 0x04000002, 0x04000000, 0x00000402,
  999. ! 0x04000002, 0x00100402, 0x00100000, 0x04000000,
  1000. ! 0x04100002, 0x00100400, 0x00000400, 0x00000002,
  1001. ! 0x00100400, 0x04000402, 0x04100000, 0x00000400,
  1002. ! 0x00000402, 0x00000000, 0x00100002, 0x04100400,
  1003. ! 0x04000400, 0x04100002, 0x04100402, 0x00100000,
  1004. ! 0x04100002, 0x00000402, 0x00100000, 0x04000002,
  1005. ! 0x00100400, 0x04000400, 0x00000002, 0x04100000,
  1006. ! 0x04000402, 0x00000000, 0x00000400, 0x00100002,
  1007. ! 0x00000000, 0x04100002, 0x04100400, 0x00000400,
  1008. ! 0x04000000, 0x04100402, 0x00100402, 0x00100000,
  1009. ! 0x04100402, 0x00000002, 0x04000400, 0x00100402,
  1010. ! 0x00100002, 0x00100400, 0x04100000, 0x04000402,
  1011. ! 0x00000402, 0x04000000, 0x04000002, 0x04100400,
  1012.   /* nibble 4 */
  1013. ! 0x02000000, 0x00004000, 0x00000100, 0x02004108,
  1014. ! 0x02004008, 0x02000100, 0x00004108, 0x02004000,
  1015. ! 0x00004000, 0x00000008, 0x02000008, 0x00004100,
  1016. ! 0x02000108, 0x02004008, 0x02004100, 0x00000000,
  1017. ! 0x00004100, 0x02000000, 0x00004008, 0x00000108,
  1018. ! 0x02000100, 0x00004108, 0x00000000, 0x02000008,
  1019. ! 0x00000008, 0x02000108, 0x02004108, 0x00004008,
  1020. ! 0x02004000, 0x00000100, 0x00000108, 0x02004100,
  1021. ! 0x02004100, 0x02000108, 0x00004008, 0x02004000,
  1022. ! 0x00004000, 0x00000008, 0x02000008, 0x02000100,
  1023. ! 0x02000000, 0x00004100, 0x02004108, 0x00000000,
  1024. ! 0x00004108, 0x02000000, 0x00000100, 0x00004008,
  1025. ! 0x02000108, 0x00000100, 0x00000000, 0x02004108,
  1026. ! 0x02004008, 0x02004100, 0x00000108, 0x00004000,
  1027. ! 0x00004100, 0x02004008, 0x02000100, 0x00000108,
  1028. ! 0x00000008, 0x00004108, 0x02004000, 0x02000008,
  1029.   /* nibble 5 */
  1030. ! 0x20000010, 0x00080010, 0x00000000, 0x20080800,
  1031. ! 0x00080010, 0x00000800, 0x20000810, 0x00080000,
  1032. ! 0x00000810, 0x20080810, 0x00080800, 0x20000000,
  1033. ! 0x20000800, 0x20000010, 0x20080000, 0x00080810,
  1034. ! 0x00080000, 0x20000810, 0x20080010, 0x00000000,
  1035. ! 0x00000800, 0x00000010, 0x20080800, 0x20080010,
  1036. ! 0x20080810, 0x20080000, 0x20000000, 0x00000810,
  1037. ! 0x00000010, 0x00080800, 0x00080810, 0x20000800,
  1038. ! 0x00000810, 0x20000000, 0x20000800, 0x00080810,
  1039. ! 0x20080800, 0x00080010, 0x00000000, 0x20000800,
  1040. ! 0x20000000, 0x00000800, 0x20080010, 0x00080000,
  1041. ! 0x00080010, 0x20080810, 0x00080800, 0x00000010,
  1042. ! 0x20080810, 0x00080800, 0x00080000, 0x20000810,
  1043. ! 0x20000010, 0x20080000, 0x00080810, 0x00000000,
  1044. ! 0x00000800, 0x20000010, 0x20000810, 0x20080800,
  1045. ! 0x20080000, 0x00000810, 0x00000010, 0x20080010,
  1046.   /* nibble 6 */
  1047. ! 0x00001000, 0x00000080, 0x00400080, 0x00400001,
  1048. ! 0x00401081, 0x00001001, 0x00001080, 0x00000000,
  1049. ! 0x00400000, 0x00400081, 0x00000081, 0x00401000,
  1050. ! 0x00000001, 0x00401080, 0x00401000, 0x00000081,
  1051. ! 0x00400081, 0x00001000, 0x00001001, 0x00401081,
  1052. ! 0x00000000, 0x00400080, 0x00400001, 0x00001080,
  1053. ! 0x00401001, 0x00001081, 0x00401080, 0x00000001,
  1054. ! 0x00001081, 0x00401001, 0x00000080, 0x00400000,
  1055. ! 0x00001081, 0x00401000, 0x00401001, 0x00000081,
  1056. ! 0x00001000, 0x00000080, 0x00400000, 0x00401001,
  1057. ! 0x00400081, 0x00001081, 0x00001080, 0x00000000,
  1058. ! 0x00000080, 0x00400001, 0x00000001, 0x00400080,
  1059. ! 0x00000000, 0x00400081, 0x00400080, 0x00001080,
  1060. ! 0x00000081, 0x00001000, 0x00401081, 0x00400000,
  1061. ! 0x00401080, 0x00000001, 0x00001001, 0x00401081,
  1062. ! 0x00400001, 0x00401080, 0x00401000, 0x00001001,
  1063.   /* nibble 7 */
  1064. ! 0x08200020, 0x08208000, 0x00008020, 0x00000000,
  1065. ! 0x08008000, 0x00200020, 0x08200000, 0x08208020,
  1066. ! 0x00000020, 0x08000000, 0x00208000, 0x00008020,
  1067. ! 0x00208020, 0x08008020, 0x08000020, 0x08200000,
  1068. ! 0x00008000, 0x00208020, 0x00200020, 0x08008000,
  1069. ! 0x08208020, 0x08000020, 0x00000000, 0x00208000,
  1070. ! 0x08000000, 0x00200000, 0x08008020, 0x08200020,
  1071. ! 0x00200000, 0x00008000, 0x08208000, 0x00000020,
  1072. ! 0x00200000, 0x00008000, 0x08000020, 0x08208020,
  1073. ! 0x00008020, 0x08000000, 0x00000000, 0x00208000,
  1074. ! 0x08200020, 0x08008020, 0x08008000, 0x00200020,
  1075. ! 0x08208000, 0x00000020, 0x00200020, 0x08008000,
  1076. ! 0x08208020, 0x00200000, 0x08200000, 0x08000020,
  1077. ! 0x00208000, 0x00008020, 0x08008020, 0x08200000,
  1078. ! 0x00000020, 0x08208000, 0x00208020, 0x00000000,
  1079. ! 0x08000000, 0x08200020, 0x00008000, 0x00208020};
  1080.   static ulong skb[8][64]={
  1081.   /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
  1082.   0x00000000,0x00000010,0x20000000,0x20000010,
  1083. ***************
  1084. *** 395,406 ****
  1085.    ******************************************************************/
  1086.   
  1087.   #define D_ENCRYPT(L,R,S)    \
  1088. !     t=(R<<1)|(R>>31); \
  1089. !     v=(t^(t>>16)); \
  1090.       u=(v&E0); \
  1091.       v=(v&E1); \
  1092. !     u=(u^(u<<16))^t^s[S  ]; \
  1093. !     t=(v^(v<<16))^t^s[S+1]; \
  1094.       t=(t>>4)|(t<<28); \
  1095.       L^=    SPtrans[1][(t    )&0x3f]| \
  1096.           SPtrans[3][(t>> 8)&0x3f]| \
  1097. --- 388,398 ----
  1098.    ******************************************************************/
  1099.   
  1100.   #define D_ENCRYPT(L,R,S)    \
  1101. !     v=(R^(R>>16)); \
  1102.       u=(v&E0); \
  1103.       v=(v&E1); \
  1104. !     u=(u^(u<<16))^R^s[S  ]; \
  1105. !     t=(v^(v<<16))^R^s[S+1]; \
  1106.       t=(t>>4)|(t<<28); \
  1107.       L^=    SPtrans[1][(t    )&0x3f]| \
  1108.           SPtrans[3][(t>> 8)&0x3f]| \
  1109. ***************
  1110. *** 528,536 ****
  1111.           l=r;
  1112.           r=t;
  1113.           }
  1114. !     t=l;
  1115. !     l=r;
  1116. !     r=t;
  1117.       PERM_OP(r,l,t, 1,0x55555555);
  1118.       PERM_OP(l,r,t, 8,0x00ff00ff);
  1119.       PERM_OP(r,l,t, 2,0x33333333);
  1120. --- 520,529 ----
  1121.           l=r;
  1122.           r=t;
  1123.           }
  1124. !     t=r;
  1125. !     r=(l>>1)|(l<<31);
  1126. !     l=(t>>1)|(t<<31);
  1127.       PERM_OP(r,l,t, 1,0x55555555);
  1128.       PERM_OP(l,r,t, 8,0x00ff00ff);
  1129.       PERM_OP(r,l,t, 2,0x33333333);
  1130. diff -r -c old/makefile new/makefile
  1131. *** old/makefile    Mon Apr 13 10:05:23 1992
  1132. --- new/makefile    Mon Apr 13 13:04:38 1992
  1133. ***************
  1134. *** 5,19 ****
  1135.   
  1136.   OBJS=    cbc_cksum.o cbc_encrypt.o ecb_encrypt.o pcbc_encrypt.o \
  1137.       quad_cksum.o random_key.o read_password.o set_key.o string_to_key.o \
  1138.       enc_read.o enc_write.o fcrypt.o
  1139.   
  1140. ! GENERAL=COPYING FILES INSTALLATION Imakefile README VERSION makefile times
  1141.   DES=    des.c des.man
  1142.   TESTING=destest.c speed.c rpw.c
  1143.   LIBDES=    des_crypt.man des.h cbc_cksum.c cbc_encrypt.c ecb_encrypt.c \
  1144.       enc_read.c enc_write.c pcbc_encrypt.c quad_cksum.c random_key.c \
  1145.       read_password.c set_key.c string_to_key.c fcrypt.c des_local.h \
  1146. !     podd.h sk.h sp.h
  1147.   PERL=    des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
  1148.   
  1149.   ALL=    $(GENERAL) $(DES) $(TESTING) $(LIBDES) $(PERL)
  1150. --- 5,27 ----
  1151.   
  1152. + LIBDIR=/usr/local/lib
  1153. + BINDIR=/usr/local/bin
  1154. + INCDIR=/usr/include
  1155. + MANDIR=/usr/local/man
  1156. + MAN1=1
  1157. + MAN3=3
  1158.   OBJS=    cbc_cksum.o cbc_encrypt.o ecb_encrypt.o pcbc_encrypt.o \
  1159.       quad_cksum.o random_key.o read_password.o set_key.o string_to_key.o \
  1160.       enc_read.o enc_write.o fcrypt.o
  1161.   
  1162. ! GENERAL=COPYING FILES INSTALLATION Imakefile README VERSION makefile times \
  1163. !     vms.com
  1164.   DES=    des.c des.man
  1165.   TESTING=destest.c speed.c rpw.c
  1166.   LIBDES=    des_crypt.man des.h cbc_cksum.c cbc_encrypt.c ecb_encrypt.c \
  1167.       enc_read.c enc_write.c pcbc_encrypt.c quad_cksum.c random_key.c \
  1168.       read_password.c set_key.c string_to_key.c fcrypt.c des_local.h \
  1169. !     podd.h sk.h spr.h
  1170.   PERL=    des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
  1171.   
  1172.   ALL=    $(GENERAL) $(DES) $(TESTING) $(LIBDES) $(PERL)
  1173. ***************
  1174. *** 25,31 ****
  1175.   $(LIB):    $(OBJS)
  1176.       /bin/rm -f $(LIB)
  1177.       ar cr $(LIB) $(OBJS)
  1178. !     ranlib libdes.a
  1179.   
  1180.   destest: destest.o libdes.a
  1181.       $(CC) $(CFLAGS) -o destest destest.o libdes.a
  1182. --- 33,41 ----
  1183.   $(LIB):    $(OBJS)
  1184.       /bin/rm -f $(LIB)
  1185.       ar cr $(LIB) $(OBJS)
  1186. !     -if test -s /bin/ranlib; then /bin/ranlib $(LIB); \
  1187. !     else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(LIB); \
  1188. !     else exit 0; fi; fi
  1189.   
  1190.   destest: destest.o libdes.a
  1191.       $(CC) $(CFLAGS) -o destest destest.o libdes.a
  1192. ***************
  1193. *** 47,49 ****
  1194. --- 57,71 ----
  1195.   
  1196.   clean:
  1197.       /bin/rm -f *.o rpw destest des speed $(LIB)
  1198. + install: $(LIB) des
  1199. +     cp $(LIB) $(LIBDIR)/$(LIB)
  1200. +     chmod 644 $(LIBDIR)/$(LIB)
  1201. +     cp des $(BINDIR)/des
  1202. +     chmod 711 $(BINDIR)/des
  1203. +     cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3)
  1204. +     chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3)
  1205. +     cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1)
  1206. +     chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1)
  1207. +     cp des.h $(INCDIR)/des.h
  1208. +     chmod 644 $(INCDIR)/des.h
  1209. diff -r -c old/read_password.c new/read_password.c
  1210. *** old/read_password.c    Mon Apr 13 10:05:24 1992
  1211. --- new/read_password.c    Wed Apr  8 10:01:34 1992
  1212. ***************
  1213. *** 1,11 ****
  1214.   /* read_password.c */
  1215.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1216.   #include "des_local.h"
  1217.   #include <string.h>
  1218.   #include <signal.h>
  1219.   #include <sgtty.h>
  1220.   #include <sys/ioctl.h>
  1221. ! #include <setjmp.h>
  1222.   
  1223.   static int read_pw();
  1224.   static void recsig();
  1225. --- 1,22 ----
  1226.   /* read_password.c */
  1227.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1228. + /* 06-Apr-92 Luke Brennan    Support for VMS */
  1229.   #include "des_local.h"
  1230.   #include <string.h>
  1231.   #include <signal.h>
  1232. + #include <setjmp.h>
  1233. + #ifndef VMS
  1234.   #include <sgtty.h>
  1235.   #include <sys/ioctl.h>
  1236. ! #else /* VMS */
  1237. ! truct sgttyb {
  1238. !     unsigned char class, ttype;
  1239. !     unsigned short pgwid;
  1240. !     unsigned ttchr : 24;
  1241. !     unsigned char pglen;
  1242. !     unsigned int xchar;
  1243. !     };
  1244. ! #endif
  1245.   
  1246.   static int read_pw();
  1247.   static void recsig();
  1248. ***************
  1249. *** 70,77 ****
  1250. --- 81,90 ----
  1251.   
  1252.       if ((tty=fopen("/dev/tty","r")) == NULL)
  1253.           tty=stdin;
  1254. + #ifdef TIOCGETP
  1255.       if (ioctl(fileno(tty),TIOCGETP,(char *)&tty_orig) == -1)
  1256.           return(-1);
  1257. + #endif
  1258.       bcopy(&(tty_orig),&(tty_new),sizeof(tty_orig));
  1259.       if (setjmp(save))
  1260.           {
  1261. ***************
  1262. *** 81,88 ****
  1263. --- 94,103 ----
  1264.       pushsig();
  1265.       ps=1;
  1266.       tty_new.sg_flags &= ~ECHO;
  1267. + #ifdef TIOCSETP
  1268.       if (ioctl(fileno(tty),TIOCSETP,(char *)&tty_new) == -1)
  1269.           return(-1);
  1270. + #endif
  1271.       ps=2;
  1272.   
  1273.       while (!ok)
  1274. ***************
  1275. *** 120,126 ****
  1276. --- 135,143 ----
  1277.   error:
  1278.       fprintf(stderr,"\n");
  1279.       /* What can we do if there is an error? */
  1280. + #ifdef TIOCSETP
  1281.       if (ps >= 2) ioctl(fileno(tty),TIOCSETP,(char *)&tty_orig);
  1282. + #endif
  1283.       if (ps >= 1) popsig();
  1284.       if (stdin != tty) fclose(tty);
  1285.       return(!ok);
  1286. Only in old: sp.h
  1287. diff -r -c old/speed.c new/speed.c
  1288. *** old/speed.c    Mon Apr 13 10:05:25 1992
  1289. --- new/speed.c    Mon Apr 13 12:29:31 1992
  1290. ***************
  1291. *** 1,25 ****
  1292.   /* speed.c */
  1293.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1294.   #include <stdio.h>
  1295.   #include <signal.h>
  1296.   #include <sys/types.h>
  1297.   #include <sys/times.h>
  1298.   #include "des.h"
  1299.   
  1300.   /* The following if from times(3) man page.  It may need to be changed */
  1301.   #define HZ    60.0
  1302.   
  1303.   #define BUFSIZE    (1024*8)
  1304.   long run=0;
  1305. - int sig_done() { run=0; }
  1306.   
  1307.   main(argc,argv)
  1308.   int argc;
  1309.   char *argv[];
  1310.       {
  1311. !     struct tms tstart,tend;
  1312. !     int count;
  1313.       FILE *in,*out,*std;
  1314.       static unsigned char buf[BUFSIZE];
  1315.       static des_cblock key={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
  1316. --- 1,101 ----
  1317.   /* speed.c */
  1318.   /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1319. + /* 06-Apr-92 Luke Brennan    Support for VMS and add extra signal calls */
  1320. + #define TIMES
  1321.   #include <stdio.h>
  1322.   #include <signal.h>
  1323. + #undef SIGALRM
  1324. + #ifndef VMS
  1325. + #include <time.h>
  1326.   #include <sys/types.h>
  1327.   #include <sys/times.h>
  1328. + #else /* VMS */
  1329. + #include <types.h>
  1330. + struct tms {
  1331. +     time_t tms_utime;
  1332. +     time_t tms_stime;
  1333. +     time_t tms_uchild;          /* I dunno...  */
  1334. +     time_t tms_uchildsys;       /* so these names are a guess :-) */
  1335. +     }
  1336. + #endif
  1337. + #ifndef TIMES
  1338. + #include <sys/timeb.h>
  1339. + #endif
  1340.   #include "des.h"
  1341.   
  1342.   /* The following if from times(3) man page.  It may need to be changed */
  1343. + #ifndef CLK_TCK
  1344. + #ifndef VMS
  1345.   #define HZ    60.0
  1346. + #else /* VMS */
  1347. + #define HZ    100.0
  1348. + #endif
  1349. + #else /* CLK_TCK */
  1350. + #define HZ ((double)CLK_TCK)
  1351. + #endif
  1352.   
  1353.   #define BUFSIZE    (1024*8)
  1354.   long run=0;
  1355.   
  1356. + #ifdef SIGALRM
  1357. + #ifdef __STDC__
  1358. + #define SIGRETTYPE void
  1359. + #else
  1360. + #define SIGRETTYPE int
  1361. + #endif 
  1362. + SIGRETTYPE sig_done(sig)
  1363. + int sig;
  1364. +     {
  1365. +     signal(SIGALRM,sig_done);
  1366. +     run=0;
  1367. +     }
  1368. + #endif
  1369. + #define START    0
  1370. + #define STOP    1
  1371. + double Time(s)
  1372. + int s;
  1373. +     {
  1374. + #ifdef TIMES
  1375. +     static struct tms tstart,tend;
  1376. +     if (s == START)
  1377. +         {
  1378. +         times(&tstart);
  1379. +         return(0);
  1380. +         }
  1381. +     else
  1382. +         {
  1383. +         times(&tend);
  1384. +         return(((double)(tend.tms_utime-tstart.tms_utime))/HZ);
  1385. +         }
  1386. + #else /* !times() */
  1387. +     static struct timeb tstart,tend;
  1388. +     long i;
  1389. +     if (s == START)
  1390. +         {
  1391. +         ftime(&tstart);
  1392. +         return(0);
  1393. +         }
  1394. +     else
  1395. +         {
  1396. +         ftime(&tend);
  1397. +         i=(long)tend.time-(long)tstart.time;
  1398. +         return(((double)(tend.time-tstart.time))+i/1000.0);
  1399. +         }
  1400. + #endif
  1401. +     }
  1402.   main(argc,argv)
  1403.   int argc;
  1404.   char *argv[];
  1405.       {
  1406. !     long count;
  1407.       FILE *in,*out,*std;
  1408.       static unsigned char buf[BUFSIZE];
  1409.       static des_cblock key={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
  1410. ***************
  1411. *** 26,78 ****
  1412.       des_key_schedule sch;
  1413.       int i,j,k,enc,cat=0,catfd;
  1414.       double d,a,b,c;
  1415.   
  1416. !     signal(SIGALRM,sig_done);
  1417.   
  1418.       printf("Doing set_key for 60 seconds\n");
  1419.       alarm(60);
  1420. !     times(&tstart);
  1421. !     for (count=0,run=1; run; count++)
  1422.           des_set_key(key,sch);
  1423. !     times(&tend);
  1424. !     d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  1425. !     printf("%d set_key's in %.2f second\n",
  1426. !         count,d);
  1427. !     a=((double)count)/d;
  1428.   
  1429.       printf("Doing des_ecb_encrypt's for 60 seconds\n");
  1430.       alarm(60);
  1431. !     times(&tstart);
  1432. !     for (count=0,run=1; run; count++)
  1433.           des_ecb_encrypt(buf,buf,&(sch[0]),DES_ENCRYPT);
  1434. !     times(&tend);
  1435. !     d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  1436. !     printf("%d des_ecb_encrypt's in %.2f second\n",
  1437. !         count,d);
  1438. !     b=((double)count*8)/d;
  1439.   
  1440.       printf("Doing des_cbc_encrypt on %d byte blocks for 60 seconds\n",
  1441.           BUFSIZE);
  1442.       alarm(60);
  1443. !     times(&tstart);
  1444. !     for (count=0,run=1; run; count++)
  1445.           des_cbc_encrypt(buf,buf,BUFSIZE,&(sch[0]),
  1446.           &(key[0]),DES_ENCRYPT);
  1447. !     times(&tend);
  1448. !     d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  1449.       printf("%d des_cbc_encrypt's of %d byte blocks in %.2f second\n",
  1450.           count,BUFSIZE,d);
  1451. !     c=((double)count*BUFSIZE)/d;
  1452.   
  1453.       printf("Doing crypt for 60 seconds\n");
  1454.       alarm(60);
  1455. !     times(&tstart);
  1456. !     for (count=0,run=1; run; count++)
  1457.           crypt("testing1","ef");
  1458. !     times(&tend);
  1459. !     d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  1460.       printf("%d crypts in %.2f second\n",count,d);
  1461. !     d=((double)count)/d;
  1462.   
  1463.       printf("set_key       per sec = %12.2f\n",a);
  1464.       printf("DES ecb bytes per sec = %12.2f\n",b);
  1465. --- 102,188 ----
  1466.       des_key_schedule sch;
  1467.       int i,j,k,enc,cat=0,catfd;
  1468.       double d,a,b,c;
  1469. +     long ca,cb,cc,cd;
  1470.   
  1471. ! #ifndef TIMES
  1472. !     printf("To get the most acurate results, try to run this\n");
  1473. !     printf("program when this computer is idle.\n");
  1474. ! #endif
  1475.   
  1476. + #ifndef SIGALRM
  1477. +     printf("First calculate aprox speed...\n");
  1478. +     des_set_key(key,sch);
  1479. +     count=10;
  1480. +     do    {
  1481. +         count*=2;
  1482. +         Time(START);
  1483. +         for (i=count; i; i--)
  1484. +             des_ecb_encrypt(buf,buf,&(sch[0]),DES_ENCRYPT);
  1485. +         d=Time(STOP);
  1486. +         } while (d <3);
  1487. +     ca=count;
  1488. +     cb=count*10;
  1489. +     cc=count*10*8/BUFSIZE+1;
  1490. +     cd=count/20+1;
  1491. +     printf("Doing set_key's %d times\n",ca);
  1492. + #define COND(d)    (count != (d))
  1493. + #define COUNT(d) (d)
  1494. + #else
  1495. + #define COND(c)    (run)
  1496. + #define COUNT(d) (count)
  1497. +     signal(SIGALRM,sig_done);
  1498.       printf("Doing set_key for 60 seconds\n");
  1499.       alarm(60);
  1500. ! #endif
  1501. !     Time(START);
  1502. !     for (count=0,run=1; COND(ca); count++)
  1503.           des_set_key(key,sch);
  1504. !     d=Time(STOP);
  1505. !     printf("%d set_key's in %.2f seconds\n",count,d);
  1506. !     a=((double)COUNT(ca))/d;
  1507.   
  1508. + #ifdef SIGALRM
  1509.       printf("Doing des_ecb_encrypt's for 60 seconds\n");
  1510.       alarm(60);
  1511. ! #else
  1512. !     printf("Doing %d des_ecb_encrypt's\n",cb);
  1513. ! #endif
  1514. !     Time(START);
  1515. !     for (count=0,run=1; COND(cb); count++)
  1516.           des_ecb_encrypt(buf,buf,&(sch[0]),DES_ENCRYPT);
  1517. !     d=Time(STOP);
  1518. !     printf("%d des_ecb_encrypt's in %.2f second\n",count,d);
  1519. !     b=((double)COUNT(cb)*8)/d;
  1520.   
  1521. + #ifdef SIGALRM
  1522.       printf("Doing des_cbc_encrypt on %d byte blocks for 60 seconds\n",
  1523.           BUFSIZE);
  1524.       alarm(60);
  1525. ! #else
  1526. !     printf("Doing %d des_cbc_encrypt's on %d byte blocks\n",cc,BUFSIZE);
  1527. ! #endif
  1528. !     Time(START);
  1529. !     for (count=0,run=1; COND(cc); count++)
  1530.           des_cbc_encrypt(buf,buf,BUFSIZE,&(sch[0]),
  1531.           &(key[0]),DES_ENCRYPT);
  1532. !     d=Time(STOP);
  1533.       printf("%d des_cbc_encrypt's of %d byte blocks in %.2f second\n",
  1534.           count,BUFSIZE,d);
  1535. !     c=((double)COUNT(cc)*BUFSIZE)/d;
  1536.   
  1537. + #ifdef SIGALRM
  1538.       printf("Doing crypt for 60 seconds\n");
  1539.       alarm(60);
  1540. ! #else
  1541. !     printf("Doing %d crypt's\n",cd);
  1542. ! #endif
  1543. !     Time(START);
  1544. !     for (count=0,run=1; COND(cd); count++)
  1545.           crypt("testing1","ef");
  1546. !     d=Time(STOP);
  1547.       printf("%d crypts in %.2f second\n",count,d);
  1548. !     d=((double)COUNT(cd))/d;
  1549.   
  1550.       printf("set_key       per sec = %12.2f\n",a);
  1551.       printf("DES ecb bytes per sec = %12.2f\n",b);
  1552. diff -r -c old/spr.h new/spr.h
  1553. *** old/spr.h    Mon Apr 13 12:57:36 1992
  1554. --- new/spr.h    Mon Apr 13 09:47:55 1992
  1555. ***************
  1556. *** 0 ****
  1557. --- 1,146 ----
  1558. + /* sp.h */
  1559. + /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1560. + static unsigned long des_SPtrans[8][64]={
  1561. + /* nibble 0 */
  1562. + 0x00820200, 0x00020000, 0x80800000, 0x80820200,
  1563. + 0x00800000, 0x80020200, 0x80020000, 0x80800000,
  1564. + 0x80020200, 0x00820200, 0x00820000, 0x80000200,
  1565. + 0x80800200, 0x00800000, 0x00000000, 0x80020000,
  1566. + 0x00020000, 0x80000000, 0x00800200, 0x00020200,
  1567. + 0x80820200, 0x00820000, 0x80000200, 0x00800200,
  1568. + 0x80000000, 0x00000200, 0x00020200, 0x80820000,
  1569. + 0x00000200, 0x80800200, 0x80820000, 0x00000000,
  1570. + 0x00000000, 0x80820200, 0x00800200, 0x80020000,
  1571. + 0x00820200, 0x00020000, 0x80000200, 0x00800200,
  1572. + 0x80820000, 0x00000200, 0x00020200, 0x80800000,
  1573. + 0x80020200, 0x80000000, 0x80800000, 0x00820000,
  1574. + 0x80820200, 0x00020200, 0x00820000, 0x80800200,
  1575. + 0x00800000, 0x80000200, 0x80020000, 0x00000000,
  1576. + 0x00020000, 0x00800000, 0x80800200, 0x00820200,
  1577. + 0x80000000, 0x80820000, 0x00000200, 0x80020200,
  1578. + /* nibble 1 */
  1579. + 0x10042004, 0x00000000, 0x00042000, 0x10040000,
  1580. + 0x10000004, 0x00002004, 0x10002000, 0x00042000,
  1581. + 0x00002000, 0x10040004, 0x00000004, 0x10002000,
  1582. + 0x00040004, 0x10042000, 0x10040000, 0x00000004,
  1583. + 0x00040000, 0x10002004, 0x10040004, 0x00002000,
  1584. + 0x00042004, 0x10000000, 0x00000000, 0x00040004,
  1585. + 0x10002004, 0x00042004, 0x10042000, 0x10000004,
  1586. + 0x10000000, 0x00040000, 0x00002004, 0x10042004,
  1587. + 0x00040004, 0x10042000, 0x10002000, 0x00042004,
  1588. + 0x10042004, 0x00040004, 0x10000004, 0x00000000,
  1589. + 0x10000000, 0x00002004, 0x00040000, 0x10040004,
  1590. + 0x00002000, 0x10000000, 0x00042004, 0x10002004,
  1591. + 0x10042000, 0x00002000, 0x00000000, 0x10000004,
  1592. + 0x00000004, 0x10042004, 0x00042000, 0x10040000,
  1593. + 0x10040004, 0x00040000, 0x00002004, 0x10002000,
  1594. + 0x10002004, 0x00000004, 0x10040000, 0x00042000,
  1595. + /* nibble 2 */
  1596. + 0x41000000, 0x01010040, 0x00000040, 0x41000040,
  1597. + 0x40010000, 0x01000000, 0x41000040, 0x00010040,
  1598. + 0x01000040, 0x00010000, 0x01010000, 0x40000000,
  1599. + 0x41010040, 0x40000040, 0x40000000, 0x41010000,
  1600. + 0x00000000, 0x40010000, 0x01010040, 0x00000040,
  1601. + 0x40000040, 0x41010040, 0x00010000, 0x41000000,
  1602. + 0x41010000, 0x01000040, 0x40010040, 0x01010000,
  1603. + 0x00010040, 0x00000000, 0x01000000, 0x40010040,
  1604. + 0x01010040, 0x00000040, 0x40000000, 0x00010000,
  1605. + 0x40000040, 0x40010000, 0x01010000, 0x41000040,
  1606. + 0x00000000, 0x01010040, 0x00010040, 0x41010000,
  1607. + 0x40010000, 0x01000000, 0x41010040, 0x40000000,
  1608. + 0x40010040, 0x41000000, 0x01000000, 0x41010040,
  1609. + 0x00010000, 0x01000040, 0x41000040, 0x00010040,
  1610. + 0x01000040, 0x00000000, 0x41010000, 0x40000040,
  1611. + 0x41000000, 0x40010040, 0x00000040, 0x01010000,
  1612. + /* nibble 3 */
  1613. + 0x00100402, 0x04000400, 0x00000002, 0x04100402,
  1614. + 0x00000000, 0x04100000, 0x04000402, 0x00100002,
  1615. + 0x04100400, 0x04000002, 0x04000000, 0x00000402,
  1616. + 0x04000002, 0x00100402, 0x00100000, 0x04000000,
  1617. + 0x04100002, 0x00100400, 0x00000400, 0x00000002,
  1618. + 0x00100400, 0x04000402, 0x04100000, 0x00000400,
  1619. + 0x00000402, 0x00000000, 0x00100002, 0x04100400,
  1620. + 0x04000400, 0x04100002, 0x04100402, 0x00100000,
  1621. + 0x04100002, 0x00000402, 0x00100000, 0x04000002,
  1622. + 0x00100400, 0x04000400, 0x00000002, 0x04100000,
  1623. + 0x04000402, 0x00000000, 0x00000400, 0x00100002,
  1624. + 0x00000000, 0x04100002, 0x04100400, 0x00000400,
  1625. + 0x04000000, 0x04100402, 0x00100402, 0x00100000,
  1626. + 0x04100402, 0x00000002, 0x04000400, 0x00100402,
  1627. + 0x00100002, 0x00100400, 0x04100000, 0x04000402,
  1628. + 0x00000402, 0x04000000, 0x04000002, 0x04100400,
  1629. + /* nibble 4 */
  1630. + 0x02000000, 0x00004000, 0x00000100, 0x02004108,
  1631. + 0x02004008, 0x02000100, 0x00004108, 0x02004000,
  1632. + 0x00004000, 0x00000008, 0x02000008, 0x00004100,
  1633. + 0x02000108, 0x02004008, 0x02004100, 0x00000000,
  1634. + 0x00004100, 0x02000000, 0x00004008, 0x00000108,
  1635. + 0x02000100, 0x00004108, 0x00000000, 0x02000008,
  1636. + 0x00000008, 0x02000108, 0x02004108, 0x00004008,
  1637. + 0x02004000, 0x00000100, 0x00000108, 0x02004100,
  1638. + 0x02004100, 0x02000108, 0x00004008, 0x02004000,
  1639. + 0x00004000, 0x00000008, 0x02000008, 0x02000100,
  1640. + 0x02000000, 0x00004100, 0x02004108, 0x00000000,
  1641. + 0x00004108, 0x02000000, 0x00000100, 0x00004008,
  1642. + 0x02000108, 0x00000100, 0x00000000, 0x02004108,
  1643. + 0x02004008, 0x02004100, 0x00000108, 0x00004000,
  1644. + 0x00004100, 0x02004008, 0x02000100, 0x00000108,
  1645. + 0x00000008, 0x00004108, 0x02004000, 0x02000008,
  1646. + /* nibble 5 */
  1647. + 0x20000010, 0x00080010, 0x00000000, 0x20080800,
  1648. + 0x00080010, 0x00000800, 0x20000810, 0x00080000,
  1649. + 0x00000810, 0x20080810, 0x00080800, 0x20000000,
  1650. + 0x20000800, 0x20000010, 0x20080000, 0x00080810,
  1651. + 0x00080000, 0x20000810, 0x20080010, 0x00000000,
  1652. + 0x00000800, 0x00000010, 0x20080800, 0x20080010,
  1653. + 0x20080810, 0x20080000, 0x20000000, 0x00000810,
  1654. + 0x00000010, 0x00080800, 0x00080810, 0x20000800,
  1655. + 0x00000810, 0x20000000, 0x20000800, 0x00080810,
  1656. + 0x20080800, 0x00080010, 0x00000000, 0x20000800,
  1657. + 0x20000000, 0x00000800, 0x20080010, 0x00080000,
  1658. + 0x00080010, 0x20080810, 0x00080800, 0x00000010,
  1659. + 0x20080810, 0x00080800, 0x00080000, 0x20000810,
  1660. + 0x20000010, 0x20080000, 0x00080810, 0x00000000,
  1661. + 0x00000800, 0x20000010, 0x20000810, 0x20080800,
  1662. + 0x20080000, 0x00000810, 0x00000010, 0x20080010,
  1663. + /* nibble 6 */
  1664. + 0x00001000, 0x00000080, 0x00400080, 0x00400001,
  1665. + 0x00401081, 0x00001001, 0x00001080, 0x00000000,
  1666. + 0x00400000, 0x00400081, 0x00000081, 0x00401000,
  1667. + 0x00000001, 0x00401080, 0x00401000, 0x00000081,
  1668. + 0x00400081, 0x00001000, 0x00001001, 0x00401081,
  1669. + 0x00000000, 0x00400080, 0x00400001, 0x00001080,
  1670. + 0x00401001, 0x00001081, 0x00401080, 0x00000001,
  1671. + 0x00001081, 0x00401001, 0x00000080, 0x00400000,
  1672. + 0x00001081, 0x00401000, 0x00401001, 0x00000081,
  1673. + 0x00001000, 0x00000080, 0x00400000, 0x00401001,
  1674. + 0x00400081, 0x00001081, 0x00001080, 0x00000000,
  1675. + 0x00000080, 0x00400001, 0x00000001, 0x00400080,
  1676. + 0x00000000, 0x00400081, 0x00400080, 0x00001080,
  1677. + 0x00000081, 0x00001000, 0x00401081, 0x00400000,
  1678. + 0x00401080, 0x00000001, 0x00001001, 0x00401081,
  1679. + 0x00400001, 0x00401080, 0x00401000, 0x00001001,
  1680. + /* nibble 7 */
  1681. + 0x08200020, 0x08208000, 0x00008020, 0x00000000,
  1682. + 0x08008000, 0x00200020, 0x08200000, 0x08208020,
  1683. + 0x00000020, 0x08000000, 0x00208000, 0x00008020,
  1684. + 0x00208020, 0x08008020, 0x08000020, 0x08200000,
  1685. + 0x00008000, 0x00208020, 0x00200020, 0x08008000,
  1686. + 0x08208020, 0x08000020, 0x00000000, 0x00208000,
  1687. + 0x08000000, 0x00200000, 0x08008020, 0x08200020,
  1688. + 0x00200000, 0x00008000, 0x08208000, 0x00000020,
  1689. + 0x00200000, 0x00008000, 0x08000020, 0x08208020,
  1690. + 0x00008020, 0x08000000, 0x00000000, 0x00208000,
  1691. + 0x08200020, 0x08008020, 0x08008000, 0x00200020,
  1692. + 0x08208000, 0x00000020, 0x00200020, 0x08008000,
  1693. + 0x08208020, 0x00200000, 0x08200000, 0x08000020,
  1694. + 0x00208000, 0x00008020, 0x08008020, 0x08200000,
  1695. + 0x00000020, 0x08208000, 0x00208020, 0x00000000,
  1696. + 0x08000000, 0x08200020, 0x00008000, 0x00208020};
  1697. diff -r -c old/times new/times
  1698. *** old/times    Mon Apr 13 10:05:26 1992
  1699. --- new/times    Mon Apr 13 12:56:37 1992
  1700. ***************
  1701. *** 1,4 ****
  1702. --- 1,15 ----
  1703. + New version 1.92 - slight speedup.
  1704.   sun sparc 2 - gcc2 -O2
  1705. + set_key       per sec =     21559.10
  1706. + DES ecb bytes per sec =    305566.92
  1707. + DES cbc bytes per sec =    303497.50
  1708. + crypt         per sec =      1410.48
  1709. + Old version 1.90
  1710. + sun sparc 2 - gcc2 -O2
  1711.   -rw-r-----  1 eay      wheel       25804 Mar 24 14:16 libdes.a
  1712.   set_key       per sec =     21462.36
  1713.   DES ecb bytes per sec =    289342.72
  1714. ***************
  1715. *** 25,27 ****
  1716. --- 36,47 ----
  1717.   DES ecb bytes per sec =     31061.97
  1718.   DES cbc bytes per sec =     31561.52
  1719.   crypt         per sec =       148.66
  1720. + From Robert Withrow <witr@rwwa.COM>
  1721. + 386/33 - cc -O
  1722. + -rw-r--r--   1 root     other      32708 Apr  4 14:45 /usr/local/lib/libdes.a
  1723. + set_key       per sec =      5475.44
  1724. + DES ecb bytes per sec =     64527.52
  1725. + DES cbc bytes per sec =     67086.06
  1726. + crypt         per sec =       298.54
  1727. diff -r -c old/vms.com new/vms.com
  1728. *** old/vms.com    Mon Apr 13 13:05:48 1992
  1729. --- new/vms.com    Wed Apr  8 08:54:51 1992
  1730. ***************
  1731. *** 0 ****
  1732. --- 1,82 ----
  1733. + $! --- VMS.com ---
  1734. + $!
  1735. + $ GoSub defines
  1736. + $ GoSub linker_options
  1737. + $ If (P1 .nes. "")
  1738. + $ Then 
  1739. + $   GoSub 'P1'
  1740. + $ Else
  1741. + $   GoSub lib
  1742. + $   GoSub destest
  1743. + $   GoSub rpw
  1744. + $   GoSub speed
  1745. + $   GoSub des
  1746. + $ EndIF
  1747. + $!
  1748. + $ Exit
  1749. + $!
  1750. + $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1751. + $!
  1752. + $DEFINES:
  1753. + $ LINKOPTS := "VAX_LINKER_OPTIONS.OPT"
  1754. + $!
  1755. + $ OBJS  = "cbc_cksum.obj,cbc_encrypt.obj,ecb_encrypt.obj,pcbc_encrypt.obj," + -
  1756. +           "quad_cksum.obj,random_key.obj,read_password.obj,set_key.obj,"    + -
  1757. +           "string_to_key.obj,enc_read.obj,enc_write.obj,fcrypt.obj"
  1758. + $!
  1759. + $ LIBDES = "cbc_cksum.c,cbc_encrypt.c,ecb_encrypt.c,enc_read.c,"           + -
  1760. +            "enc_write.c,pcbc_encrypt.c,quad_cksum.c,random_key.c,"         + -
  1761. +            "read_password.c,set_key.c,string_to_key.c,fcrypt.c"
  1762. + $ Return
  1763. + $!
  1764. + $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1765. + $!
  1766. + $LINKER_OPTIONS:
  1767. + $ If (f$search(LINKOPTS) .eqs. "")
  1768. + $ Then
  1769. + $   Create 'LINKOPTS'
  1770. + $DECK
  1771. + ! Default system options file to link against the sharable C runtime library
  1772. + !
  1773. + Sys$Share:VAXcRTL.exe/Share
  1774. + $EOD
  1775. + $ EndIF
  1776. + $ Return
  1777. + $!
  1778. + $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1779. + $!
  1780. + $LIB:
  1781. + $ CC 'LIBDES'
  1782. + $ If (f$search("LIBDES.OLB") .nes. "")
  1783. + $ Then Library /Object /Replace libdes 'OBJS'
  1784. + $ Else Library /Create /Object  libdes 'OBJS'
  1785. + $ EndIF
  1786. + $ Return
  1787. + $!
  1788. + $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1789. + $!
  1790. + $DESTEST:
  1791. + $ CC destest
  1792. + $ Link /Exec=destest destest.obj,libdes/LIBRARY,'linkopts'/Option
  1793. + $ Return
  1794. + $!
  1795. + $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1796. + $!
  1797. + $RPW:
  1798. + $ CC rpw
  1799. + $ Link /Exec=rpw  rpw.obj,libdes/LIBRARY,'linkopts'/Option
  1800. + $ Return
  1801. + $!
  1802. + $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1803. + $!
  1804. + $SPEED:
  1805. + $ CC speed
  1806. + $ Link /Exec=speed speed.obj,libdes/LIBRARY,'linkopts'/Option
  1807. + $ Return
  1808. + $!
  1809. + $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1810. + $!
  1811. + $DES:
  1812. + $ CC des
  1813. + $ Link /Exec=des des.obj,libdes/LIBRARY,'linkopts'/Option
  1814. + $ Return
  1815.  
  1816.  
  1817. exit 0 # Just in case...
  1818.