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

  1. From: eay@psych.psy.uq.oz.au (Eric Young)
  2. Newsgroups: comp.sources.misc
  3. Subject: v29i043: libdes - DES encryption library, Part01/04
  4. Message-ID: <csm-v29i043=libdes.234005@aber.ac.uk>
  5. Date: 3 Apr 92 22:40:35 GMT
  6. Approved: aem@aber.ac.uk
  7. X-Md4-Signature: 9f382ac7159601bb8bc7296560ec5188
  8.  
  9. Submitted-by: eay@psych.psy.uq.oz.au (Eric Young)
  10. Posting-number: Volume 29, Issue 43
  11. Archive-name: libdes/part01
  12. Environment: UNIX
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 1 (of 4)."
  21. # Contents:  FILES INSTALLATION Imakefile MANIFEST PC1 PC2 README
  22. #   VERSION cbc_cksum.c cbc_encrypt.c des.h des.man des_local.h doIP
  23. #   doPC1 doPC2 ecb_encrypt.c enc_read.c enc_write.c makefile
  24. #   pcbc_encrypt.c podd.h quad_cksum.c random_key.c read_password.c
  25. #   rpw.c shifts.pl speed.c string_to_key.c times
  26. # Wrapped by aem@aberfa on Wed Apr  1 15:53:19 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'FILES' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'FILES'\"
  30. else
  31. echo shar: Extracting \"'FILES'\" \(1964 characters\)
  32. sed "s/^X//" >'FILES' <<'END_OF_FILE'
  33. X/* General stuff */
  34. XCOPYING        - Copying info.
  35. XFILES        - This file.
  36. XINSTALLATION    - How to make things compile.
  37. XImakefile    - For use with kerberos.
  38. XREADME        - What this package is.
  39. XVERSION        - Which version this is.
  40. Xmakefile    - The make file.
  41. Xtimes        - Some outputs from 'speed' on my local machines.
  42. X
  43. X/* My sunOS des(1) replacement */
  44. Xdes.c        - des(1) source code.
  45. Xdes.man        - des(1) manual.
  46. X
  47. X/* Testing and timing programs. */
  48. Xdestest.c    - Source for libdes.a test program.
  49. Xspeed.c        - Source for libdes.a timing program.
  50. Xrpw.c        - Source for libdes.a testing password reading routines.
  51. X
  52. X/* libdes.a source code */
  53. Xdes_crypt.man    - libdes.a manual page.
  54. Xdes.h        - Public libdes.a header file.
  55. Xcbc_cksum.c    - des_cbc_cksum() source.
  56. Xcbc_encrypt.c    - des_cbc_encrypt() source.
  57. Xecb_encrypt.c    - ecb_encrypt() source, this contains the basic DES code.
  58. Xenc_read.c    - des_enc_read() source.
  59. Xenc_write.c    - des_enc_write() source.
  60. Xpcbc_encrypt.c    - des_pcbc_encrypt() source.
  61. Xquad_cksum.c    - quad_cksum() source.
  62. Xrandom_key.c    - des_random_key() source.
  63. Xread_password.c - Source for des_read_password() plus related functions.
  64. Xset_key.c    - Source for des_set_key().
  65. Xstring_to_key.c - Covert a string of any length into a key.
  66. Xfcrypt.c    - A small, fast version of crypt(3).
  67. Xdes_local.h    - Internal libdes.a header file.
  68. Xpodd.h        - Odd parity tables - used in des_set_key().
  69. Xsk.h        - Lookup tables used in des_set_key().
  70. Xsp.h        - What is left of the S tables - used in ecb_encrypt().
  71. X
  72. X/* The perl scripts - you can ignore these files they are only
  73. X * included for the curious */
  74. Xdes.pl        - des in perl anyone? des_set_key and des_ecb_encrypt
  75. X          both done in a perl library.
  76. Xtestdes.pl    - Testing program for des.pl
  77. XdoIP        - Perl script used to develop IP xor/shift code.
  78. XdoPC1        - Perl script used to develop PC1 xor/shift code.
  79. XdoPC2        - Generates sk.h.
  80. XPC1        - Output of doPC1 should be the same as output from PC1.
  81. XPC2        - used in development of doPC2.
  82. Xshifts.pl    - Perl library used by my perl scripts.
  83. X
  84. END_OF_FILE
  85. if test 1964 -ne `wc -c <'FILES'`; then
  86.     echo shar: \"'FILES'\" unpacked with wrong size!
  87. fi
  88. # end of 'FILES'
  89. fi
  90. if test -f 'INSTALLATION' -a "${1}" != "-c" ; then 
  91.   echo shar: Will not clobber existing file \"'INSTALLATION'\"
  92. else
  93. echo shar: Extracting \"'INSTALLATION'\" \(724 characters\)
  94. sed "s/^X//" >'INSTALLATION' <<'END_OF_FILE'
  95. XCheck the CC and CFLAGS lines in the makefile
  96. XCheck the HZ value for the times(3) function.  If it is not 60 then
  97. Xyou will need to change its value in speed.c
  98. X
  99. XIf possible use gcc v 2.0.
  100. XTurn on the maximum optimising
  101. X
  102. Xtype './make'
  103. X
  104. Xrun './destest' to check things are ok.
  105. Xrun './rpw' to check the tty code for reading passwords works.
  106. Xrun './speed' to see how fast those optimisations make the library run :-)
  107. X
  108. XYou will need to install by hand
  109. Xlibdes.a      to /usr/local/lib/libdes.a
  110. Xdes.h         to /usr/include/des.h
  111. Xdes          to /usr/local/bin/des
  112. Xdes_crypt.man to /usr/local/man/man3/des_crypt.3
  113. Xdes.man       to /usr/local/man/man1/des.1
  114. X
  115. Xdes(1) should be compatable with sunOS's but I have been unable to
  116. Xtest it.
  117. END_OF_FILE
  118. if test 724 -ne `wc -c <'INSTALLATION'`; then
  119.     echo shar: \"'INSTALLATION'\" unpacked with wrong size!
  120. fi
  121. # end of 'INSTALLATION'
  122. fi
  123. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  124.   echo shar: Will not clobber existing file \"'Imakefile'\"
  125. else
  126. echo shar: Extracting \"'Imakefile'\" \(733 characters\)
  127. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  128. X# This Imakefile has not been tested for a while but it should still
  129. X# work when placed in the correct directory in the kerberos v 4 distribution
  130. X
  131. XSRCS=    cbc_cksum.c cbc_encrypt.c ecb_encrypt.c pcbc_encrypt.c \
  132. X    quad_cksum.c random_key.c read_password.c set_key.c string_to_key.c \
  133. X    enc_read.c enc_write.c
  134. X
  135. XOBJS=    cbc_cksum.o cbc_encrypt.o ecb_encrypt.o pcbc_encrypt.o \
  136. X    quad_cksum.o random_key.o read_password.o set_key.o string_to_key.o \
  137. X    enc_read.o enc_write.o
  138. X
  139. XCODE=    $(SRCS) Imakefile COPYRIGHT README VERSION \
  140. X    des.h des_local.h ksp.h makesh podd.h sp.h destest.c \
  141. X    rpw.c
  142. X
  143. XDBG= -O4
  144. XCC= cc
  145. X
  146. XSRCDIR=$(SRCTOP)/lib/des
  147. X
  148. Xlibrary_obj_rule()
  149. X
  150. Xinstall_library_target(des,$(OBJS),$(SRCS),)
  151. X
  152. Xtest(destest,libdes.a,)
  153. Xtest(rpw,libdes.a,)
  154. END_OF_FILE
  155. if test 733 -ne `wc -c <'Imakefile'`; then
  156.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  157. fi
  158. # end of 'Imakefile'
  159. fi
  160. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  161.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  162. else
  163. echo shar: Extracting \"'MANIFEST'\" \(1336 characters\)
  164. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  165. X   File Name        Archive #    Description
  166. X-----------------------------------------------------------
  167. X COPYING                    4    
  168. X FILES                      1    
  169. X INSTALLATION               1    
  170. X Imakefile                  1    
  171. X MANIFEST                   1    
  172. X PC1                        1    
  173. X PC2                        1    
  174. X README                     1    
  175. X VERSION                    1    
  176. X cbc_cksum.c                1    
  177. X cbc_encrypt.c              1    
  178. X des.c                      2    
  179. X des.h                      1    
  180. X des.man                    1    
  181. X des.pl                     3    
  182. X des_crypt.man              2    
  183. X des_local.h                1    
  184. X destest.c                  2    
  185. X doIP                       1    
  186. X doPC1                      1    
  187. X doPC2                      1    
  188. X ecb_encrypt.c              1    
  189. X enc_read.c                 1    
  190. X enc_write.c                1    
  191. X fcrypt.c                   3    
  192. X makefile                   1    
  193. X pcbc_encrypt.c             1    
  194. X podd.h                     1    
  195. X quad_cksum.c               1    
  196. X random_key.c               1    
  197. X read_password.c            1    
  198. X rpw.c                      1    
  199. X set_key.c                  2    
  200. X shifts.pl                  1    
  201. X sk.h                       2    
  202. X sp.h                       2    
  203. X speed.c                    1    
  204. X string_to_key.c            1    
  205. X testdes.pl                 2    
  206. X times                      1    
  207. END_OF_FILE
  208. if test 1336 -ne `wc -c <'MANIFEST'`; then
  209.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  210. fi
  211. # end of 'MANIFEST'
  212. fi
  213. if test -f 'PC1' -a "${1}" != "-c" ; then 
  214.   echo shar: Will not clobber existing file \"'PC1'\"
  215. else
  216. echo shar: Extracting \"'PC1'\" \(454 characters\)
  217. sed "s/^X//" >'PC1' <<'END_OF_FILE'
  218. X#!/usr/local/bin/perl
  219. X
  220. X@PC1=(  57,49,41,33,25,17, 9,
  221. X     1,58,50,42,34,26,18,
  222. X    10, 2,59,51,43,35,27,
  223. X    19,11, 3,60,52,44,36,
  224. X    "-","-","-","-",
  225. X    63,55,47,39,31,23,15,
  226. X     7,62,54,46,38,30,22,
  227. X    14, 6,61,53,45,37,29,
  228. X    21,13, 5,28,20,12, 4,
  229. X    "-","-","-","-",
  230. X    );
  231. X
  232. Xforeach (@PC1)
  233. X    {
  234. X    if ($_ ne "-")
  235. X        {
  236. X        $_--;
  237. X        $_=int($_/8)*8+7-($_%8);
  238. X        printf "%2d  ",$_;
  239. X        }
  240. X    else
  241. X        { print "--  "; }
  242. X    print "\n" if (((++$i) % 8) == 0);
  243. X    print "\n" if ((($i) % 32) == 0);
  244. X    }
  245. X
  246. END_OF_FILE
  247. if test 454 -ne `wc -c <'PC1'`; then
  248.     echo shar: \"'PC1'\" unpacked with wrong size!
  249. fi
  250. # end of 'PC1'
  251. fi
  252. if test -f 'PC2' -a "${1}" != "-c" ; then 
  253.   echo shar: Will not clobber existing file \"'PC2'\"
  254. else
  255. echo shar: Extracting \"'PC2'\" \(861 characters\)
  256. sed "s/^X//" >'PC2' <<'END_OF_FILE'
  257. X#!/usr/local/bin/perl
  258. X
  259. X@PC2_C=(14,17,11,24, 1, 5,
  260. X     3,28,15, 6,21,10,
  261. X    23,19,12, 4,26, 8,
  262. X    16, 7,27,20,13, 2,
  263. X    );
  264. X
  265. X@PC2_D=(41,52,31,37,47,55,
  266. X    30,40,51,45,33,48,
  267. X    44,49,39,56,34,53,
  268. X    46,42,50,36,29,32,
  269. X    );
  270. X
  271. Xforeach (@PC2_C) {
  272. X    if ($_ ne "-")
  273. X        {
  274. X        $_--;
  275. X        printf "%2d  ",$_; }
  276. X    else { print "--  "; }
  277. X    $C{$_}=1;
  278. X    print "\n" if (((++$i) % 8) == 0);
  279. X    }
  280. X$i=0;
  281. Xprint "\n";
  282. Xforeach (@PC2_D) {
  283. X    if ($_ ne "-")
  284. X        {
  285. X        $_-=29;
  286. X        printf "%2d  ",$_; }
  287. X    else { print "--  "; }
  288. X    $D{$_}=1;
  289. X    print "\n" if (((++$i) % 8) == 0); }
  290. X
  291. Xprint "\n";
  292. Xforeach $i (0 .. 27)
  293. X    {
  294. X    $_=$C{$i};
  295. X    if ($_ ne "-") {printf "%2d ",$_;}
  296. X    else { print "--  "; }
  297. X    print "\n" if (((++$i) % 8) == 0);
  298. X    }
  299. Xprint "\n";
  300. X
  301. Xprint "\n";
  302. Xforeach $i (0 .. 27)
  303. X    {
  304. X    $_=$D{$i};
  305. X    if ($_ ne "-") {printf "%2d  ",$_;}
  306. X    else { print "--  "; }
  307. X    print "\n" if (((++$i) % 8) == 0);
  308. X    }
  309. Xprint "\n";
  310. Xsub numsort
  311. X    {
  312. X    $a-$b;
  313. X    }
  314. END_OF_FILE
  315. if test 861 -ne `wc -c <'PC2'`; then
  316.     echo shar: \"'PC2'\" unpacked with wrong size!
  317. fi
  318. # end of 'PC2'
  319. fi
  320. if test -f 'README' -a "${1}" != "-c" ; then 
  321.   echo shar: Will not clobber existing file \"'README'\"
  322. else
  323. echo shar: Extracting \"'README'\" \(1375 characters\)
  324. sed "s/^X//" >'README' <<'END_OF_FILE'
  325. XThis is a DES encryption library.
  326. XIt suports ecb, cbc and MIT's pcbc encryption modes and also has
  327. Xa fast implementation of crypt(3).
  328. XIt also contains support routines to read keys from a terminal,
  329. Xgenerate a random key, generate a key from an arbitary length string,
  330. Xread/write from/to a file descriptor, and an implementation of
  331. XsunOS des(1) command for file encryption.
  332. X
  333. XThe implementation was written so as to conform with the manual entry
  334. Xfor the des_crypt(3) library routines from MIT's project Athena.
  335. X
  336. Xdestest should be run after compilation to test the des routines.
  337. Xrpw should be run after compilation to test the read password routines.
  338. XThe des program is a replacement for the sun des command.  I believe it
  339. Xconforms to the sun binary but I am unable to test it.
  340. X
  341. XThe Imakefile is setup for use in the kerberos distribution.
  342. X
  343. XThese routines are best compiled with gcc v 2.0 or any other good
  344. Xoptimising compiler.
  345. XJust turn you optimiser up to the highest settings and run destest
  346. Xafter the build to make sure everything works.
  347. X
  348. XI believe these routines are about the fastest DES routines that use
  349. Xsmall lookup tables (4.5k) that are publicly available.
  350. XThe fcrypt routine is faster than ufc's fcrypt (when compiling with
  351. Xgcc2 -O2) on the sparc 2 (1340 vs 1270) but is not so good on other machines
  352. X(on a sun3/260 168 vs 336).
  353. X
  354. XEric Young (eay@psych.psy.uq.oz.au)
  355. END_OF_FILE
  356. if test 1375 -ne `wc -c <'README'`; then
  357.     echo shar: \"'README'\" unpacked with wrong size!
  358. fi
  359. # end of 'README'
  360. fi
  361. if test -f 'VERSION' -a "${1}" != "-c" ; then 
  362.   echo shar: Will not clobber existing file \"'VERSION'\"
  363. else
  364. echo shar: Extracting \"'VERSION'\" \(1830 characters\)
  365. sed "s/^X//" >'VERSION' <<'END_OF_FILE'
  366. XVersion 1.9 24/03/91 eay
  367. X    Now contains a fast small crypt replacement.
  368. X    Added des(1) command.
  369. X    Added des_rw_mode so people can use cbc encryption with
  370. X    enc_read and enc_write.
  371. X
  372. XVersion 1.8 15/10/91 eay
  373. X    Bug in cbc_cksum.
  374. X    Many thanks to Keith Reynolds (keithr@sco.COM) for pointing this
  375. X    one out.
  376. X
  377. XVersion 1.7 24/09/91 eay
  378. X    Fixed set_key :-)
  379. X    set_key is 4 times faster and takes less space.
  380. X    There are a few minor changes that could be made.
  381. X
  382. XVersion 1.6 19/09/1991 eay
  383. X    Finally go IP and FP finished.
  384. X    Now I need to fix set_key.
  385. X    This version is quite a bit faster that 1.51
  386. X
  387. XVersion 1.52 15/06/1991 eay
  388. X    20% speedup in ecb_encrypt by changing the E bit selection
  389. X    to use 2 32bit words.  This also required modification of the
  390. X    sp table.  There is still a way to speedup the IP and IP-1
  391. X    (hints from outer@sq.com) still working on this one :-(.
  392. X
  393. XVersion 1.51 07/06/1991 eay
  394. X    Faster des_encrypt by loop unrolling
  395. X    Fixed bug in quad_cksum.c (thanks to hughes@logos.ucs.indiana.edu)
  396. X
  397. XVersion 1.50 28/05/1991 eay
  398. X    Optimized the code a bit more for the sparc.  I have improved the
  399. X    speed of the inner des_encrypt by speeding up the initial and
  400. X    final permutations.
  401. X
  402. XVersion 1.40 23/10/1990 eay
  403. X    Fixed des_random_key, it did not produce a random key :-(
  404. X
  405. XVersion 1.30  2/10/1990 eay
  406. X    Have made des_quad_cksum the same as MIT's, the full package
  407. X    should be compatible with MIT's
  408. X    Have tested on a DECstation 3100
  409. X    Still need to fix des_set_key (make it faster).
  410. X    Does des_cbc_encrypts at 70.5k/sec on a 3100.
  411. X
  412. XVersion 1.20 18/09/1990 eay
  413. X    Fixed byte order dependencies.
  414. X    Fixed (I hope) all the word alignment problems.
  415. X    Speedup in des_ecb_encrypt.
  416. X
  417. XVersion 1.10 11/09/1990 eay
  418. X    Added des_enc_read and des_enc_write.
  419. X    Still need to fix des_quad_cksum.
  420. X    Still need to document des_enc_read and des_enc_write.
  421. X
  422. XVersion 1.00 27/08/1990 eay
  423. END_OF_FILE
  424. if test 1830 -ne `wc -c <'VERSION'`; then
  425.     echo shar: \"'VERSION'\" unpacked with wrong size!
  426. fi
  427. # end of 'VERSION'
  428. fi
  429. if test -f 'cbc_cksum.c' -a "${1}" != "-c" ; then 
  430.   echo shar: Will not clobber existing file \"'cbc_cksum.c'\"
  431. else
  432. echo shar: Extracting \"'cbc_cksum.c'\" \(901 characters\)
  433. sed "s/^X//" >'cbc_cksum.c' <<'END_OF_FILE'
  434. X/* cbc_cksum.c */
  435. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  436. X#include "des_local.h"
  437. X
  438. Xulong des_cbc_cksum(input,output,length,schedule,ivec)
  439. Xdes_cblock *input;
  440. Xdes_cblock *output;
  441. Xlong length;
  442. Xdes_key_schedule schedule;
  443. Xdes_cblock *ivec;
  444. X    {
  445. X    register ulong tout0,tout1,tin0,tin1;
  446. X    register long l=length;
  447. X    ulong tin[2],tout[2];
  448. X    uchar *in,*out,*iv;
  449. X
  450. X    in=(uchar *)input;
  451. X    out=(uchar *)output;
  452. X    iv=(uchar *)ivec;
  453. X
  454. X    c2l(iv,tout0);
  455. X    c2l(iv,tout1);
  456. X    for (; l>0; l-=8)
  457. X        {
  458. X        if (l >= 8)
  459. X            {
  460. X            c2l(in,tin0);
  461. X            c2l(in,tin1);
  462. X            }
  463. X        else
  464. X            c2ln(in,tin0,tin1,l);
  465. X            
  466. X        tin0^=tout0;
  467. X        tin1^=tout1;
  468. X        tin[0]=tin0;
  469. X        tin[1]=tin1;
  470. X        des_encrypt((ulong *)tin,(ulong *)tout,schedule,DES_ENCRYPT);
  471. X        /* fix 15/10/91 eay - thanks to keithr@sco.COM */
  472. X        tout0=tout[0];
  473. X        tout1=tout[1];
  474. X        }
  475. X    l2c(tout0,out);
  476. X    l2c(tout1,out);
  477. X    tout0=tin0=tin1=tin[0]=tin[1]=tout[0]=tout[1]=0;
  478. X    return(tout1);
  479. X    }
  480. END_OF_FILE
  481. if test 901 -ne `wc -c <'cbc_cksum.c'`; then
  482.     echo shar: \"'cbc_cksum.c'\" unpacked with wrong size!
  483. fi
  484. # end of 'cbc_cksum.c'
  485. fi
  486. if test -f 'cbc_encrypt.c' -a "${1}" != "-c" ; then 
  487.   echo shar: Will not clobber existing file \"'cbc_encrypt.c'\"
  488. else
  489. echo shar: Extracting \"'cbc_encrypt.c'\" \(1327 characters\)
  490. sed "s/^X//" >'cbc_encrypt.c' <<'END_OF_FILE'
  491. X/* cbc_encrypt.c */
  492. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  493. X#include "des_local.h"
  494. X
  495. Xint des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
  496. Xdes_cblock *input;
  497. Xdes_cblock *output;
  498. Xlong length;
  499. Xdes_key_schedule schedule;
  500. Xdes_cblock *ivec;
  501. Xint encrypt;
  502. X    {
  503. X    register ulong tin0,tin1;
  504. X    register ulong tout0,tout1,xor0,xor1;
  505. X    register uchar *in,*out;
  506. X    register long l=length;
  507. X    ulong tout[2],tin[2];
  508. X    uchar *iv;
  509. X
  510. X    in=(uchar *)input;
  511. X    out=(uchar *)output;
  512. X    iv=(uchar *)ivec;
  513. X
  514. X    if (encrypt)
  515. X        {
  516. X        c2l(iv,tout0);
  517. X        c2l(iv,tout1);
  518. X        for (; l>0; l-=8)
  519. X            {
  520. X            if (l >= 8)
  521. X                {
  522. X                c2l(in,tin0);
  523. X                c2l(in,tin1);
  524. X                }
  525. X            else
  526. X                c2ln(in,tin0,tin1,l);
  527. X            tin0^=tout0;
  528. X            tin1^=tout1;
  529. X            tin[0]=tin0;
  530. X            tin[1]=tin1;
  531. X            des_encrypt((ulong *)tin,(ulong *)tout,
  532. X                schedule,encrypt);
  533. X            tout0=tout[0];
  534. X            tout1=tout[1];
  535. X            l2c(tout0,out);
  536. X            l2c(tout1,out);
  537. X            }
  538. X        }
  539. X    else
  540. X        {
  541. X        c2l(iv,xor0);
  542. X        c2l(iv,xor1);
  543. X        for (; l>0; l-=8)
  544. X            {
  545. X            c2l(in,tin0);
  546. X            c2l(in,tin1);
  547. X            tin[0]=tin0;
  548. X            tin[1]=tin1;
  549. X            des_encrypt((ulong *)tin,(ulong *)tout,
  550. X                schedule,encrypt);
  551. X            tout0=tout[0]^xor0;
  552. X            tout1=tout[1]^xor1;
  553. X            if (l >= 8)
  554. X                {
  555. X                l2c(tout0,out);
  556. X                l2c(tout1,out);
  557. X                }
  558. X            else
  559. X                l2cn(tout0,tout1,out,l);
  560. X            xor0=tin0;
  561. X            xor1=tin1;
  562. X            }
  563. X        }
  564. X    tin0=tin1=tout0=tout1=xor0=xor1=0;
  565. X    return(0);
  566. X    }
  567. X
  568. END_OF_FILE
  569. if test 1327 -ne `wc -c <'cbc_encrypt.c'`; then
  570.     echo shar: \"'cbc_encrypt.c'\" unpacked with wrong size!
  571. fi
  572. # end of 'cbc_encrypt.c'
  573. fi
  574. if test -f 'des.h' -a "${1}" != "-c" ; then 
  575.   echo shar: Will not clobber existing file \"'des.h'\"
  576. else
  577. echo shar: Extracting \"'des.h'\" \(1176 characters\)
  578. sed "s/^X//" >'des.h' <<'END_OF_FILE'
  579. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  580. Xtypedef unsigned char des_cblock[8];
  581. Xtypedef struct des_ks_struct
  582. X    {
  583. X    des_cblock _;
  584. X    } des_key_schedule[16];
  585. X
  586. X#define DES_KEY_SZ     (sizeof(des_cblock))
  587. X#define DES_ENCRYPT    1
  588. X#define DES_DECRYPT    0
  589. X
  590. X#define DES_CBC_MODE    0
  591. X#define DES_PCBC_MODE    1
  592. Xextern int des_rw_mode;
  593. X
  594. X#define C_Block des_cblock
  595. X#define Key_schedule des_key_schedule
  596. X#define ENCRYPT DES_ENCRYPT
  597. X#define DECRYPT DES_DECRYPT
  598. X#define KEY_SZ DES_KEY_SZ
  599. X#define string_to_key des_string_to_key
  600. X#define read_pw_string des_read_pw_string
  601. X#define random_key des_random_key
  602. X#define pcbc_encrypt des_pcbc_encrypt
  603. X#define set_key des_set_key
  604. X#define key_sched des_key_sched
  605. X#define cbc_encrypt des_cbc_encrypt
  606. X#define cbc_cksum des_cbc_cksum
  607. X#define quad_cksum des_quad_cksum
  608. X
  609. Xint des_read_password();
  610. Xint des_string_to_key();
  611. Xint des_read_pw_string();
  612. Xint des_random_key();
  613. Xint des_set_key();
  614. Xint des_key_sched();
  615. Xint des_ecb_encrypt();
  616. Xint des_cbc_encrypt();
  617. Xint des_pcbc_encrypt();
  618. Xunsigned long des_cbc_cksum();
  619. Xunsigned long des_quad_cksum();
  620. Xint des_enc_read();
  621. Xint des_enc_write();
  622. Xchar *crypt();
  623. X
  624. Xextern int des_check_key; /* default is false */
  625. END_OF_FILE
  626. if test 1176 -ne `wc -c <'des.h'`; then
  627.     echo shar: \"'des.h'\" unpacked with wrong size!
  628. fi
  629. # end of 'des.h'
  630. fi
  631. if test -f 'des.man' -a "${1}" != "-c" ; then 
  632.   echo shar: Will not clobber existing file \"'des.man'\"
  633. else
  634. echo shar: Extracting \"'des.man'\" \(1897 characters\)
  635. sed "s/^X//" >'des.man' <<'END_OF_FILE'
  636. X.TH DES 1 
  637. X.SH NAME
  638. Xdes - encrypt or decrypt data using Data Encryption Standard
  639. X.SH SYNOPSIS
  640. X.B des
  641. X.B \-e
  642. X|
  643. X.B \-d
  644. X[
  645. X.B \-bfs
  646. X] [
  647. X.B \-k
  648. X.I key
  649. X] [
  650. X.I input-file
  651. X[
  652. X.I output-file
  653. X] ]
  654. X.SH DESCRIPTION
  655. X.B des
  656. Xencrypts and decrypts data using the
  657. XData Encryption Standard algorithm.
  658. XOne of
  659. X.B \-e
  660. X(for encrypt) or
  661. X.B \-d
  662. X(for decrypt) must be specified.
  663. X.LP
  664. XTwo standard encryption modes are supported by the
  665. X.B des
  666. Xprogram, Cipher Block Chaining (the default) and Electronic Code Book
  667. X(specified with
  668. X.B \-b
  669. X).
  670. X.LP
  671. XThe key used for the
  672. X.B DES
  673. Xalgorithm is obtained by prompting the user unless the
  674. X.B `\-k
  675. X.I key '
  676. Xoption is given.
  677. XIf the key is an argument to the
  678. X.B des
  679. Xcommand, it is potentially visible to users executing
  680. X.BR ps (1)
  681. Xor a derivative.  To minimize this possibility,
  682. X.B des
  683. Xtakes care to destroy the key argument immediately upon entry.
  684. XIf your shell keeps a history file be careful to make sure it is not
  685. Xworld readable.
  686. X.LP
  687. XThe
  688. X.B des
  689. Xcommand reads from standard input unless
  690. X.I input-file
  691. Xis specified and writes to standard output unless
  692. X.I output-file
  693. Xis given.
  694. X.SH OPTIONS
  695. X.TP
  696. X.B \-b
  697. XSelect ECB
  698. X(eight bytes at a time) encryption mode.
  699. X.TP
  700. X.B \-d
  701. XDecrypt data.
  702. X.TP
  703. X.B \-e
  704. XEncrypt data.
  705. X.TP
  706. X.B \-f
  707. XDoes nothing - allowed for compatibility with sunOS des(1) command.
  708. X.TP
  709. X.B \-s
  710. XDoes nothing - allowed for compatibility with sunOS des(1) command.
  711. X.TP
  712. X.I \-k " key"
  713. XUse the encryption 
  714. X.I key
  715. Xspecified.
  716. X.SH SEE ALSO
  717. X.B ps (1)
  718. X.B des_crypt(3)
  719. X.SH BUGS
  720. X.LP
  721. XIt would be better to use a real 56-bit key rather than an
  722. XASCII-based
  723. X56-bit pattern.  Knowing that the key was derived from ASCII
  724. Xradically reduces
  725. Xthe time necessary for a brute-force cryptographic attack.
  726. X.SH AUTHOR
  727. X.LP
  728. XEric Young (eay@psych.psy.uq.oz.au), Psychology Department,
  729. XUniversity of Queensland, Australia.
  730. X.SH RESTRICTIONS
  731. X.LP
  732. XThis software was written in Australia and should be available
  733. Xoutside the USA.
  734. END_OF_FILE
  735. if test 1897 -ne `wc -c <'des.man'`; then
  736.     echo shar: \"'des.man'\" unpacked with wrong size!
  737. fi
  738. # end of 'des.man'
  739. fi
  740. if test -f 'des_local.h' -a "${1}" != "-c" ; then 
  741.   echo shar: Will not clobber existing file \"'des_local.h'\"
  742. else
  743. echo shar: Extracting \"'des_local.h'\" \(1613 characters\)
  744. sed "s/^X//" >'des_local.h' <<'END_OF_FILE'
  745. X/* des_local.h */
  746. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  747. X#include <stdio.h>
  748. X#include "des.h"
  749. X
  750. Xtypedef unsigned char uchar;
  751. Xtypedef unsigned short ushort;
  752. Xtypedef unsigned int uint;
  753. Xtypedef unsigned long ulong;
  754. X
  755. X#define ITERATIONS 16
  756. X#define HALF_ITERATIONS 8
  757. X
  758. X/* used in des_read and des_write */
  759. X#define MAXWRITE    (1024*16)
  760. X#define BSIZE        (MAXWRITE+4)
  761. X
  762. X#define c2l(c,l)    (l =((ulong)(*((c)++)))    , \
  763. X             l|=((ulong)(*((c)++)))<< 8, \
  764. X             l|=((ulong)(*((c)++)))<<16, \
  765. X             l|=((ulong)(*((c)++)))<<24)
  766. X
  767. X/* NOTE - c is not incremented as per c2l */
  768. X#define c2ln(c,l1,l2,n)    { \
  769. X            c+=n; \
  770. X            l1=l2=0; \
  771. X            switch (n) { \
  772. X            case 7: l2|=((ulong)(*(--(c))))<<16; \
  773. X            case 6: l2|=((ulong)(*(--(c))))<< 8; \
  774. X            case 5: l2|=((ulong)(*(--(c))));     \
  775. X            case 4: l1|=((ulong)(*(--(c))))<<24; \
  776. X            case 3: l1|=((ulong)(*(--(c))))<<16; \
  777. X            case 2: l1|=((ulong)(*(--(c))))<< 8; \
  778. X            case 1: l1|=((ulong)(*(--(c))));     \
  779. X                } \
  780. X            }
  781. X
  782. X#define l2c(l,c)    (*((c)++)=(uchar)(((l)    )&0xff), \
  783. X             *((c)++)=(uchar)(((l)>> 8)&0xff), \
  784. X             *((c)++)=(uchar)(((l)>>16)&0xff), \
  785. X             *((c)++)=(uchar)(((l)>>24)&0xff))
  786. X
  787. X/* NOTE - c is not incremented as per l2c */
  788. X#define l2cn(l1,l2,c,n)    { \
  789. X            c+=n; \
  790. X            switch (n) { \
  791. X            case 7: *(--(c))=(uchar)(((l2)>>16)&0xff); \
  792. X            case 6: *(--(c))=(uchar)(((l2)>> 8)&0xff); \
  793. X            case 5: *(--(c))=(uchar)(((l2)    )&0xff); \
  794. X            case 4: *(--(c))=(uchar)(((l1)>>24)&0xff); \
  795. X            case 3: *(--(c))=(uchar)(((l1)>>16)&0xff); \
  796. X            case 2: *(--(c))=(uchar)(((l1)>> 8)&0xff); \
  797. X            case 1: *(--(c))=(uchar)(((l1)    )&0xff); \
  798. X                } \
  799. X            }
  800. X
  801. Xextern void des_set_odd_parity();
  802. END_OF_FILE
  803. if test 1613 -ne `wc -c <'des_local.h'`; then
  804.     echo shar: \"'des_local.h'\" unpacked with wrong size!
  805. fi
  806. # end of 'des_local.h'
  807. fi
  808. if test -f 'doIP' -a "${1}" != "-c" ; then 
  809.   echo shar: Will not clobber existing file \"'doIP'\"
  810. else
  811. echo shar: Extracting \"'doIP'\" \(831 characters\)
  812. sed "s/^X//" >'doIP' <<'END_OF_FILE'
  813. X#!/usr/local/bin/perl
  814. X
  815. X@l=(
  816. X     0, 1, 2, 3, 4, 5, 6, 7,
  817. X     8, 9,10,11,12,13,14,15,
  818. X    16,17,18,19,20,21,22,23,
  819. X    24,25,26,27,28,29,30,31
  820. X    );
  821. X@r=(
  822. X    32,33,34,35,36,37,38,39,
  823. X    40,41,42,43,44,45,46,47,
  824. X    48,49,50,51,52,53,54,55,
  825. X    56,57,58,59,60,61,62,63
  826. X    );
  827. X
  828. Xrequire 'shifts.pl';
  829. X
  830. Xsub PERM_OP
  831. X    {
  832. X    local(*a,*b,*t,$n,$m)=@_;
  833. X
  834. X    @z=&shift(*a,-$n);
  835. X    @z=&xor(*b,*z);
  836. X    @z=&and(*z,$m);
  837. X    @b=&xor(*b,*z);
  838. X    @z=&shift(*z,$n);
  839. X    @a=&xor(*a,*z);
  840. X    }
  841. X
  842. X
  843. X@L=@l;
  844. X@R=@r;
  845. X&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
  846. X&PERM_OP(*L,*R,*T,16,0x0000ffff);
  847. X&PERM_OP(*R,*L,*T,2,0x33333333);
  848. X&PERM_OP(*L,*R,*T,8,0x00ff00ff);
  849. X&PERM_OP(*R,*L,*T,1,0x55555555);
  850. X    &printit(@L);
  851. X    &printit(@R);
  852. X&PERM_OP(*R,*L,*T,1,0x55555555);
  853. X&PERM_OP(*L,*R,*T,8,0x00ff00ff);
  854. X&PERM_OP(*R,*L,*T,2,0x33333333);
  855. X&PERM_OP(*L,*R,*T,16,0x0000ffff);
  856. X&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
  857. X    &printit(@L);
  858. X    &printit(@R);
  859. END_OF_FILE
  860. if test 831 -ne `wc -c <'doIP'`; then
  861.     echo shar: \"'doIP'\" unpacked with wrong size!
  862. fi
  863. # end of 'doIP'
  864. fi
  865. if test -f 'doPC1' -a "${1}" != "-c" ; then 
  866.   echo shar: Will not clobber existing file \"'doPC1'\"
  867. else
  868. echo shar: Extracting \"'doPC1'\" \(1661 characters\)
  869. sed "s/^X//" >'doPC1' <<'END_OF_FILE'
  870. X#!/usr/local/bin/perl
  871. X
  872. X@l=(
  873. X     0, 1, 2, 3, 4, 5, 6, 7,
  874. X     8, 9,10,11,12,13,14,15,
  875. X    16,17,18,19,20,21,22,23,
  876. X    24,25,26,27,28,29,30,31
  877. X    );
  878. X@r=(
  879. X    32,33,34,35,36,37,38,39,
  880. X    40,41,42,43,44,45,46,47,
  881. X    48,49,50,51,52,53,54,55,
  882. X    56,57,58,59,60,61,62,63
  883. X    );
  884. X
  885. Xrequire 'shifts.pl';
  886. X
  887. Xsub PERM_OP
  888. X    {
  889. X    local(*a,*b,*t,$n,$m)=@_;
  890. X
  891. X    @z=&shift(*a,-$n);
  892. X    @z=&xor(*b,*z);
  893. X    @z=&and(*z,$m);
  894. X    @b=&xor(*b,*z);
  895. X    @z=&shift(*z,$n);
  896. X    @a=&xor(*a,*z);
  897. X    }
  898. X
  899. Xsub HPERM_OP2
  900. X    {
  901. X    local(*a,*t,$n,$m)=@_;
  902. X    local(@x,@y,$i);
  903. X
  904. X    @z=&shift(*a,16-$n);
  905. X    @z=&xor(*a,*z);
  906. X    @z=&and(*z,$m);
  907. X    @a=&xor(*a,*z);
  908. X    @z=&shift(*z,$n-16);
  909. X    @a=&xor(*a,*z);
  910. X    }
  911. X
  912. Xsub HPERM_OP
  913. X        {
  914. X        local(*a,*t,$n,$m)=@_;
  915. X        local(@x,@y,$i);
  916. X
  917. X        for ($i=0; $i<16; $i++)
  918. X                {
  919. X                $x[$i]=$a[$i];
  920. X                $y[$i]=$a[16+$i];
  921. X                }
  922. X        @z=&shift(*x,-$n);
  923. X        @z=&xor(*y,*z);
  924. X        @z=&and(*z,$m);
  925. X        @y=&xor(*y,*z);
  926. X        @z=&shift(*z,$n);
  927. X        @x=&xor(*x,*z);
  928. X        for ($i=0; $i<16; $i++)
  929. X                {
  930. X                $a[$i]=$x[$i];
  931. X                $a[16+$i]=$y[$i];
  932. X                }
  933. X        }
  934. X
  935. X@L=@l;
  936. X@R=@r;
  937. X&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
  938. X
  939. X&HPERM_OP2(*L,*T,-2, 0xcccc0000);
  940. X&HPERM_OP2(*L,*T,-1, 0xaaaa0000);
  941. X&HPERM_OP2(*L,*T,8,  0x00ff0000);
  942. X&HPERM_OP2(*L,*T,-1, 0xaaaa0000);
  943. X
  944. X&HPERM_OP2(*R,*T,-8, 0xff000000);
  945. X&HPERM_OP2(*R,*T,8,  0x00ff0000);
  946. X&HPERM_OP2(*R,*T,2,  0x33330000);
  947. X
  948. X@A=&and(*R,0x00aa00aa);
  949. X@A=&shift(*A,7);
  950. X@B=&and(*R,0x55005500);
  951. X@B=&shift(*B,-7);
  952. X@C=&and(*R,0xaa55aa55);
  953. X@R=&or(*A,*B);
  954. X@R=&or(*R,*C);
  955. X
  956. X@T=&and(*L,0xf0000000);
  957. X@T=&shift(*T,-4);
  958. X@R=&shift(*R,-8);
  959. X@R=&or(*R,*T);
  960. X@L=&and(*L,0x0fffffff);
  961. X    &printit(@L);
  962. X    &printit(@R);
  963. END_OF_FILE
  964. if test 1661 -ne `wc -c <'doPC1'`; then
  965.     echo shar: \"'doPC1'\" unpacked with wrong size!
  966. fi
  967. # end of 'doPC1'
  968. fi
  969. if test -f 'doPC2' -a "${1}" != "-c" ; then 
  970.   echo shar: Will not clobber existing file \"'doPC2'\"
  971. else
  972. echo shar: Extracting \"'doPC2'\" \(1578 characters\)
  973. sed "s/^X//" >'doPC2' <<'END_OF_FILE'
  974. X#!/usr/local/bin/perl
  975. X
  976. X@PC2_C=(14,17,11,24, 1, 5,
  977. X     3,28,15, 6,21,10,
  978. X    23,19,12, 4,26, 8,
  979. X    16, 7,27,20,13, 2,
  980. X    );
  981. X
  982. X@PC2_D=(41,52,31,37,47,55,
  983. X    30,40,51,45,33,48,
  984. X    44,49,39,56,34,53,
  985. X    46,42,50,36,29,32,
  986. X    );
  987. X
  988. X$i=0;
  989. Xforeach (@PC2_C) {
  990. X    $_--;
  991. X#    printf "%2d,",$_;
  992. X    $C{$_}=$i;
  993. X    ++$i;
  994. X#    print "\n" if ((($i) % 8) == 0);
  995. X    }
  996. X$i=0;
  997. X#print "\n";
  998. Xforeach (@PC2_D) {
  999. X    $_-=28;
  1000. X    $_--;
  1001. X#    printf "%2d,",$_;
  1002. X    $D{$_}=$i;
  1003. X    $i++;
  1004. X#    print "\n" if ((($i) % 8) == 0);
  1005. X    }
  1006. X
  1007. X#print "\n";
  1008. Xforeach $i (0 .. 27)
  1009. X    {
  1010. X    $_=$C{$i};
  1011. X#    printf "%2d,",$_;
  1012. X    $i++;
  1013. X#    print "\n" if ((($i) % 8) == 0);
  1014. X    }
  1015. X#print "\n";
  1016. X
  1017. X#print "\n";
  1018. Xforeach $i (0 .. 27)
  1019. X    {
  1020. X    $_=$D{$i};
  1021. X#    printf "%2d,",$_;
  1022. X    $i++;
  1023. X#    print "\n" if ((($i) % 8) == 0);
  1024. X    }
  1025. X#print "\n";
  1026. X
  1027. Xprint "static ulong skb[8][64]={\n";
  1028. X&doit("C",*C, 0, 1, 2, 3, 4, 5);
  1029. X&doit("C",*C, 6, 7, 9,10,11,12);
  1030. X&doit("C",*C,13,14,15,16,18,19);
  1031. X&doit("C",*C,20,22,23,25,26,27);
  1032. X
  1033. X&doit("D",*D, 0, 1, 2, 3, 4, 5);
  1034. X&doit("D",*D, 7, 8,10,11,12,13);
  1035. X&doit("D",*D,15,16,17,18,19,20);
  1036. X&doit("D",*D,21,22,23,24,26,27);
  1037. Xprint "};\n";
  1038. X
  1039. Xsub doit
  1040. X    {
  1041. X    local($l,*A,@b)=@_;
  1042. X    local(@out);
  1043. X
  1044. X    printf("/* for $l bits (numbered as per FIPS 46) %d %d %d %d %d %d */\n",
  1045. X        $b[0]+1, $b[1]+1, $b[2]+1, $b[3]+1, $b[4]+1, $b[5]+1);
  1046. X    for ($i=0; $i<64; $i++)
  1047. X        {
  1048. X        $out[$i]=0;
  1049. X        $j=1;
  1050. X#print "\n";
  1051. X        for ($k=0; $k<6; $k++)
  1052. X            {
  1053. X            $l=$A{$b[$k]};
  1054. X#print"$l - ";
  1055. X            if ((1<<$k) & $i)
  1056. X                {
  1057. X                $ll=int($l/6)*8+($l%6);
  1058. X                $out[$i]|=1<<($ll);
  1059. X                }
  1060. X            }
  1061. X        $pp=$out[$i];
  1062. X        $pp=($pp&0xff0000ff)|   (($pp&0x00ff0000)>>8)|
  1063. X                    (($pp&0x0000ff00)<<8);
  1064. X        printf("0x%08X,",$pp);
  1065. X        print "\n" if (($i+1) % 4 == 0);
  1066. X        }
  1067. X    }
  1068. END_OF_FILE
  1069. if test 1578 -ne `wc -c <'doPC2'`; then
  1070.     echo shar: \"'doPC2'\" unpacked with wrong size!
  1071. fi
  1072. # end of 'doPC2'
  1073. fi
  1074. if test -f 'ecb_encrypt.c' -a "${1}" != "-c" ; then 
  1075.   echo shar: Will not clobber existing file \"'ecb_encrypt.c'\"
  1076. else
  1077. echo shar: Extracting \"'ecb_encrypt.c'\" \(3600 characters\)
  1078. sed "s/^X//" >'ecb_encrypt.c' <<'END_OF_FILE'
  1079. X/* ecb_encrypt.c */
  1080. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1081. X#include "des_local.h"
  1082. X#include "sp.h"
  1083. X
  1084. Xint des_ecb_encrypt(input,output,ks,encrypt)
  1085. Xdes_cblock *input;
  1086. Xdes_cblock *output;
  1087. Xdes_key_schedule ks;
  1088. Xint encrypt;
  1089. X    {
  1090. X    register ulong l0,l1;
  1091. X    register uchar *in,*out;
  1092. X    ulong ll[2];
  1093. X
  1094. X    in=(uchar *)input;
  1095. X    out=(uchar *)output;
  1096. X    c2l(in,l0);
  1097. X    c2l(in,l1);
  1098. X    ll[0]=l0;
  1099. X    ll[1]=l1;
  1100. X    des_encrypt(ll,ll,ks,encrypt);
  1101. X    l0=ll[0];
  1102. X    l1=ll[1];
  1103. X    l2c(l0,out);
  1104. X    l2c(l1,out);
  1105. X    return(0);
  1106. X    }
  1107. X
  1108. X#define D_ENCRYPT(L,R,S)    \
  1109. X    t=(R<<1)|(R>>31); \
  1110. X    u=(t^s[S  ]); \
  1111. X    t=(t^s[S+1]); \
  1112. X    t=(t>>4)|(t<<28); \
  1113. X    L^=    des_SPtrans[1][(t    )&0x3f]| \
  1114. X        des_SPtrans[3][(t>> 8)&0x3f]| \
  1115. X        des_SPtrans[5][(t>>16)&0x3f]| \
  1116. X        des_SPtrans[7][(t>>24)&0x3f]| \
  1117. X        des_SPtrans[0][(u    )&0x3f]| \
  1118. X        des_SPtrans[2][(u>> 8)&0x3f]| \
  1119. X        des_SPtrans[4][(u>>16)&0x3f]| \
  1120. X        des_SPtrans[6][(u>>24)&0x3f];
  1121. X
  1122. X    /* IP and FP
  1123. X     * The problem is more of a geometric problem that random bit fiddling.
  1124. X     0  1  2  3  4  5  6  7      62 54 46 38 30 22 14  6
  1125. X     8  9 10 11 12 13 14 15      60 52 44 36 28 20 12  4
  1126. X        16 17 18 19 20 21 22 23      58 50 42 34 26 18 10  2
  1127. X    24 25 26 27 28 29 30 31  to  56 48 40 32 24 16  8  0
  1128. X
  1129. X    32 33 34 35 36 37 38 39      63 55 47 39 31 23 15  7
  1130. X    40 41 42 43 44 45 46 47      61 53 45 37 29 21 13  5
  1131. X    48 49 50 51 52 53 54 55      59 51 43 35 27 19 11  3
  1132. X    56 57 58 59 60 61 62 63      57 49 41 33 25 17  9  1
  1133. X
  1134. X    The output has been subject to swaps of the form
  1135. X    0 1 -> 3 1 but the odd and even bits have been put into
  1136. X    2 3    2 0 
  1137. X    different words.  The main trick is to remember that
  1138. X    t=((l>>size)^r)&(mask);
  1139. X    r^=t;
  1140. X    l^=(t<<size);
  1141. X    can be used to swap and move bits between words.
  1142. X
  1143. X    So l =  0  1  2  3  r = 16 17 18 19
  1144. X            4  5  6  7      20 21 22 23
  1145. X            8  9 10 11      24 25 26 27
  1146. X           12 13 14 15      28 29 30 31
  1147. X    becomes (for size == 2 and mask == 0x3333)
  1148. X       t =   2^16  3^17 -- --   l =  0  1 16 17  r =  2  3 18 19
  1149. X         6^20  7^21 -- --        4  5 20 21       6  7 22 23
  1150. X        10^24 11^25 -- --        8  9 24 25      10 11 24 25
  1151. X                14^28 15^29 -- --       12 13 28 29      14 15 28 29
  1152. X
  1153. X    Thanks for hints from Richard Outerbridge - he told me IP&FP
  1154. X    could be done in 15 xor, 10 shifts and 5 ands.
  1155. X    When I finally started to think of the problem in 2D
  1156. X    I first got ~42 operations without xors.  When I remembered
  1157. X    how to use xors :-) I got it to its final state.
  1158. X    */
  1159. X#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
  1160. X    (b)^=(t),\
  1161. X    (a)^=((t)<<(n)))
  1162. X
  1163. Xint des_encrypt(input,output,ks,encrypt)
  1164. Xulong *input;
  1165. Xulong *output;
  1166. Xdes_key_schedule ks;
  1167. Xint encrypt;
  1168. X    {
  1169. X    register ulong l,r,t,u;
  1170. X    register int i;
  1171. X    register ulong *s;
  1172. X
  1173. X    l=input[0];
  1174. X    r=input[1];
  1175. X
  1176. X    /* do IP */
  1177. X    PERM_OP(r,l,t, 4,0x0f0f0f0f);
  1178. X    PERM_OP(l,r,t,16,0x0000ffff);
  1179. X    PERM_OP(r,l,t, 2,0x33333333);
  1180. X    PERM_OP(l,r,t, 8,0x00ff00ff);
  1181. X    PERM_OP(r,l,t, 1,0x55555555);
  1182. X    /* r and l are reversed - remember that :-) */
  1183. X    t=l;
  1184. X    l=r;
  1185. X    r=t;
  1186. X
  1187. X    s=(ulong *)ks;
  1188. X
  1189. X    /* I don't know if it is worth the effort of loop unrolling the
  1190. X     * inner loop */
  1191. X    if (encrypt)
  1192. X        {
  1193. X        for (i=0; i<32; i+=4)
  1194. X            {
  1195. X            D_ENCRYPT(l,r,i+0); /*  1 */
  1196. X            D_ENCRYPT(r,l,i+2); /*  2 */
  1197. X            }
  1198. X        }
  1199. X    else
  1200. X        {
  1201. X        for (i=30; i>0; i-=4)
  1202. X            {
  1203. X            D_ENCRYPT(l,r,i-0); /* 16 */
  1204. X            D_ENCRYPT(r,l,i-2); /* 15 */
  1205. X            }
  1206. X        }
  1207. X
  1208. X    /* swap l and r
  1209. X     * we will not do the swap so just remember they are
  1210. X     * reversed for the rest of the subroutine
  1211. X     * luckily FP fixes this problem :-) */
  1212. X
  1213. X    PERM_OP(r,l,t, 1,0x55555555);
  1214. X    PERM_OP(l,r,t, 8,0x00ff00ff);
  1215. X    PERM_OP(r,l,t, 2,0x33333333);
  1216. X    PERM_OP(l,r,t,16,0x0000ffff);
  1217. X    PERM_OP(r,l,t, 4,0x0f0f0f0f);
  1218. X
  1219. X    output[0]=l;
  1220. X    output[1]=r;
  1221. X    return(0);
  1222. X    }
  1223. X
  1224. END_OF_FILE
  1225. if test 3600 -ne `wc -c <'ecb_encrypt.c'`; then
  1226.     echo shar: \"'ecb_encrypt.c'\" unpacked with wrong size!
  1227. fi
  1228. # end of 'ecb_encrypt.c'
  1229. fi
  1230. if test -f 'enc_read.c' -a "${1}" != "-c" ; then 
  1231.   echo shar: Will not clobber existing file \"'enc_read.c'\"
  1232. else
  1233. echo shar: Extracting \"'enc_read.c'\" \(3122 characters\)
  1234. sed "s/^X//" >'enc_read.c' <<'END_OF_FILE'
  1235. X/* des_read.c */
  1236. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1237. X#include <errno.h>
  1238. X#include "des_local.h"
  1239. X
  1240. X/* This has some uglies in it but it works - even over sockets. */
  1241. Xextern int errno;
  1242. Xint des_rw_mode=DES_PCBC_MODE;
  1243. X
  1244. Xint des_enc_read(fd,buf,len,sched,iv)
  1245. Xint fd;
  1246. Xchar *buf;
  1247. Xint len;
  1248. Xdes_key_schedule sched;
  1249. Xdes_cblock *iv;
  1250. X    {
  1251. X    /* data to be unencrypted */
  1252. X    int net_num=0;
  1253. X    char net[BSIZE];
  1254. X    /* extra unencrypted data 
  1255. X     * for when a block of 100 comes in but is des_read one byte at
  1256. X     * a time. */
  1257. X    static char unnet[BSIZE];
  1258. X    static int unnet_start=0;
  1259. X    static int unnet_left=0;
  1260. X    int i;
  1261. X    long num=0,rnum;
  1262. X
  1263. X    /* left over data from last decrypt */
  1264. X    if (unnet_left != 0)
  1265. X        {
  1266. X        if (unnet_left < len)
  1267. X            {
  1268. X            /* we still still need more data but will return
  1269. X             * with the number of bytes we have - should always
  1270. X             * check the return value */
  1271. X            bcopy(&(unnet[unnet_start]),buf,unnet_left);
  1272. X            unnet_start=unnet_left=0;
  1273. X            i=unnet_left;
  1274. X            }
  1275. X        else
  1276. X            {
  1277. X            bcopy(&(unnet[unnet_start]),buf,len);
  1278. X            unnet_start+=len;
  1279. X            unnet_left-=len;
  1280. X            i=len;
  1281. X            }
  1282. X        return(i);
  1283. X        }
  1284. X
  1285. X    /* We need to get more data. */
  1286. X    if (len > MAXWRITE) len=MAXWRITE;
  1287. X
  1288. X    /* first - get the length */
  1289. X    net_num=0;
  1290. X    while (net_num < sizeof(long)) 
  1291. X        {
  1292. X        i=read(fd,&(net[net_num]),sizeof(long)-net_num);
  1293. X        if ((i == -1) && (errno == EINTR)) continue;
  1294. X        if (i <= 0) return(0);
  1295. X        net_num+=i;
  1296. X        }
  1297. X
  1298. X    /* we now have at net_num bytes in net */
  1299. X    bcopy(&(net[0]),&num,sizeof(long));
  1300. X    num=ntohl(num);
  1301. X    /* num should be rounded up to the next group of eight
  1302. X     * we make sure that we have read a multiple of 8 bytes from the net.
  1303. X     */
  1304. X    rnum=(num < 8)?8:((num+7)/8*8);
  1305. X    net_num=0;
  1306. X    while (net_num < rnum)
  1307. X        {
  1308. X        i=read(fd,&(net[net_num]),rnum-net_num);
  1309. X        if ((i == -1) && (errno == EINTR)) continue;
  1310. X        if (i <= 0) return(0);
  1311. X        net_num+=i;
  1312. X        }
  1313. X
  1314. X    /* Check if there will be data left over. */
  1315. X    if (len < num)
  1316. X        {
  1317. X        if (des_rw_mode == DES_PCBC_MODE)
  1318. X            pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
  1319. X                num,sched,iv,DES_DECRYPT);
  1320. X        else
  1321. X            cbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
  1322. X                num,sched,iv,DES_DECRYPT);
  1323. X        bcopy(unnet,buf,len);
  1324. X        unnet_start=len;
  1325. X        unnet_left=num-len;
  1326. X
  1327. X        /* The following line is done because we return num
  1328. X         * as the number of bytes read. */
  1329. X        num=len;
  1330. X        }
  1331. X    else
  1332. X        {
  1333. X        /* >output is a multiple of 8 byes, if len < rnum
  1334. X         * >we must be careful.  The user must be aware that this
  1335. X         * >routine will write more bytes than he asked for.
  1336. X         * >The length of the buffer must be correct.
  1337. X         * FIXED - Should be ok now 18-9-90 - eay */
  1338. X        if (len < rnum)
  1339. X            {
  1340. X            char tmpbuf[BSIZE];
  1341. X
  1342. X            if (des_rw_mode == DES_PCBC_MODE)
  1343. X                pcbc_encrypt((des_cblock *)net,
  1344. X                    (des_cblock *)tmpbuf,
  1345. X                    num,sched,iv,DES_DECRYPT);
  1346. X            else
  1347. X                cbc_encrypt((des_cblock *)net,
  1348. X                    (des_cblock *)tmpbuf,
  1349. X                    num,sched,iv,DES_DECRYPT);
  1350. X
  1351. X            bcopy(tmpbuf,buf,len);
  1352. X            }
  1353. X        else
  1354. X            {
  1355. X            if (des_rw_mode == DES_PCBC_MODE)
  1356. X                pcbc_encrypt((des_cblock *)net,
  1357. X                    (des_cblock *)buf,num,sched,iv,
  1358. X                    DES_DECRYPT);
  1359. X            else
  1360. X                cbc_encrypt((des_cblock *)net,
  1361. X                    (des_cblock *)buf,num,sched,iv,
  1362. X                    DES_DECRYPT);
  1363. X            }
  1364. X        }
  1365. X    return(num);
  1366. X    }
  1367. X
  1368. END_OF_FILE
  1369. if test 3122 -ne `wc -c <'enc_read.c'`; then
  1370.     echo shar: \"'enc_read.c'\" unpacked with wrong size!
  1371. fi
  1372. # end of 'enc_read.c'
  1373. fi
  1374. if test -f 'enc_write.c' -a "${1}" != "-c" ; then 
  1375.   echo shar: Will not clobber existing file \"'enc_write.c'\"
  1376. else
  1377. echo shar: Extracting \"'enc_write.c'\" \(1616 characters\)
  1378. sed "s/^X//" >'enc_write.c' <<'END_OF_FILE'
  1379. X/* des_enc_write */
  1380. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1381. X#include <errno.h>
  1382. X#include "des_local.h"
  1383. X
  1384. Xint des_enc_write(fd,buf,len,sched,iv)
  1385. Xint fd;
  1386. Xchar *buf;
  1387. Xint len;
  1388. Xdes_key_schedule sched;
  1389. Xdes_cblock *iv;
  1390. X    {
  1391. X    long l,rnum;
  1392. X    int i,j,k;
  1393. X    char outbuf[BSIZE];
  1394. X    char shortbuf[8];
  1395. X    char *p;
  1396. X    static int start=1;
  1397. X
  1398. X    /* If we are sending less than 8 bytes, the same char will look
  1399. X     * the same if we don't pad it out with random bytes */
  1400. X    if (start)
  1401. X        {
  1402. X        start=0;
  1403. X        srandom(time(NULL));
  1404. X        }
  1405. X
  1406. X    /* lets recurse if we want to send the data in small chunks */
  1407. X    if (len > MAXWRITE)
  1408. X        {
  1409. X        j=0;
  1410. X        for (i=0; i<len; i+=k)
  1411. X            {
  1412. X            k=des_enc_write(fd,&(buf[i]),
  1413. X                ((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv);
  1414. X            if (k < 0)
  1415. X                return(k);
  1416. X            else
  1417. X                j+=k;
  1418. X            }
  1419. X        return(j);
  1420. X        }
  1421. X
  1422. X    /* pad short strings */
  1423. X    if (len < 8)
  1424. X        {
  1425. X        p=shortbuf;
  1426. X        bcopy(buf,shortbuf,len);
  1427. X        for (i=len; i<8; i++)
  1428. X            shortbuf[i]=random();
  1429. X        rnum=8;
  1430. X        }
  1431. X    else
  1432. X        {
  1433. X        p=buf;
  1434. X        rnum=((len+7)/8*8); /* round up to nearest eight */
  1435. X        }
  1436. X
  1437. X    /* write length first */
  1438. X    l=htonl(len);
  1439. X    bcopy(&l,outbuf,sizeof(long));
  1440. X    if (des_rw_mode == DES_PCBC_MODE)
  1441. X        pcbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[4]),
  1442. X            (long)((len<8)?8:len),sched,iv,DES_ENCRYPT); 
  1443. X    else
  1444. X        cbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[4]),
  1445. X            (long)((len<8)?8:len),sched,iv,DES_ENCRYPT); 
  1446. X
  1447. X    /* output */
  1448. X    for (j=0; j<rnum+4; j+=i)
  1449. X        {
  1450. X        i=write(fd,outbuf,(int)(rnum+4));
  1451. X        if (i == -1)
  1452. X            {
  1453. X            if (errno == EINTR)
  1454. X                i=0;
  1455. X            else     /* This is really a bad error - very bad
  1456. X                 * It will stuff-up both ends. */
  1457. X                return(-1);
  1458. X            }
  1459. X        }
  1460. X
  1461. X    return(len);
  1462. X    }
  1463. END_OF_FILE
  1464. if test 1616 -ne `wc -c <'enc_write.c'`; then
  1465.     echo shar: \"'enc_write.c'\" unpacked with wrong size!
  1466. fi
  1467. # end of 'enc_write.c'
  1468. fi
  1469. if test -f 'makefile' -a "${1}" != "-c" ; then 
  1470.   echo shar: Will not clobber existing file \"'makefile'\"
  1471. else
  1472. echo shar: Extracting \"'makefile'\" \(1174 characters\)
  1473. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  1474. X#CC=gcc
  1475. X#CFLAGS= -O2
  1476. XCC=cc
  1477. XCFLAGS= -O
  1478. X
  1479. XOBJS=    cbc_cksum.o cbc_encrypt.o ecb_encrypt.o pcbc_encrypt.o \
  1480. X    quad_cksum.o random_key.o read_password.o set_key.o string_to_key.o \
  1481. X    enc_read.o enc_write.o fcrypt.o
  1482. X
  1483. XGENERAL=COPYING FILES INSTALLATION Imakefile README VERSION makefile times
  1484. XDES=    des.c des.man
  1485. XTESTING=destest.c speed.c rpw.c
  1486. XLIBDES=    des_crypt.man des.h cbc_cksum.c cbc_encrypt.c ecb_encrypt.c \
  1487. X    enc_read.c enc_write.c pcbc_encrypt.c quad_cksum.c random_key.c \
  1488. X    read_password.c set_key.c string_to_key.c fcrypt.c des_local.h \
  1489. X    podd.h sk.h sp.h
  1490. XPERL=    des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
  1491. X
  1492. XALL=    $(GENERAL) $(DES) $(TESTING) $(LIBDES) $(PERL)
  1493. X
  1494. XLIB=    libdes.a
  1495. X
  1496. Xall: $(LIB) destest rpw des speed
  1497. X
  1498. X$(LIB):    $(OBJS)
  1499. X    /bin/rm -f $(LIB)
  1500. X    ar cr $(LIB) $(OBJS)
  1501. X    ranlib libdes.a
  1502. X
  1503. Xdestest: destest.o libdes.a
  1504. X    $(CC) $(CFLAGS) -o destest destest.o libdes.a
  1505. X    
  1506. Xrpw: rpw.o libdes.a
  1507. X    $(CC) $(CFLAGS) -o rpw rpw.o libdes.a
  1508. X
  1509. Xspeed: speed.o libdes.a
  1510. X    $(CC) $(CFLAGS) -o speed speed.o libdes.a
  1511. X
  1512. Xdes: des.o libdes.a
  1513. X    $(CC) $(CFLAGS) -o des des.o libdes.a
  1514. X
  1515. Xtar:
  1516. X    tar cf libdes.tar $(ALL)
  1517. X
  1518. Xshar:
  1519. X    shar $(ALL) >libdes.shar
  1520. X
  1521. Xclean:
  1522. X    /bin/rm -f *.o rpw destest des speed $(LIB)
  1523. END_OF_FILE
  1524. if test 1174 -ne `wc -c <'makefile'`; then
  1525.     echo shar: \"'makefile'\" unpacked with wrong size!
  1526. fi
  1527. # end of 'makefile'
  1528. fi
  1529. if test -f 'pcbc_encrypt.c' -a "${1}" != "-c" ; then 
  1530.   echo shar: Will not clobber existing file \"'pcbc_encrypt.c'\"
  1531. else
  1532. echo shar: Extracting \"'pcbc_encrypt.c'\" \(1337 characters\)
  1533. sed "s/^X//" >'pcbc_encrypt.c' <<'END_OF_FILE'
  1534. X/* pcbc_encrypt.c */
  1535. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1536. X#include "des_local.h"
  1537. X
  1538. Xint des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)
  1539. Xdes_cblock *input;
  1540. Xdes_cblock *output;
  1541. Xlong length;
  1542. Xdes_key_schedule schedule;
  1543. Xdes_cblock *ivec;
  1544. Xint encrypt;
  1545. X    {
  1546. X    register ulong sin0,sin1,xor0,xor1,tout0,tout1;
  1547. X    ulong tin[2],tout[2];
  1548. X    uchar *in,*out,*iv;
  1549. X
  1550. X    in=(uchar *)input;
  1551. X    out=(uchar *)output;
  1552. X    iv=(uchar *)ivec;
  1553. X
  1554. X    if (encrypt)
  1555. X        {
  1556. X        c2l(iv,xor0);
  1557. X        c2l(iv,xor1);
  1558. X        for (; length>0; length-=8)
  1559. X            {
  1560. X            if (length >= 8)
  1561. X                {
  1562. X                c2l(in,sin0);
  1563. X                c2l(in,sin1);
  1564. X                }
  1565. X            else
  1566. X                c2ln(in,sin0,sin1,length);
  1567. X            tin[0]=sin0^xor0;
  1568. X            tin[1]=sin1^xor1;
  1569. X            des_encrypt((ulong *)tin,(ulong *)tout,
  1570. X                schedule,encrypt);
  1571. X            tout0=tout[0];
  1572. X            tout1=tout[1];
  1573. X            xor0=sin0^tout[0];
  1574. X            xor1=sin1^tout[1];
  1575. X            l2c(tout0,out);
  1576. X            l2c(tout1,out);
  1577. X            }
  1578. X        }
  1579. X    else
  1580. X        {
  1581. X        c2l(iv,xor0); c2l(iv,xor1);
  1582. X        for (; length>0; length-=8)
  1583. X            {
  1584. X            c2l(in,sin0);
  1585. X            c2l(in,sin1);
  1586. X            tin[0]=sin0;
  1587. X            tin[1]=sin1;
  1588. X            des_encrypt((ulong *)tin,(ulong *)tout,
  1589. X                schedule,encrypt);
  1590. X            tout0=tout[0]^xor0;
  1591. X            tout1=tout[1]^xor1;
  1592. X            if (length >= 8)
  1593. X                {
  1594. X                l2c(tout0,out);
  1595. X                l2c(tout1,out);
  1596. X                }
  1597. X            else
  1598. X                l2cn(tout0,tout1,out,length);
  1599. X            xor0=tout0^sin0;
  1600. X            xor1=tout1^sin1;
  1601. X            }
  1602. X        }
  1603. X    tin[0]=tin[1]=tout[0]=tout[1]=0;
  1604. X    return(0);
  1605. X    }
  1606. END_OF_FILE
  1607. if test 1337 -ne `wc -c <'pcbc_encrypt.c'`; then
  1608.     echo shar: \"'pcbc_encrypt.c'\" unpacked with wrong size!
  1609. fi
  1610. # end of 'pcbc_encrypt.c'
  1611. fi
  1612. if test -f 'podd.h' -a "${1}" != "-c" ; then 
  1613.   echo shar: Will not clobber existing file \"'podd.h'\"
  1614. else
  1615. echo shar: Extracting \"'podd.h'\" \(1160 characters\)
  1616. sed "s/^X//" >'podd.h' <<'END_OF_FILE'
  1617. X/* podd.h */
  1618. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1619. Xstatic unsigned char odd_parity[256]={
  1620. X  1,  1,  2,  2,  4,  4,  7,  7,  8,  8, 11, 11, 13, 13, 14, 14,
  1621. X 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
  1622. X 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
  1623. X 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
  1624. X 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
  1625. X 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
  1626. X 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
  1627. X112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
  1628. X128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
  1629. X145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
  1630. X161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
  1631. X176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
  1632. X193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
  1633. X208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
  1634. X224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
  1635. X241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
  1636. END_OF_FILE
  1637. if test 1160 -ne `wc -c <'podd.h'`; then
  1638.     echo shar: \"'podd.h'\" unpacked with wrong size!
  1639. fi
  1640. # end of 'podd.h'
  1641. fi
  1642. if test -f 'quad_cksum.c' -a "${1}" != "-c" ; then 
  1643.   echo shar: Will not clobber existing file \"'quad_cksum.c'\"
  1644. else
  1645. echo shar: Extracting \"'quad_cksum.c'\" \(1511 characters\)
  1646. sed "s/^X//" >'quad_cksum.c' <<'END_OF_FILE'
  1647. X/* quad_cksum.c */
  1648. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1649. X/* From "Message Authentication"  R.R. Jueneman, S.M. Matyas, C.H. Meyer
  1650. X * IEEE Communications Magazine Sept 1985 Vol. 23 No. 9 p 29-40
  1651. X * This module in only based on the code in this paper and is
  1652. X * almost definitely not the same as the MIT implementation.
  1653. X */
  1654. X#include "des_local.h"
  1655. X
  1656. X/* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */
  1657. X#define B0(a)    (((ulong)(a)))
  1658. X#define B1(a)    (((ulong)(a))<<8)
  1659. X#define B2(a)    (((ulong)(a))<<16)
  1660. X#define B3(a)    (((ulong)(a))<<24)
  1661. X
  1662. X/* used to scramble things a bit */
  1663. X/* Got the value MIT uses via brute force :-) 2/10/90 eay */
  1664. X#define NOISE    (83653421)
  1665. X
  1666. Xunsigned long des_quad_cksum(input,output,length,out_count,seed)
  1667. Xdes_cblock *input;
  1668. Xdes_cblock *output;
  1669. Xlong length;
  1670. Xint out_count;
  1671. Xdes_cblock *seed;
  1672. X    {
  1673. X    ulong z0,z1,t0,t1;
  1674. X    int i;
  1675. X    long l=0;
  1676. X    uchar *cp;
  1677. X    uchar *lp;
  1678. X
  1679. X    lp=(uchar *)output;
  1680. X
  1681. X    z0=B0((*seed)[0])|B1((*seed)[1])|B2((*seed)[2])|B3((*seed)[3]);
  1682. X    z1=B0((*seed)[4])|B1((*seed)[5])|B2((*seed)[6])|B3((*seed)[7]);
  1683. X
  1684. X    for (i=0; ((i<4)&&(i<out_count)); i++)
  1685. X        {
  1686. X        cp=(uchar *)input;
  1687. X        l=length;
  1688. X        while (l > 0)
  1689. X            {
  1690. X            if (l > 1)
  1691. X                {
  1692. X                t0= (ulong)*cp++;
  1693. X                t0|=(ulong)B1(*cp++);
  1694. X                l--;
  1695. X                }
  1696. X            else
  1697. X                t0= (ulong)*cp++;
  1698. X            l--;
  1699. X
  1700. X            /* add */
  1701. X            t0+=z0;
  1702. X            t1=z1;
  1703. X            /* square, well sort of square */
  1704. X            z0=((t0*t0)+(t1*t1))  %0x7fffffff; 
  1705. X            z1=(t0*(t1+NOISE))%0x7fffffff;
  1706. X            }
  1707. X        if (lp != NULL)
  1708. X            {
  1709. X            l2c(z0,lp);
  1710. X            l2c(z1,lp);
  1711. X            }
  1712. X        }
  1713. X    return(z0);
  1714. X    }
  1715. X
  1716. END_OF_FILE
  1717. if test 1511 -ne `wc -c <'quad_cksum.c'`; then
  1718.     echo shar: \"'quad_cksum.c'\" unpacked with wrong size!
  1719. fi
  1720. # end of 'quad_cksum.c'
  1721. fi
  1722. if test -f 'random_key.c' -a "${1}" != "-c" ; then 
  1723.   echo shar: Will not clobber existing file \"'random_key.c'\"
  1724. else
  1725. echo shar: Extracting \"'random_key.c'\" \(849 characters\)
  1726. sed "s/^X//" >'random_key.c' <<'END_OF_FILE'
  1727. X/* random_key.c */
  1728. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1729. X#include "des_local.h"
  1730. X
  1731. Xint des_random_key(ret)
  1732. Xdes_cblock ret;
  1733. X    {
  1734. X    des_key_schedule ks;
  1735. X    static ulong c=0;
  1736. X    static ushort pid=0;
  1737. X    static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
  1738. X    des_cblock key;
  1739. X
  1740. X#ifdef MSDOS
  1741. X    pid=1;
  1742. X#else
  1743. X    if (!pid) pid=getpid();
  1744. X#endif
  1745. X    ((ulong *)key)[0]=(ulong)time(NULL);
  1746. X    ((ulong *)key)[1]=(ulong)((pid)|((c++)<<16));
  1747. X
  1748. X    des_set_odd_parity((des_cblock *)data);
  1749. X    des_set_key((des_cblock *)data,ks);
  1750. X    des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
  1751. X        (long)sizeof(key),ks,(des_cblock *)data);
  1752. X    des_set_odd_parity((des_cblock *)key);
  1753. X    des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
  1754. X        (long)sizeof(key),ks,(des_cblock *)data);
  1755. X
  1756. X    bcopy(key,ret,sizeof(key));
  1757. X    bzero(key,sizeof(key));
  1758. X    bzero(ks,sizeof(ks));
  1759. X    return(0);
  1760. X    }
  1761. END_OF_FILE
  1762. if test 849 -ne `wc -c <'random_key.c'`; then
  1763.     echo shar: \"'random_key.c'\" unpacked with wrong size!
  1764. fi
  1765. # end of 'random_key.c'
  1766. fi
  1767. if test -f 'read_password.c' -a "${1}" != "-c" ; then 
  1768.   echo shar: Will not clobber existing file \"'read_password.c'\"
  1769. else
  1770. echo shar: Extracting \"'read_password.c'\" \(2624 characters\)
  1771. sed "s/^X//" >'read_password.c' <<'END_OF_FILE'
  1772. X/* read_password.c */
  1773. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1774. X#include "des_local.h"
  1775. X#include <string.h>
  1776. X#include <signal.h>
  1777. X#include <sgtty.h>
  1778. X#include <sys/ioctl.h>
  1779. X#include <setjmp.h>
  1780. X
  1781. Xstatic int read_pw();
  1782. Xstatic void recsig();
  1783. Xstatic void pushsig();
  1784. Xstatic void popsig();
  1785. X
  1786. Xstatic void (*savsig[NSIG])();
  1787. Xstatic jmp_buf save;
  1788. X
  1789. Xint des_read_password(key,prompt,verify)
  1790. Xdes_cblock *key;
  1791. Xchar *prompt;
  1792. Xint verify;
  1793. X    {
  1794. X    int ok;
  1795. X    char buf[BUFSIZ],buff[BUFSIZ];
  1796. X
  1797. X    if ((ok=read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
  1798. X        des_string_to_key(buf,key);
  1799. X    bzero(buf,BUFSIZ);
  1800. X    bzero(buff,BUFSIZ);
  1801. X    return(ok);
  1802. X    }
  1803. X
  1804. Xint des_read_pw_string(buf,length,prompt,verify)
  1805. Xchar *buf;
  1806. Xint length;
  1807. Xchar *prompt;
  1808. Xint verify;
  1809. X    {
  1810. X    char buff[BUFSIZ];
  1811. X    int ret;
  1812. X
  1813. X    ret=read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
  1814. X    bzero(buff,BUFSIZ);
  1815. X    return(ret);
  1816. X    }
  1817. X
  1818. Xstatic read_till_nl(in)
  1819. XFILE *in;
  1820. X    {
  1821. X#define SIZE 4
  1822. X    char buf[SIZE+1];
  1823. X
  1824. X    do    {
  1825. X        fgets(buf,SIZE,in);
  1826. X        } while (index(buf,'\n') == NULL);
  1827. X    }
  1828. X
  1829. X/* return 0 if ok, 1 (or -1) otherwise */
  1830. Xstatic int read_pw(buf,buff,size,prompt,verify)
  1831. Xchar *buf,*buff;
  1832. Xint size;
  1833. Xchar *prompt;
  1834. Xint verify;
  1835. X    {
  1836. X    struct sgttyb tty_orig,tty_new;
  1837. X    int ok=0;
  1838. X    char *p;
  1839. X    int ps=0;
  1840. X    FILE *tty;
  1841. X
  1842. X    if ((tty=fopen("/dev/tty","r")) == NULL)
  1843. X        tty=stdin;
  1844. X    if (ioctl(fileno(tty),TIOCGETP,(char *)&tty_orig) == -1)
  1845. X        return(-1);
  1846. X    bcopy(&(tty_orig),&(tty_new),sizeof(tty_orig));
  1847. X    if (setjmp(save))
  1848. X        {
  1849. X        ok=0;
  1850. X        goto error;
  1851. X        }
  1852. X    pushsig();
  1853. X    ps=1;
  1854. X    tty_new.sg_flags &= ~ECHO;
  1855. X    if (ioctl(fileno(tty),TIOCSETP,(char *)&tty_new) == -1)
  1856. X        return(-1);
  1857. X    ps=2;
  1858. X
  1859. X    while (!ok)
  1860. X        {
  1861. X        fputs(prompt,stderr);
  1862. X        fflush(stderr);
  1863. X
  1864. X        buf[0]='\0';
  1865. X        fgets(buf,size,tty);
  1866. X        if (feof(tty)) goto error;
  1867. X        if ((p=(char *)index(buf,'\n')) != NULL)
  1868. X            *p='\0';
  1869. X        else    read_till_nl(tty);
  1870. X        if (verify)
  1871. X            {
  1872. X            fprintf(stderr,"\nVerifying password %s",prompt);
  1873. X            fflush(stderr);
  1874. X            buff[0]='\0';
  1875. X            fgets(buff,size,tty);
  1876. X            if (feof(tty)) goto error;
  1877. X            if ((p=(char *)index(buff,'\n')) != NULL)
  1878. X                *p='\0';
  1879. X            else    read_till_nl(tty);
  1880. X                
  1881. X            if (strcmp(buf,buff) != 0)
  1882. X                {
  1883. X                fprintf(stderr,"\nVerify failure - try again\n");
  1884. X                fflush(stderr);
  1885. X                continue;
  1886. X                }
  1887. X            }
  1888. X        ok=1;
  1889. X        }
  1890. X
  1891. Xerror:
  1892. X    fprintf(stderr,"\n");
  1893. X    /* What can we do if there is an error? */
  1894. X    if (ps >= 2) ioctl(fileno(tty),TIOCSETP,(char *)&tty_orig);
  1895. X    if (ps >= 1) popsig();
  1896. X    if (stdin != tty) fclose(tty);
  1897. X    return(!ok);
  1898. X    }
  1899. X
  1900. Xstatic void pushsig()
  1901. X    {
  1902. X    int i;
  1903. X
  1904. X    for (i=0; i<NSIG; i++)
  1905. X        savsig[i]=signal(i,recsig);
  1906. X    }
  1907. X
  1908. Xstatic void popsig()
  1909. X    {
  1910. X    int i;
  1911. X
  1912. X    for (i=0; i<NSIG; i++)
  1913. X        signal(i,savsig[i]);
  1914. X    }
  1915. X
  1916. Xstatic void recsig()
  1917. X    {
  1918. X    longjmp(save,1);
  1919. X    }
  1920. END_OF_FILE
  1921. if test 2624 -ne `wc -c <'read_password.c'`; then
  1922.     echo shar: \"'read_password.c'\" unpacked with wrong size!
  1923. fi
  1924. # end of 'read_password.c'
  1925. fi
  1926. if test -f 'rpw.c' -a "${1}" != "-c" ; then 
  1927.   echo shar: Will not clobber existing file \"'rpw.c'\"
  1928. else
  1929. echo shar: Extracting \"'rpw.c'\" \(592 characters\)
  1930. sed "s/^X//" >'rpw.c' <<'END_OF_FILE'
  1931. X/* rpw.c */
  1932. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  1933. X#include <stdio.h>
  1934. X#include "des.h"
  1935. X
  1936. Xmain()
  1937. X    {
  1938. X    des_cblock k;
  1939. X    int i;
  1940. X
  1941. X    printf("read passwd\n");
  1942. X    if ((i=des_read_password(k,"Enter password:",0)) == 0)
  1943. X        {
  1944. X        printf("password = ");
  1945. X        for (i=0; i<8; i++)
  1946. X            printf("%02x ",k[i]);
  1947. X        }
  1948. X    else
  1949. X        printf("error %d\n",i);
  1950. X    printf("\n");
  1951. X    printf("read passwd and verify\n");
  1952. X    if ((i=des_read_password(k,"Enter verified password:",1)) == 0)
  1953. X        {
  1954. X        printf("password = ");
  1955. X        for (i=0; i<8; i++)
  1956. X            printf("%02x ",k[i]);
  1957. X        printf("\n");
  1958. X        }
  1959. X    else
  1960. X        printf("error %d\n",i);
  1961. X    }
  1962. END_OF_FILE
  1963. if test 592 -ne `wc -c <'rpw.c'`; then
  1964.     echo shar: \"'rpw.c'\" unpacked with wrong size!
  1965. fi
  1966. # end of 'rpw.c'
  1967. fi
  1968. if test -f 'shifts.pl' -a "${1}" != "-c" ; then 
  1969.   echo shar: Will not clobber existing file \"'shifts.pl'\"
  1970. else
  1971. echo shar: Extracting \"'shifts.pl'\" \(1978 characters\)
  1972. sed "s/^X//" >'shifts.pl' <<'END_OF_FILE'
  1973. Xsub lab_shift
  1974. X    {
  1975. X    local(*a,$n)=@_;
  1976. X    local(@r,$i,$j,$k,$d,@z);
  1977. X
  1978. X    @r=&shift(*a,$n);
  1979. X    foreach $i (0 .. 31)
  1980. X        {
  1981. X        @z=split(/\^/,$r[$i]);
  1982. X        for ($j=0; $j <= $#z; $j++)
  1983. X            {
  1984. X            ($d)=($z[$j] =~ /^(..)/);
  1985. X            ($k)=($z[$j] =~ /\[(.*)\]$/);
  1986. X            $k.=",$n" if ($k ne "");
  1987. X            $k="$n"      if ($k eq "");
  1988. X            $d="$d[$k]";
  1989. X            $z[$j]=$d;
  1990. X            }
  1991. X        $r[$i]=join('^',@z);
  1992. X        }
  1993. X    return(@r);
  1994. X    }
  1995. X
  1996. Xsub shift
  1997. X    {
  1998. X    local(*a,$n)=@_;
  1999. X    local(@f);
  2000. X
  2001. X    if ($n > 0)
  2002. X        {
  2003. X        @f=&shiftl(*a,$n);
  2004. X        }
  2005. X    else
  2006. X        {
  2007. X        @f=&shiftr(*a,-$n);
  2008. X        }
  2009. X    return(@f);
  2010. X    }
  2011. X
  2012. Xsub shiftr
  2013. X    {
  2014. X    local(*a,$n)=@_;
  2015. X    local(@r,$i);
  2016. X
  2017. X    $#r=31;
  2018. X    foreach $i (0 .. 31)
  2019. X        {
  2020. X        if (($i+$n) > 31)
  2021. X            {
  2022. X            $r[$i]="--";
  2023. X            }
  2024. X        else
  2025. X            {
  2026. X            $r[$i]=$a[$i+$n];
  2027. X            }
  2028. X        }
  2029. X    return(@r);
  2030. X    }
  2031. X
  2032. Xsub shiftl
  2033. X    {
  2034. X    local(*a,$n)=@_;
  2035. X    local(@r,$i);
  2036. X
  2037. X    $#r=31;
  2038. X    foreach $i (0 .. 31)
  2039. X        {
  2040. X        if ($i < $n)
  2041. X            {
  2042. X            $r[$i]="--";
  2043. X            }
  2044. X        else
  2045. X            {
  2046. X            $r[$i]=$a[$i-$n];
  2047. X            }
  2048. X        }
  2049. X    return(@r);
  2050. X    }
  2051. X
  2052. Xsub printit
  2053. X    {
  2054. X    local(@a)=@_;
  2055. X    local($i);
  2056. X
  2057. X    foreach $i (0 .. 31)
  2058. X        {
  2059. X        printf "%2s  ",$a[$i];
  2060. X        print "\n" if (($i%8) == 7);
  2061. X        }
  2062. X    print "\n";
  2063. X    }
  2064. X
  2065. Xsub xor
  2066. X    {
  2067. X    local(*a,*b)=@_;
  2068. X    local(@r,$i);
  2069. X
  2070. X    $#r=31;
  2071. X    foreach $i (0 .. 31)
  2072. X        {
  2073. X        $r[$i]=&compress($a[$i].'^'.$b[$i]);
  2074. X#        $r[$i]=$a[$i]."^".$b[$i];
  2075. X        }
  2076. X    return(@r);
  2077. X    }
  2078. X
  2079. Xsub and
  2080. X    {
  2081. X    local(*a,$m)=@_;
  2082. X    local(@r,$i);
  2083. X
  2084. X    $#r=31;
  2085. X    foreach $i (0 .. 31)
  2086. X        {
  2087. X        $r[$i]=(($m & (1<<$i))?($a[$i]):('--'));
  2088. X        }
  2089. X    return(@r);
  2090. X    }
  2091. X
  2092. Xsub or
  2093. X    {
  2094. X    local(*a,*b)=@_;
  2095. X    local(@r,$i);
  2096. X
  2097. X    $#r=31;
  2098. X    foreach $i (0 .. 31)
  2099. X        {
  2100. X        $r[$i]='--'   if (($a[$i] eq '--') && ($b[$i] eq '--'));
  2101. X        $r[$i]=$a[$i] if (($a[$i] ne '--') && ($b[$i] eq '--'));
  2102. X        $r[$i]=$b[$i] if (($a[$i] eq '--') && ($b[$i] ne '--'));
  2103. X        $r[$i]='++'   if (($a[$i] ne '--') && ($b[$i] ne '--'));
  2104. X        }
  2105. X    return(@r);
  2106. X    }
  2107. X
  2108. Xsub compress
  2109. X    {
  2110. X    local($s)=@_;
  2111. X    local($_,$i,@a,%a,$r);
  2112. X
  2113. X    $s =~ s/\^\^/\^/g;
  2114. X    $s =~ s/^\^//;
  2115. X    $s =~ s/\^$//;
  2116. X    @a=split(/\^/,$s);
  2117. X
  2118. X    while ($#a >= 0)
  2119. X        {
  2120. X        $_=shift(@a);
  2121. X        next unless /\d/;
  2122. X        $a{$_}++;
  2123. X        }
  2124. X    foreach $i (sort keys %a)
  2125. X        {
  2126. X        next if ($a{$i}%2 == 0);
  2127. X        $r.="$i^";
  2128. X        }
  2129. X    chop($r);
  2130. X    return($r);
  2131. X    }
  2132. X1;
  2133. END_OF_FILE
  2134. if test 1978 -ne `wc -c <'shifts.pl'`; then
  2135.     echo shar: \"'shifts.pl'\" unpacked with wrong size!
  2136. fi
  2137. # end of 'shifts.pl'
  2138. fi
  2139. if test -f 'speed.c' -a "${1}" != "-c" ; then 
  2140.   echo shar: Will not clobber existing file \"'speed.c'\"
  2141. else
  2142. echo shar: Extracting \"'speed.c'\" \(2089 characters\)
  2143. sed "s/^X//" >'speed.c' <<'END_OF_FILE'
  2144. X/* speed.c */
  2145. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  2146. X#include <stdio.h>
  2147. X#include <signal.h>
  2148. X#include <sys/types.h>
  2149. X#include <sys/times.h>
  2150. X#include "des.h"
  2151. X
  2152. X/* The following if from times(3) man page.  It may need to be changed */
  2153. X#define HZ    60.0
  2154. X
  2155. X#define BUFSIZE    (1024*8)
  2156. X
  2157. Xlong run=0;
  2158. Xint sig_done() { run=0; }
  2159. X
  2160. Xmain(argc,argv)
  2161. Xint argc;
  2162. Xchar *argv[];
  2163. X    {
  2164. X    struct tms tstart,tend;
  2165. X    int count;
  2166. X    FILE *in,*out,*std;
  2167. X    static unsigned char buf[BUFSIZE];
  2168. X    static des_cblock key={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
  2169. X    des_key_schedule sch;
  2170. X    int i,j,k,enc,cat=0,catfd;
  2171. X    double d,a,b,c;
  2172. X
  2173. X    signal(SIGALRM,sig_done);
  2174. X
  2175. X    printf("Doing set_key for 60 seconds\n");
  2176. X    alarm(60);
  2177. X    times(&tstart);
  2178. X    for (count=0,run=1; run; count++)
  2179. X        des_set_key(key,sch);
  2180. X    times(&tend);
  2181. X    d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  2182. X    printf("%d set_key's in %.2f second\n",
  2183. X        count,d);
  2184. X    a=((double)count)/d;
  2185. X
  2186. X    printf("Doing des_ecb_encrypt's for 60 seconds\n");
  2187. X    alarm(60);
  2188. X    times(&tstart);
  2189. X    for (count=0,run=1; run; count++)
  2190. X        des_ecb_encrypt(buf,buf,&(sch[0]),DES_ENCRYPT);
  2191. X    times(&tend);
  2192. X    d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  2193. X    printf("%d des_ecb_encrypt's in %.2f second\n",
  2194. X        count,d);
  2195. X    b=((double)count*8)/d;
  2196. X
  2197. X    printf("Doing des_cbc_encrypt on %d byte blocks for 60 seconds\n",
  2198. X        BUFSIZE);
  2199. X    alarm(60);
  2200. X    times(&tstart);
  2201. X    for (count=0,run=1; run; count++)
  2202. X        des_cbc_encrypt(buf,buf,BUFSIZE,&(sch[0]),
  2203. X        &(key[0]),DES_ENCRYPT);
  2204. X    times(&tend);
  2205. X    d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  2206. X    printf("%d des_cbc_encrypt's of %d byte blocks in %.2f second\n",
  2207. X        count,BUFSIZE,d);
  2208. X    c=((double)count*BUFSIZE)/d;
  2209. X
  2210. X    printf("Doing crypt for 60 seconds\n");
  2211. X    alarm(60);
  2212. X    times(&tstart);
  2213. X    for (count=0,run=1; run; count++)
  2214. X        crypt("testing1","ef");
  2215. X    times(&tend);
  2216. X    d=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
  2217. X    printf("%d crypts in %.2f second\n",count,d);
  2218. X    d=((double)count)/d;
  2219. X
  2220. X    printf("set_key       per sec = %12.2f\n",a);
  2221. X    printf("DES ecb bytes per sec = %12.2f\n",b);
  2222. X    printf("DES cbc bytes per sec = %12.2f\n",c);
  2223. X    printf("crypt         per sec = %12.2f\n",d);
  2224. X    }
  2225. END_OF_FILE
  2226. if test 2089 -ne `wc -c <'speed.c'`; then
  2227.     echo shar: \"'speed.c'\" unpacked with wrong size!
  2228. fi
  2229. # end of 'speed.c'
  2230. fi
  2231. if test -f 'string_to_key.c' -a "${1}" != "-c" ; then 
  2232.   echo shar: Will not clobber existing file \"'string_to_key.c'\"
  2233. else
  2234. echo shar: Extracting \"'string_to_key.c'\" \(533 characters\)
  2235. sed "s/^X//" >'string_to_key.c' <<'END_OF_FILE'
  2236. X/* string_to_key.c */
  2237. X/* Copyright (C) 1992 Eric Young - see COPYING for more details */
  2238. X#include "des_local.h"
  2239. X
  2240. Xint des_string_to_key(str,key)
  2241. Xchar *str;
  2242. Xdes_cblock *key;
  2243. X    {
  2244. X    des_key_schedule ks;
  2245. X    int i,length;
  2246. X
  2247. X    bzero(key,8);
  2248. X    length=strlen(str);
  2249. X    for (i=0; i<length; i++)
  2250. X        (*key)[i%8]^=(str[i]<<1);
  2251. X    des_set_odd_parity((des_cblock *)key);
  2252. X    des_set_key((des_cblock *)key,ks);
  2253. X    des_cbc_cksum((des_cblock *)str,(des_cblock *)key,(long)length,ks,
  2254. X        (des_cblock *)key);
  2255. X    bzero(ks,sizeof(ks));
  2256. X    des_set_odd_parity(key);
  2257. X    return(0);
  2258. X    }
  2259. END_OF_FILE
  2260. if test 533 -ne `wc -c <'string_to_key.c'`; then
  2261.     echo shar: \"'string_to_key.c'\" unpacked with wrong size!
  2262. fi
  2263. # end of 'string_to_key.c'
  2264. fi
  2265. if test -f 'times' -a "${1}" != "-c" ; then 
  2266.   echo shar: Will not clobber existing file \"'times'\"
  2267. else
  2268. echo shar: Extracting \"'times'\" \(926 characters\)
  2269. sed "s/^X//" >'times' <<'END_OF_FILE'
  2270. Xsun sparc 2 - gcc2 -O2
  2271. X-rw-r-----  1 eay      wheel       25804 Mar 24 14:16 libdes.a
  2272. Xset_key       per sec =     21462.36
  2273. XDES ecb bytes per sec =    289342.72
  2274. XDES cbc bytes per sec =    288306.34
  2275. Xcrypt         per sec =      1343.25
  2276. X
  2277. Xsun sparc 2 - cc -O4
  2278. X-rw-r-----  1 eay      wheel       27444 Mar 24 14:47 libdes.a
  2279. Xset_key       per sec =     20065.82
  2280. XDES ecb bytes per sec =    240058.09
  2281. XDES cbc bytes per sec =    240987.25
  2282. Xcrypt         per sec =      1147.72
  2283. X
  2284. Xsun 3/260 gcc -O2
  2285. X-rw-r-----  1 eay      wheel       22540 Mar 25 07:30 libdes.a
  2286. Xset_key       per sec =      3305.00
  2287. XDES ecb bytes per sec =     41326.80
  2288. XDES cbc bytes per sec =     42421.17
  2289. Xcrypt         per sec =       187.79
  2290. X
  2291. Xsun 3/260 cc -O4
  2292. X-rw-r-----  1 eay      wheel       23714 Mar 25 07:15 libdes.a
  2293. Xset_key       per sec =      2994.30
  2294. XDES ecb bytes per sec =     31061.97
  2295. XDES cbc bytes per sec =     31561.52
  2296. Xcrypt         per sec =       148.66
  2297. END_OF_FILE
  2298. if test 926 -ne `wc -c <'times'`; then
  2299.     echo shar: \"'times'\" unpacked with wrong size!
  2300. fi
  2301. # end of 'times'
  2302. fi
  2303. echo shar: End of archive 1 \(of 4\).
  2304. cp /dev/null ark1isdone
  2305. MISSING=""
  2306. for I in 1 2 3 4 ; do
  2307.     if test ! -f ark${I}isdone ; then
  2308.     MISSING="${MISSING} ${I}"
  2309.     fi
  2310. done
  2311. if test "${MISSING}" = "" ; then
  2312.     echo You have unpacked all 4 archives.
  2313.     rm -f ark[1-9]isdone
  2314. else
  2315.     echo You still need to unpack the following archives:
  2316.     echo "        " ${MISSING}
  2317. fi
  2318. ##  End of shell archive.
  2319. exit 0
  2320. exit 0 # Just in case...
  2321.