home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume40 / libdes / part05 < prev    next >
Internet Message Format  |  1993-10-14  |  32KB

  1. From: eay@psych.psy.uq.oz.au (Eric Young)
  2. Newsgroups: comp.sources.misc
  3. Subject: v40i012: libdes - DES encryption library, Part05/05
  4. Date: 14 Oct 1993 18:02:12 +0100
  5. Sender: aem@aber.ac.uk
  6. Approved: aem@aber.ac.uk
  7. Message-ID: <29k0mk$1ml@uk-usenet.uk.sun.com>
  8. X-Md4-Signature: caf29918256b2dc5b90cf0ee4d4b796b
  9.  
  10. Submitted-by: eay@psych.psy.uq.oz.au (Eric Young)
  11. Posting-number: Volume 40, Issue 12
  12. Archive-name: libdes/part05
  13. Environment: C
  14. Supersedes: libdes: Volume 29, Issue 43-46
  15.  
  16. #! /bin/sh
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  3cbc_enc.c 3ecb_enc.c CHANGES INSTALL Imakefile KERBEROS
  22. #   PC1 PC2 cbc_enc.c cfb_enc.c doIP doPC1 ofb_enc.c podd.h qud_cksm.c
  23. #   rand_key.c rpw.c shifts.pl
  24. # Wrapped by alecm@uk-usenet on Wed Oct 13 10:33:50 1993
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 5 (of 5)."'
  28. if test -f '3cbc_enc.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'3cbc_enc.c'\"
  30. else
  31.   echo shar: Extracting \"'3cbc_enc.c'\" \(1370 characters\)
  32.   sed "s/^X//" >'3cbc_enc.c' <<'END_OF_FILE'
  33. X/* 3cbc_enc.c */
  34. X/* Copyright (C) 1993 Eric Young - see README for more details */
  35. X#include "des_locl.h"
  36. X
  37. Xint des_3cbc_encrypt(input,output,length,ks1,ks2,iv1,iv2,encrypt)
  38. Xdes_cblock *input;
  39. Xdes_cblock *output;
  40. Xlong length;
  41. Xdes_key_schedule ks1,ks2;
  42. Xdes_cblock *iv1,*iv2;
  43. Xint encrypt;
  44. X    {
  45. X    int off=length/8-1;
  46. X    des_cblock niv1,niv2;
  47. X
  48. Xprintf("3cbc\n");
  49. Xxp(iv1);
  50. Xxp(iv1);
  51. Xxp(iv2);
  52. Xxp(input);
  53. X    if (encrypt == DES_ENCRYPT)
  54. X        {
  55. X        des_cbc_encrypt(input,output,length,ks1,iv1,encrypt);
  56. X        if (length >= sizeof(des_cblock))
  57. X            bcopy(output[off],niv1,sizeof(des_cblock));
  58. X        des_cbc_encrypt(output,output,length,ks2,iv1,!encrypt);
  59. X        des_cbc_encrypt(output,output,length,ks1,iv2, encrypt);
  60. X        if (length >= sizeof(des_cblock))
  61. X            bcopy(output[off],niv2,sizeof(des_cblock));
  62. X        bcopy(niv1,*iv1,sizeof(des_cblock));
  63. X        }
  64. X    else
  65. X        {
  66. X        if (length >= sizeof(des_cblock))
  67. X            bcopy(input[off],niv1,sizeof(des_cblock));
  68. X        des_cbc_encrypt(input,output,length,ks1,iv1,encrypt);
  69. X        des_cbc_encrypt(output,output,length,ks2,iv2,!encrypt);
  70. X        if (length >= sizeof(des_cblock))
  71. X            bcopy(output[off],niv2,sizeof(des_cblock));
  72. X        des_cbc_encrypt(output,output,length,ks1,iv2, encrypt);
  73. X        }
  74. X    bcopy(niv1,iv1,sizeof(des_cblock));
  75. X    bcopy(niv2,iv2,sizeof(des_cblock));
  76. Xxp(iv1);
  77. Xxp(iv1);
  78. Xxp(iv2);
  79. Xxp(output);
  80. X    return(0);
  81. X    }
  82. X
  83. Xxp(a)
  84. Xunsigned char *a;
  85. X{ int i; for(i=0; i<8; i++) printf("%02X",a[i]);printf("\n");}
  86. END_OF_FILE
  87.   if test 1370 -ne `wc -c <'3cbc_enc.c'`; then
  88.     echo shar: \"'3cbc_enc.c'\" unpacked with wrong size!
  89.   fi
  90.   # end of '3cbc_enc.c'
  91. fi
  92. if test -f '3ecb_enc.c' -a "${1}" != "-c" ; then 
  93.   echo shar: Will not clobber existing file \"'3ecb_enc.c'\"
  94. else
  95.   echo shar: Extracting \"'3ecb_enc.c'\" \(600 characters\)
  96.   sed "s/^X//" >'3ecb_enc.c' <<'END_OF_FILE'
  97. X/* 3ecb_enc.c */
  98. X/* Copyright (C) 1993 Eric Young - see README for more details */
  99. X#include "des_locl.h"
  100. X
  101. Xint des_3ecb_encrypt(input,output,ks1,ks2,encrypt)
  102. Xdes_cblock *input;
  103. Xdes_cblock *output;
  104. Xdes_key_schedule ks1,ks2;
  105. Xint encrypt;
  106. X    {
  107. X    register unsigned long l0,l1,t;
  108. X    register unsigned char *in,*out;
  109. X    unsigned long ll[2];
  110. X
  111. X    in=(unsigned char *)input;
  112. X    out=(unsigned char *)output;
  113. X    c2l(in,l0);
  114. X    c2l(in,l1);
  115. X    ll[0]=l0;
  116. X    ll[1]=l1;
  117. X    des_encrypt(ll,ll,ks1,encrypt);
  118. X    des_encrypt(ll,ll,ks2,!encrypt);
  119. X    des_encrypt(ll,ll,ks1,encrypt);
  120. X    l0=ll[0];
  121. X    l1=ll[1];
  122. X    l2c(l0,out);
  123. X    l2c(l1,out);
  124. X    return(0);
  125. X    }
  126. X
  127. END_OF_FILE
  128.   if test 600 -ne `wc -c <'3ecb_enc.c'`; then
  129.     echo shar: \"'3ecb_enc.c'\" unpacked with wrong size!
  130.   fi
  131.   # end of '3ecb_enc.c'
  132. fi
  133. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  134.   echo shar: Will not clobber existing file \"'CHANGES'\"
  135. else
  136.   echo shar: Extracting \"'CHANGES'\" \(663 characters\)
  137.   sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  138. XThe main changes in this package since it was last posted to
  139. Xcomp.sources.misc are
  140. X
  141. XThe main changes are
  142. X- Major changes to the Copyright restrictions.
  143. X- Lots and lots of features added to the des(1) command, including
  144. X  - Triple DES, both triple ECB and triple CBC options.
  145. X  - uuencodeing/uudecoding built in to des(1).
  146. X  - generate checksums.
  147. X  - hex keys.
  148. X- Cleaned up the prototypes in des.h
  149. X- Filenames are now mostly <= 8 characters long.
  150. X- OFB, CFB, triple ECB and triple CBC modes of DES added to the library.
  151. X- Compiles and runs of all 64bit machines I could test the code on
  152. X  (Cray, ETA10, DEC Alpha).
  153. X- It really does work with kerberos v 4 now :-).
  154. END_OF_FILE
  155.   if test 663 -ne `wc -c <'CHANGES'`; then
  156.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  157.   fi
  158.   # end of 'CHANGES'
  159. fi
  160. if test -f 'INSTALL' -a "${1}" != "-c" ; then 
  161.   echo shar: Will not clobber existing file \"'INSTALL'\"
  162. else
  163.   echo shar: Extracting \"'INSTALL'\" \(2169 characters\)
  164.   sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
  165. XCheck the CC and CFLAGS lines in the makefile
  166. X
  167. XIf your C library does not support the times(3) function, change the
  168. X#define TIMES to
  169. X#undef TIMES in speed.c
  170. XIf it does, check the HZ value for the times(3) function.
  171. XIf your system does not define CLK_TCK it will be assumed to
  172. Xbe 60.
  173. X
  174. XIf possible use gcc v 2.2.2
  175. XTurn on the maximum optimising
  176. X
  177. Xtype 'make'
  178. X
  179. Xrun './destest' to check things are ok.
  180. Xrun './rpw' to check the tty code for reading passwords works.
  181. Xrun './speed' to see how fast those optimisations make the library run :-)
  182. X
  183. XA make install will by default install
  184. Xlibdes.a      in /usr/local/lib/libdes.a
  185. Xdes           in /usr/local/bin/des
  186. Xdes_crypt.man in /usr/local/man/man3/des_crypt.3
  187. Xdes.man       in /usr/local/man/man1/des.1
  188. Xdes.h         in /usr/include/des.h
  189. X
  190. Xdes(1) should be compatible with sunOS's but I have been unable to
  191. Xtest it.
  192. X
  193. XThese routines should compile on MSDOS, most 32bit and 64bit version
  194. Xof Unix (BSD and SYSV) and VMS, without modification.
  195. XThe only problems should be #include files that are in the wrong places.
  196. X
  197. XThese routines can be compiled under MSDOS.
  198. XI have successfully encrypted files using des(1) under MSDOS and then
  199. Xdecrypted the files on a SparcStation.
  200. XI have been able to compile and test the routines with
  201. XMicrosoft C v 5.1 and Turbo C v 2.0.
  202. XThe code in this library is in no way optimised for the 16bit
  203. Xoperation of MSDOS.  Microsoft C generates code that is 40% slower
  204. Xthan Turbo C's code.  I believe this is due to problems it has with
  205. Xcode generation with the 32bit shift operation in the IP and FP
  206. Xsections.  I have added some 16bit optimization in ecb_encrypt.c
  207. Xand this generated a %70 speedup under Turbo C.  Such are the
  208. Xlimitations of DOS compilers :-(.
  209. X
  210. XFor Turbo C v 2.0, make sure to define MSDOS, in the relevant menu.
  211. X
  212. XThere is an alternative version of the D_ENCRYPT macro that can be
  213. Xenabled with the -DALT_ECB option in the makefile.  This alternative
  214. Xmacro can make a +-%20 speed difference to the DES encryption speed,
  215. Xdepending on the compiler/CPU combinations.
  216. XIt has its greatest effect on Sparc machines when using the sun compiler.
  217. XIf in doubt, try enable/disable it and running speed.
  218. END_OF_FILE
  219.   if test 2169 -ne `wc -c <'INSTALL'`; then
  220.     echo shar: \"'INSTALL'\" unpacked with wrong size!
  221.   fi
  222.   # end of 'INSTALL'
  223. fi
  224. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  225.   echo shar: Will not clobber existing file \"'Imakefile'\"
  226. else
  227.   echo shar: Extracting \"'Imakefile'\" \(1013 characters\)
  228.   sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  229. X# This Imakefile has not been tested for a while but it should still
  230. X# work when placed in the correct directory in the kerberos v 4 distribution
  231. X
  232. XSRCS=   cbc_cksm.c cbc_enc.c ecb_enc.c pcbc_enc.c \
  233. X        qud_cksm.c rand_key.c read_pwd.c set_key.c str2key.c \
  234. X        enc_read.c enc_writ.c fcrypt.c cfb_enc.c \
  235. X    3ecb_enc.c ofb_enc.c
  236. X
  237. XOBJS=   cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
  238. X    qud_cksm.o rand_key.o read_pwd.o set_key.o str2key.o \
  239. X    enc_read.o enc_writ.o fcrypt.o cfb_enc.o \
  240. X    3ecb_enc.o ofb_enc.o
  241. X
  242. XGENERAL=COPYING FILES INSTALL Imakefile README VERSION makefile times \
  243. X    vms.com KERBEROS
  244. XDES=    des.c des.man
  245. XTESTING=destest.c speed.c rpw.c
  246. XLIBDES= des_crypt.man des.h des_locl.h podd.h sk.h spr.h
  247. X
  248. XPERL=   des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
  249. X
  250. XCODE=    $(GENERAL) $(DES) $(TESTING) $(SRCS) $(LIBDES) $(PERL)
  251. X
  252. XSRCDIR=$(SRCTOP)/lib/des
  253. X
  254. XDBG= -O
  255. XINCLUDE= -I$(SRCDIR)
  256. XCC= cc
  257. X
  258. Xlibrary_obj_rule()
  259. X
  260. Xinstall_library_target(des,$(OBJS),$(SRCS),)
  261. X
  262. Xtest(destest,libdes.a,)
  263. Xtest(rpw,libdes.a,)
  264. END_OF_FILE
  265.   if test 1013 -ne `wc -c <'Imakefile'`; then
  266.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  267.   fi
  268.   # end of 'Imakefile'
  269. fi
  270. if test -f 'KERBEROS' -a "${1}" != "-c" ; then 
  271.   echo shar: Will not clobber existing file \"'KERBEROS'\"
  272. else
  273.   echo shar: Extracting \"'KERBEROS'\" \(1398 characters\)
  274.   sed "s/^X//" >'KERBEROS' <<'END_OF_FILE'
  275. XTo use this library with Bones (kerberos without DES):
  276. X1) Get my modified Bones - eBones.  It can be found on
  277. X   gondwana.ecr.mu.oz.au (128.250.1.63) /pub/athena/eBones-p9.tar.Z
  278. X   and
  279. X   nic.funet.fi (128.214.6.100) /pub/unix/security/Kerberos/eBones-p9.tar.Z
  280. X
  281. X2) Unpack this library in src/lib/des, makeing sure it is version
  282. X   3.00 or greater (libdes.tar.93-10-07.Z).  This versions differences
  283. X   from the version in comp.sources.misc volume 29 patchlevel2.
  284. X   The primarily difference is that it should compile under kerberos :-).
  285. X   It can be found at.
  286. X   ftp.psy.uq.oz.au (130.102.32.1) /pub/DES/libdes.tar.93-10-07.Z
  287. X
  288. XNow do a normal kerberos build and things should work.
  289. X
  290. XOne problem I found when I was build on my local sun.
  291. X---
  292. XFor sunOS 4.1.1 apply the following patch to src/util/ss/make_commands.c
  293. X
  294. X*** make_commands.c.orig    Fri Jul  3 04:18:35 1987
  295. X--- make_commands.c    Wed May 20 08:47:42 1992
  296. X***************
  297. X*** 98,104 ****
  298. X       if (!rename(o_file, z_file)) {
  299. X        if (!vfork()) {
  300. X             chdir("/tmp");
  301. X!            execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", "-n",
  302. X               z_file+5, 0);
  303. X             perror("/bin/ld");
  304. X             _exit(1);
  305. X--- 98,104 ----
  306. X       if (!rename(o_file, z_file)) {
  307. X        if (!vfork()) {
  308. X             chdir("/tmp");
  309. X!            execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r",
  310. X               z_file+5, 0);
  311. X             perror("/bin/ld");
  312. X             _exit(1);
  313. END_OF_FILE
  314.   if test 1398 -ne `wc -c <'KERBEROS'`; then
  315.     echo shar: \"'KERBEROS'\" unpacked with wrong size!
  316.   fi
  317.   # end of 'KERBEROS'
  318. fi
  319. if test -f 'PC1' -a "${1}" != "-c" ; then 
  320.   echo shar: Will not clobber existing file \"'PC1'\"
  321. else
  322.   echo shar: Extracting \"'PC1'\" \(454 characters\)
  323.   sed "s/^X//" >'PC1' <<'END_OF_FILE'
  324. X#!/usr/local/bin/perl
  325. X
  326. X@PC1=(  57,49,41,33,25,17, 9,
  327. X     1,58,50,42,34,26,18,
  328. X    10, 2,59,51,43,35,27,
  329. X    19,11, 3,60,52,44,36,
  330. X    "-","-","-","-",
  331. X    63,55,47,39,31,23,15,
  332. X     7,62,54,46,38,30,22,
  333. X    14, 6,61,53,45,37,29,
  334. X    21,13, 5,28,20,12, 4,
  335. X    "-","-","-","-",
  336. X    );
  337. X
  338. Xforeach (@PC1)
  339. X    {
  340. X    if ($_ ne "-")
  341. X        {
  342. X        $_--;
  343. X        $_=int($_/8)*8+7-($_%8);
  344. X        printf "%2d  ",$_;
  345. X        }
  346. X    else
  347. X        { print "--  "; }
  348. X    print "\n" if (((++$i) % 8) == 0);
  349. X    print "\n" if ((($i) % 32) == 0);
  350. X    }
  351. X
  352. END_OF_FILE
  353.   if test 454 -ne `wc -c <'PC1'`; then
  354.     echo shar: \"'PC1'\" unpacked with wrong size!
  355.   fi
  356.   # end of 'PC1'
  357. fi
  358. if test -f 'PC2' -a "${1}" != "-c" ; then 
  359.   echo shar: Will not clobber existing file \"'PC2'\"
  360. else
  361.   echo shar: Extracting \"'PC2'\" \(861 characters\)
  362.   sed "s/^X//" >'PC2' <<'END_OF_FILE'
  363. X#!/usr/local/bin/perl
  364. X
  365. X@PC2_C=(14,17,11,24, 1, 5,
  366. X     3,28,15, 6,21,10,
  367. X    23,19,12, 4,26, 8,
  368. X    16, 7,27,20,13, 2,
  369. X    );
  370. X
  371. X@PC2_D=(41,52,31,37,47,55,
  372. X    30,40,51,45,33,48,
  373. X    44,49,39,56,34,53,
  374. X    46,42,50,36,29,32,
  375. X    );
  376. X
  377. Xforeach (@PC2_C) {
  378. X    if ($_ ne "-")
  379. X        {
  380. X        $_--;
  381. X        printf "%2d  ",$_; }
  382. X    else { print "--  "; }
  383. X    $C{$_}=1;
  384. X    print "\n" if (((++$i) % 8) == 0);
  385. X    }
  386. X$i=0;
  387. Xprint "\n";
  388. Xforeach (@PC2_D) {
  389. X    if ($_ ne "-")
  390. X        {
  391. X        $_-=29;
  392. X        printf "%2d  ",$_; }
  393. X    else { print "--  "; }
  394. X    $D{$_}=1;
  395. X    print "\n" if (((++$i) % 8) == 0); }
  396. X
  397. Xprint "\n";
  398. Xforeach $i (0 .. 27)
  399. X    {
  400. X    $_=$C{$i};
  401. X    if ($_ ne "-") {printf "%2d ",$_;}
  402. X    else { print "--  "; }
  403. X    print "\n" if (((++$i) % 8) == 0);
  404. X    }
  405. Xprint "\n";
  406. X
  407. Xprint "\n";
  408. Xforeach $i (0 .. 27)
  409. X    {
  410. X    $_=$D{$i};
  411. X    if ($_ ne "-") {printf "%2d  ",$_;}
  412. X    else { print "--  "; }
  413. X    print "\n" if (((++$i) % 8) == 0);
  414. X    }
  415. Xprint "\n";
  416. Xsub numsort
  417. X    {
  418. X    $a-$b;
  419. X    }
  420. END_OF_FILE
  421.   if test 861 -ne `wc -c <'PC2'`; then
  422.     echo shar: \"'PC2'\" unpacked with wrong size!
  423.   fi
  424.   # end of 'PC2'
  425. fi
  426. if test -f 'cbc_enc.c' -a "${1}" != "-c" ; then 
  427.   echo shar: Will not clobber existing file \"'cbc_enc.c'\"
  428. else
  429.   echo shar: Extracting \"'cbc_enc.c'\" \(1451 characters\)
  430.   sed "s/^X//" >'cbc_enc.c' <<'END_OF_FILE'
  431. X/* cbc_enc.c */
  432. X/* Copyright (C) 1993 Eric Young - see README for more details */
  433. X#include "des_locl.h"
  434. X
  435. Xint des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
  436. Xdes_cblock *input;
  437. Xdes_cblock *output;
  438. Xlong length;
  439. Xdes_key_schedule schedule;
  440. Xdes_cblock *ivec;
  441. Xint encrypt;
  442. X    {
  443. X    register unsigned long tin0,tin1;
  444. X    register unsigned long tout0,tout1,xor0,xor1;
  445. X    register unsigned char *in,*out;
  446. X    register long l=length;
  447. X    unsigned long tout[2],tin[2];
  448. X    unsigned char *iv;
  449. X
  450. X    in=(unsigned char *)input;
  451. X    out=(unsigned char *)output;
  452. X    iv=(unsigned char *)ivec;
  453. X
  454. X    if (encrypt)
  455. X        {
  456. X        c2l(iv,tout0);
  457. X        c2l(iv,tout1);
  458. X        for (; l>0; l-=8)
  459. X            {
  460. X            if (l >= 8)
  461. X                {
  462. X                c2l(in,tin0);
  463. X                c2l(in,tin1);
  464. X                }
  465. X            else
  466. X                c2ln(in,tin0,tin1,l);
  467. X            tin0^=tout0;
  468. X            tin1^=tout1;
  469. X            tin[0]=tin0;
  470. X            tin[1]=tin1;
  471. X            des_encrypt((unsigned long *)tin,(unsigned long *)tout,
  472. X                schedule,encrypt);
  473. X            tout0=tout[0];
  474. X            tout1=tout[1];
  475. X            l2c(tout0,out);
  476. X            l2c(tout1,out);
  477. X            }
  478. X        }
  479. X    else
  480. X        {
  481. X        c2l(iv,xor0);
  482. X        c2l(iv,xor1);
  483. X        for (; l>0; l-=8)
  484. X            {
  485. X            c2l(in,tin0);
  486. X            c2l(in,tin1);
  487. X            tin[0]=tin0;
  488. X            tin[1]=tin1;
  489. X            des_encrypt((unsigned long *)tin,(unsigned long *)tout,
  490. X                schedule,encrypt);
  491. X            tout0=tout[0]^xor0;
  492. X            tout1=tout[1]^xor1;
  493. X            if (l >= 8)
  494. X                {
  495. X                l2c(tout0,out);
  496. X                l2c(tout1,out);
  497. X                }
  498. X            else
  499. X                l2cn(tout0,tout1,out,l);
  500. X            xor0=tin0;
  501. X            xor1=tin1;
  502. X            }
  503. X        }
  504. X    tin0=tin1=tout0=tout1=xor0=xor1=0;
  505. X    tin[0]=tin[1]=tout[0]=tout[1]=0;
  506. X    return(0);
  507. X    }
  508. X
  509. END_OF_FILE
  510.   if test 1451 -ne `wc -c <'cbc_enc.c'`; then
  511.     echo shar: \"'cbc_enc.c'\" unpacked with wrong size!
  512.   fi
  513.   # end of 'cbc_enc.c'
  514. fi
  515. if test -f 'cfb_enc.c' -a "${1}" != "-c" ; then 
  516.   echo shar: Will not clobber existing file \"'cfb_enc.c'\"
  517. else
  518.   echo shar: Extracting \"'cfb_enc.c'\" \(2172 characters\)
  519.   sed "s/^X//" >'cfb_enc.c' <<'END_OF_FILE'
  520. X/* cfb_enc.c */
  521. X/* Copyright (C) 1993 Eric Young - see README for more details */
  522. X#include "des_locl.h"
  523. X
  524. X/* The input and output are loaded in multiples of 8 bits.
  525. X * What this means is that if you hame numbits=12 and length=2
  526. X * the first 12 bits will be retrieved from the first byte and half
  527. X * the second.  The second 12 bits will come from the 3rd and half the 4th
  528. X * byte.
  529. X */
  530. Xint des_cfb_encrypt(in,out,numbits,length,schedule,ivec,encrypt)
  531. Xunsigned char *in,*out;
  532. Xint numbits;
  533. Xlong length;
  534. Xdes_key_schedule schedule;
  535. Xdes_cblock *ivec;
  536. Xint encrypt;
  537. X    {
  538. X    register unsigned long d0,d1,v0,v1,n=(numbits+7)/8;
  539. X    register unsigned long mask0,mask1;
  540. X    register long l=length;
  541. X    register int num=numbits;
  542. X    unsigned long ti[2],to[2];
  543. X    unsigned char *iv;
  544. X
  545. X    if (num > 64) return(0);
  546. X    if (num > 32)
  547. X        {
  548. X        mask0=0xffffffff;
  549. X        if (num == 64)
  550. X            mask1=mask0;
  551. X        else
  552. X            mask1=(1L<<(num-32))-1;
  553. X        }
  554. X    else
  555. X        {
  556. X        if (num == 32)
  557. X            mask0=0xffffffff;
  558. X        else
  559. X            mask0=(1L<<num)-1;
  560. X        mask1=0x00000000;
  561. X        }
  562. X
  563. X    iv=(unsigned char *)ivec;
  564. X    c2l(iv,v0);
  565. X    c2l(iv,v1);
  566. X    if (encrypt)
  567. X        {
  568. X        while (l-- > 0)
  569. X            {
  570. X            ti[0]=v0;
  571. X            ti[1]=v1;
  572. X            des_encrypt((unsigned long *)ti,(unsigned long *)to,
  573. X                    schedule,DES_ENCRYPT);
  574. X            c2ln(in,d0,d1,n);
  575. X            in+=n;
  576. X            d0=(d0^to[0])&mask0;
  577. X            d1=(d1^to[1])&mask1;
  578. X            l2cn(d0,d1,out,n);
  579. X            out+=n;
  580. X            if (num > 32)
  581. X                {
  582. X                v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffff;
  583. X                v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffff;
  584. X                }
  585. X            else
  586. X                {
  587. X                v0=((v0>>num)|(v1<<(32-num)))&0xffffffff;
  588. X                v1=((v1>>num)|(d0<<(32-num)))&0xffffffff;
  589. X                }
  590. X            }
  591. X        }
  592. X    else
  593. X        {
  594. X        while (l-- > 0)
  595. X            {
  596. X            ti[0]=v0;
  597. X            ti[1]=v1;
  598. X            des_encrypt((unsigned long *)ti,(unsigned long *)to,
  599. X                    schedule,DES_ENCRYPT);
  600. X            c2ln(in,d0,d1,n);
  601. X            in+=n;
  602. X            if (num > 32)
  603. X                {
  604. X                v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffff;
  605. X                v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffff;
  606. X                }
  607. X            else
  608. X                {
  609. X                v0=((v0>>num)|(v1<<(32-num)))&0xffffffff;
  610. X                v1=((v1>>num)|(d0<<(32-num)))&0xffffffff;
  611. X                }
  612. X            d0=(d0^to[0])&mask0;
  613. X            d1=(d1^to[1])&mask1;
  614. X            l2cn(d0,d1,out,n);
  615. X            out+=n;
  616. X            }
  617. X        }
  618. X    iv=(unsigned char *)ivec;
  619. X    l2c(v0,iv);
  620. X    l2c(v1,iv);
  621. X    v0=v1=d0=d1=ti[0]=ti[1]=to[0]=to[1]=0;
  622. X    return(0);
  623. X    }
  624. X
  625. END_OF_FILE
  626.   if test 2172 -ne `wc -c <'cfb_enc.c'`; then
  627.     echo shar: \"'cfb_enc.c'\" unpacked with wrong size!
  628.   fi
  629.   # end of 'cfb_enc.c'
  630. fi
  631. if test -f 'doIP' -a "${1}" != "-c" ; then 
  632.   echo shar: Will not clobber existing file \"'doIP'\"
  633. else
  634.   echo shar: Extracting \"'doIP'\" \(831 characters\)
  635.   sed "s/^X//" >'doIP' <<'END_OF_FILE'
  636. X#!/usr/local/bin/perl
  637. X
  638. X@l=(
  639. X     0, 1, 2, 3, 4, 5, 6, 7,
  640. X     8, 9,10,11,12,13,14,15,
  641. X    16,17,18,19,20,21,22,23,
  642. X    24,25,26,27,28,29,30,31
  643. X    );
  644. X@r=(
  645. X    32,33,34,35,36,37,38,39,
  646. X    40,41,42,43,44,45,46,47,
  647. X    48,49,50,51,52,53,54,55,
  648. X    56,57,58,59,60,61,62,63
  649. X    );
  650. X
  651. Xrequire 'shifts.pl';
  652. X
  653. Xsub PERM_OP
  654. X    {
  655. X    local(*a,*b,*t,$n,$m)=@_;
  656. X
  657. X    @z=&shift(*a,-$n);
  658. X    @z=&xor(*b,*z);
  659. X    @z=&and(*z,$m);
  660. X    @b=&xor(*b,*z);
  661. X    @z=&shift(*z,$n);
  662. X    @a=&xor(*a,*z);
  663. X    }
  664. X
  665. X
  666. X@L=@l;
  667. X@R=@r;
  668. X&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
  669. X&PERM_OP(*L,*R,*T,16,0x0000ffff);
  670. X&PERM_OP(*R,*L,*T,2,0x33333333);
  671. X&PERM_OP(*L,*R,*T,8,0x00ff00ff);
  672. X&PERM_OP(*R,*L,*T,1,0x55555555);
  673. X    &printit(@L);
  674. X    &printit(@R);
  675. X&PERM_OP(*R,*L,*T,1,0x55555555);
  676. X&PERM_OP(*L,*R,*T,8,0x00ff00ff);
  677. X&PERM_OP(*R,*L,*T,2,0x33333333);
  678. X&PERM_OP(*L,*R,*T,16,0x0000ffff);
  679. X&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
  680. X    &printit(@L);
  681. X    &printit(@R);
  682. END_OF_FILE
  683.   if test 831 -ne `wc -c <'doIP'`; then
  684.     echo shar: \"'doIP'\" unpacked with wrong size!
  685.   fi
  686.   # end of 'doIP'
  687. fi
  688. if test -f 'doPC1' -a "${1}" != "-c" ; then 
  689.   echo shar: Will not clobber existing file \"'doPC1'\"
  690. else
  691.   echo shar: Extracting \"'doPC1'\" \(2106 characters\)
  692.   sed "s/^X//" >'doPC1' <<'END_OF_FILE'
  693. X#!/usr/local/bin/perl
  694. X
  695. X@l=(
  696. X     0, 1, 2, 3, 4, 5, 6, 7,
  697. X     8, 9,10,11,12,13,14,15,
  698. X    16,17,18,19,20,21,22,23,
  699. X    24,25,26,27,28,29,30,31
  700. X    );
  701. X@r=(
  702. X    32,33,34,35,36,37,38,39,
  703. X    40,41,42,43,44,45,46,47,
  704. X    48,49,50,51,52,53,54,55,
  705. X    56,57,58,59,60,61,62,63
  706. X    );
  707. X
  708. Xrequire 'shifts.pl';
  709. X
  710. Xsub PERM_OP
  711. X    {
  712. X    local(*a,*b,*t,$n,$m)=@_;
  713. X
  714. X    @z=&shift(*a,-$n);
  715. X    @z=&xor(*b,*z);
  716. X    @z=&and(*z,$m);
  717. X    @b=&xor(*b,*z);
  718. X    @z=&shift(*z,$n);
  719. X    @a=&xor(*a,*z);
  720. X    }
  721. X
  722. Xsub HPERM_OP2
  723. X    {
  724. X    local(*a,*t,$n,$m)=@_;
  725. X    local(@x,@y,$i);
  726. X
  727. X    @z=&shift(*a,16-$n);
  728. X    @z=&xor(*a,*z);
  729. X    @z=&and(*z,$m);
  730. X    @a=&xor(*a,*z);
  731. X    @z=&shift(*z,$n-16);
  732. X    @a=&xor(*a,*z);
  733. X    }
  734. X
  735. Xsub HPERM_OP
  736. X        {
  737. X        local(*a,*t,$n,$m)=@_;
  738. X        local(@x,@y,$i);
  739. X
  740. X        for ($i=0; $i<16; $i++)
  741. X                {
  742. X                $x[$i]=$a[$i];
  743. X                $y[$i]=$a[16+$i];
  744. X                }
  745. X        @z=&shift(*x,-$n);
  746. X        @z=&xor(*y,*z);
  747. X        @z=&and(*z,$m);
  748. X        @y=&xor(*y,*z);
  749. X        @z=&shift(*z,$n);
  750. X        @x=&xor(*x,*z);
  751. X        for ($i=0; $i<16; $i++)
  752. X                {
  753. X                $a[$i]=$x[$i];
  754. X                $a[16+$i]=$y[$i];
  755. X                }
  756. X        }
  757. X
  758. X@L=@l;
  759. X@R=@r;
  760. X
  761. X    print "---\n"; &printit(@R);
  762. X&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
  763. X    print "---\n"; &printit(@R);
  764. X&HPERM_OP2(*L,*T,-2,0xcccc0000);
  765. X&HPERM_OP2(*R,*T,-2,0xcccc0000);
  766. X    print "---\n"; &printit(@R);
  767. X&PERM_OP(*R,*L,*T,1,0x55555555);
  768. X    print "---\n"; &printit(@R);
  769. X&PERM_OP(*L,*R,*T,8,0x00ff00ff);
  770. X    print "---\n"; &printit(@R);
  771. X&PERM_OP(*R,*L,*T,1,0x55555555);
  772. X    print "---\n"; &printit(@R);
  773. X#    &printit(@L);
  774. X    &printit(@R);
  775. Xprint <<"EOF";
  776. X==============================
  777. X63  55  47  39  31  23  15   7  
  778. X62  54  46  38  30  22  14   6  
  779. X61  53  45  37  29  21  13   5  
  780. X60  52  44  36  --  --  --  --  
  781. X
  782. X57  49  41  33  25  17   9   1  
  783. X58  50  42  34  26  18  10   2  
  784. X59  51  43  35  27  19  11   3  
  785. X28  20  12   4  --  --  --  --  
  786. XEOF
  787. Xexit(1);
  788. X@A=&and(*R,0x000000ff);
  789. X@A=&shift(*A,16);
  790. X@B=&and(*R,0x0000ff00);
  791. X@C=&and(*R,0x00ff0000);
  792. X@C=&shift(*C,-16);
  793. X@D=&and(*L,0xf0000000);
  794. X@D=&shift(*D,-4);
  795. X@A=&or(*A,*B);
  796. X@B=&or(*D,*C);
  797. X@R=&or(*A,*B);
  798. X@L=&and(*L,0x0fffffff);
  799. X
  800. X    &printit(@L);
  801. X    &printit(@R);
  802. X
  803. END_OF_FILE
  804.   if test 2106 -ne `wc -c <'doPC1'`; then
  805.     echo shar: \"'doPC1'\" unpacked with wrong size!
  806.   fi
  807.   # end of 'doPC1'
  808. fi
  809. if test -f 'ofb_enc.c' -a "${1}" != "-c" ; then 
  810.   echo shar: Will not clobber existing file \"'ofb_enc.c'\"
  811. else
  812.   echo shar: Extracting \"'ofb_enc.c'\" \(1368 characters\)
  813.   sed "s/^X//" >'ofb_enc.c' <<'END_OF_FILE'
  814. X/* ofb_enc.c */
  815. X/* Copyright (C) 1993 Eric Young - see README for more details */
  816. X#include "des_locl.h"
  817. X
  818. X/* The input and output are loaded in multiples of 8 bits.
  819. X * What this means is that if you hame numbits=12 and length=2
  820. X * the first 12 bits will be retrieved from the first byte and half
  821. X * the second.  The second 12 bits will come from the 3rd and half the 4th
  822. X * byte.
  823. X */
  824. Xint des_ofb_encrypt(in,out,numbits,length,schedule,ivec)
  825. Xunsigned char *in,*out;
  826. Xint numbits;
  827. Xlong length;
  828. Xdes_key_schedule schedule;
  829. Xdes_cblock *ivec;
  830. X    {
  831. X    register unsigned long d0,d1,v0,v1,n=(numbits+7)/8;
  832. X    register unsigned long mask0,mask1;
  833. X    register long l=length;
  834. X    register int num=numbits;
  835. X    unsigned long ti[2];
  836. X    unsigned char *iv;
  837. X
  838. X    if (num > 64) return(0);
  839. X    if (num > 32)
  840. X        {
  841. X        mask0=0xffffffff;
  842. X        if (num >= 64)
  843. X            mask1=mask0;
  844. X        else
  845. X            mask1=(1L<<(num-32))-1;
  846. X        }
  847. X    else
  848. X        {
  849. X        if (num == 32)
  850. X            mask0=0xffffffff;
  851. X        else
  852. X            mask0=(1L<<num)-1;
  853. X        mask1=0x00000000;
  854. X        }
  855. X
  856. X    iv=(unsigned char *)ivec;
  857. X    c2l(iv,v0);
  858. X    c2l(iv,v1);
  859. X    ti[0]=v0;
  860. X    ti[1]=v1;
  861. X    while (l-- > 0)
  862. X        {
  863. X        des_encrypt((unsigned long *)ti,(unsigned long *)ti,
  864. X                schedule,DES_ENCRYPT);
  865. X        c2ln(in,d0,d1,n);
  866. X        in+=n;
  867. X        d0=(d0^ti[0])&mask0;
  868. X        d1=(d1^ti[1])&mask1;
  869. X        l2cn(d0,d1,out,n);
  870. X        out+=n;
  871. X        }
  872. X    v0=ti[0];
  873. X    v1=ti[1];
  874. X    iv=(unsigned char *)ivec;
  875. X    l2c(v0,iv);
  876. X    l2c(v1,iv);
  877. X    v0=v1=d0=d1=ti[0]=ti[1]=0;
  878. X    return(0);
  879. X    }
  880. X
  881. END_OF_FILE
  882.   if test 1368 -ne `wc -c <'ofb_enc.c'`; then
  883.     echo shar: \"'ofb_enc.c'\" unpacked with wrong size!
  884.   fi
  885.   # end of 'ofb_enc.c'
  886. fi
  887. if test -f 'podd.h' -a "${1}" != "-c" ; then 
  888.   echo shar: Will not clobber existing file \"'podd.h'\"
  889. else
  890.   echo shar: Extracting \"'podd.h'\" \(1159 characters\)
  891.   sed "s/^X//" >'podd.h' <<'END_OF_FILE'
  892. X/* podd.h */
  893. X/* Copyright (C) 1993 Eric Young - see README for more details */
  894. Xstatic unsigned char odd_parity[256]={
  895. X  1,  1,  2,  2,  4,  4,  7,  7,  8,  8, 11, 11, 13, 13, 14, 14,
  896. X 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
  897. X 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
  898. X 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
  899. X 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
  900. X 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
  901. X 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
  902. X112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
  903. X128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
  904. X145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
  905. X161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
  906. X176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
  907. X193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
  908. X208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
  909. X224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
  910. X241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
  911. END_OF_FILE
  912.   if test 1159 -ne `wc -c <'podd.h'`; then
  913.     echo shar: \"'podd.h'\" unpacked with wrong size!
  914.   fi
  915.   # end of 'podd.h'
  916. fi
  917. if test -f 'qud_cksm.c' -a "${1}" != "-c" ; then 
  918.   echo shar: Will not clobber existing file \"'qud_cksm.c'\"
  919. else
  920.   echo shar: Extracting \"'qud_cksm.c'\" \(2121 characters\)
  921.   sed "s/^X//" >'qud_cksm.c' <<'END_OF_FILE'
  922. X/* qud_cksm.c */
  923. X/* Copyright (C) 1993 Eric Young - see README for more details */
  924. X/* From "Message Authentication"  R.R. Jueneman, S.M. Matyas, C.H. Meyer
  925. X * IEEE Communications Magazine Sept 1985 Vol. 23 No. 9 p 29-40
  926. X * This module in only based on the code in this paper and is
  927. X * almost definitely not the same as the MIT implementation.
  928. X */
  929. X#include "des_locl.h"
  930. X
  931. X/* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */
  932. X#define B0(a)    (((unsigned long)(a)))
  933. X#define B1(a)    (((unsigned long)(a))<<8)
  934. X#define B2(a)    (((unsigned long)(a))<<16)
  935. X#define B3(a)    (((unsigned long)(a))<<24)
  936. X
  937. X/* used to scramble things a bit */
  938. X/* Got the value MIT uses via brute force :-) 2/10/90 eay */
  939. X#define NOISE    ((unsigned long)83653421)
  940. X
  941. Xunsigned long des_quad_cksum(input,output,length,out_count,seed)
  942. Xdes_cblock *input;
  943. Xdes_cblock *output;
  944. Xlong length;
  945. Xint out_count;
  946. Xdes_cblock *seed;
  947. X    {
  948. X    unsigned long z0,z1,t0,t1;
  949. X    int i;
  950. X    long l=0;
  951. X    unsigned char *cp;
  952. X    unsigned char *lp;
  953. X
  954. X    if (out_count < 1) out_count=1;
  955. X    lp=(unsigned char *)output;
  956. X
  957. X    z0=B0((*seed)[0])|B1((*seed)[1])|B2((*seed)[2])|B3((*seed)[3]);
  958. X    z1=B0((*seed)[4])|B1((*seed)[5])|B2((*seed)[6])|B3((*seed)[7]);
  959. X
  960. X    for (i=0; ((i<4)&&(i<out_count)); i++)
  961. X        {
  962. X        cp=(unsigned char *)input;
  963. X        l=length;
  964. X        while (l > 0)
  965. X            {
  966. X            if (l > 1)
  967. X                {
  968. X                t0= (unsigned long)(*(cp++));
  969. X                t0|=(unsigned long)B1(*(cp++));
  970. X                l--;
  971. X                }
  972. X            else
  973. X                t0= (unsigned long)(*(cp++));
  974. X            l--;
  975. X            /* add */
  976. X            t0+=z0;
  977. X            t0&=0xffffffff;
  978. X            t1=z1;
  979. X            /* square, well sort of square */
  980. X            z0=((((t0*t0)&0xffffffff)+((t1*t1)&0xffffffff))
  981. X                &0xffffffff)%0x7fffffff; 
  982. X            z1=((t0*((t1+NOISE)&0xffffffff))&0xffffffff)%0x7fffffff;
  983. X            }
  984. X        if (lp != NULL)
  985. X            {
  986. X            /* I believe I finally have things worked out.
  987. X             * The MIT library assumes that the checksum
  988. X             * is one huge number and it is returned in a
  989. X             * host dependant byte order.
  990. X             */
  991. X            static unsigned long l=1;
  992. X            static unsigned char *c=(unsigned char *)&l;
  993. X
  994. X            if (c[0])
  995. X                {
  996. X                l2c(z0,lp);
  997. X                l2c(z1,lp);
  998. X                }
  999. X            else
  1000. X                {
  1001. X                lp=output[out_count-i-1];
  1002. X                l2n(z1,lp);
  1003. X                l2n(z0,lp);
  1004. X                }
  1005. X            }
  1006. X        }
  1007. X    return(z0);
  1008. X    }
  1009. X
  1010. END_OF_FILE
  1011.   if test 2121 -ne `wc -c <'qud_cksm.c'`; then
  1012.     echo shar: \"'qud_cksm.c'\" unpacked with wrong size!
  1013.   fi
  1014.   # end of 'qud_cksm.c'
  1015. fi
  1016. if test -f 'rand_key.c' -a "${1}" != "-c" ; then 
  1017.   echo shar: Will not clobber existing file \"'rand_key.c'\"
  1018. else
  1019.   echo shar: Extracting \"'rand_key.c'\" \(918 characters\)
  1020.   sed "s/^X//" >'rand_key.c' <<'END_OF_FILE'
  1021. X/* rand_key.c */
  1022. X/* Copyright (C) 1993 Eric Young - see README for more details */
  1023. X#include "des_locl.h"
  1024. X
  1025. Xint des_random_key(ret)
  1026. Xdes_cblock ret;
  1027. X    {
  1028. X    des_key_schedule ks;
  1029. X    static unsigned long c=0;
  1030. X    static unsigned short pid=0;
  1031. X    static des_cblock data={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
  1032. X    des_cblock key;
  1033. X    unsigned char *p;
  1034. X    unsigned long t;
  1035. X
  1036. X#ifdef MSDOS
  1037. X    pid=1;
  1038. X#else
  1039. X    if (!pid) pid=getpid();
  1040. X#endif
  1041. X    p=key;
  1042. X    t=(unsigned long)time(NULL);
  1043. X    l2c(t,p);
  1044. X    t=(unsigned long)((pid)|((c++)<<16));
  1045. X    l2c(t,p);
  1046. X
  1047. X    des_set_odd_parity((des_cblock *)data);
  1048. X    des_set_key((des_cblock *)data,ks);
  1049. X    des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
  1050. X        (long)sizeof(key),ks,(des_cblock *)data);
  1051. X    des_set_odd_parity((des_cblock *)key);
  1052. X    des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
  1053. X        (long)sizeof(key),ks,(des_cblock *)data);
  1054. X
  1055. X    bcopy(key,ret,sizeof(key));
  1056. X    bzero(key,sizeof(key));
  1057. X    bzero(ks,sizeof(ks));
  1058. X    t=0;
  1059. X    return(0);
  1060. X    }
  1061. END_OF_FILE
  1062.   if test 918 -ne `wc -c <'rand_key.c'`; then
  1063.     echo shar: \"'rand_key.c'\" unpacked with wrong size!
  1064.   fi
  1065.   # end of 'rand_key.c'
  1066. fi
  1067. if test -f 'rpw.c' -a "${1}" != "-c" ; then 
  1068.   echo shar: Will not clobber existing file \"'rpw.c'\"
  1069. else
  1070.   echo shar: Extracting \"'rpw.c'\" \(728 characters\)
  1071.   sed "s/^X//" >'rpw.c' <<'END_OF_FILE'
  1072. X/* rpw.c */
  1073. X/* Copyright (C) 1993 Eric Young - see README for more details */
  1074. X#include <stdio.h>
  1075. X#include "des.h"
  1076. X
  1077. Xmain()
  1078. X    {
  1079. X    des_cblock k,k1;
  1080. X    int i;
  1081. X
  1082. X    printf("read passwd\n");
  1083. X    if ((i=des_read_password((C_Block *)k,"Enter password:",0)) == 0)
  1084. X        {
  1085. X        printf("password = ");
  1086. X        for (i=0; i<8; i++)
  1087. X            printf("%02x ",k[i]);
  1088. X        }
  1089. X    else
  1090. X        printf("error %d\n",i);
  1091. X    printf("\n");
  1092. X    printf("read 2passwds and verify\n");
  1093. X    if ((i=des_read_2passwords((C_Block *)k,(C_Block *)k1,
  1094. X        "Enter verified password:",1)) == 0)
  1095. X        {
  1096. X        printf("password1 = ");
  1097. X        for (i=0; i<8; i++)
  1098. X            printf("%02x ",k[i]);
  1099. X        printf("\n");
  1100. X        printf("password2 = ");
  1101. X        for (i=0; i<8; i++)
  1102. X            printf("%02x ",k1[i]);
  1103. X        printf("\n");
  1104. X        }
  1105. X    else
  1106. X        printf("error %d\n",i);
  1107. X    }
  1108. END_OF_FILE
  1109.   if test 728 -ne `wc -c <'rpw.c'`; then
  1110.     echo shar: \"'rpw.c'\" unpacked with wrong size!
  1111.   fi
  1112.   # end of 'rpw.c'
  1113. fi
  1114. if test -f 'shifts.pl' -a "${1}" != "-c" ; then 
  1115.   echo shar: Will not clobber existing file \"'shifts.pl'\"
  1116. else
  1117.   echo shar: Extracting \"'shifts.pl'\" \(1978 characters\)
  1118.   sed "s/^X//" >'shifts.pl' <<'END_OF_FILE'
  1119. Xsub lab_shift
  1120. X    {
  1121. X    local(*a,$n)=@_;
  1122. X    local(@r,$i,$j,$k,$d,@z);
  1123. X
  1124. X    @r=&shift(*a,$n);
  1125. X    foreach $i (0 .. 31)
  1126. X        {
  1127. X        @z=split(/\^/,$r[$i]);
  1128. X        for ($j=0; $j <= $#z; $j++)
  1129. X            {
  1130. X            ($d)=($z[$j] =~ /^(..)/);
  1131. X            ($k)=($z[$j] =~ /\[(.*)\]$/);
  1132. X            $k.=",$n" if ($k ne "");
  1133. X            $k="$n"      if ($k eq "");
  1134. X            $d="$d[$k]";
  1135. X            $z[$j]=$d;
  1136. X            }
  1137. X        $r[$i]=join('^',@z);
  1138. X        }
  1139. X    return(@r);
  1140. X    }
  1141. X
  1142. Xsub shift
  1143. X    {
  1144. X    local(*a,$n)=@_;
  1145. X    local(@f);
  1146. X
  1147. X    if ($n > 0)
  1148. X        {
  1149. X        @f=&shiftl(*a,$n);
  1150. X        }
  1151. X    else
  1152. X        {
  1153. X        @f=&shiftr(*a,-$n);
  1154. X        }
  1155. X    return(@f);
  1156. X    }
  1157. X
  1158. Xsub shiftr
  1159. X    {
  1160. X    local(*a,$n)=@_;
  1161. X    local(@r,$i);
  1162. X
  1163. X    $#r=31;
  1164. X    foreach $i (0 .. 31)
  1165. X        {
  1166. X        if (($i+$n) > 31)
  1167. X            {
  1168. X            $r[$i]="--";
  1169. X            }
  1170. X        else
  1171. X            {
  1172. X            $r[$i]=$a[$i+$n];
  1173. X            }
  1174. X        }
  1175. X    return(@r);
  1176. X    }
  1177. X
  1178. Xsub shiftl
  1179. X    {
  1180. X    local(*a,$n)=@_;
  1181. X    local(@r,$i);
  1182. X
  1183. X    $#r=31;
  1184. X    foreach $i (0 .. 31)
  1185. X        {
  1186. X        if ($i < $n)
  1187. X            {
  1188. X            $r[$i]="--";
  1189. X            }
  1190. X        else
  1191. X            {
  1192. X            $r[$i]=$a[$i-$n];
  1193. X            }
  1194. X        }
  1195. X    return(@r);
  1196. X    }
  1197. X
  1198. Xsub printit
  1199. X    {
  1200. X    local(@a)=@_;
  1201. X    local($i);
  1202. X
  1203. X    foreach $i (0 .. 31)
  1204. X        {
  1205. X        printf "%2s  ",$a[$i];
  1206. X        print "\n" if (($i%8) == 7);
  1207. X        }
  1208. X    print "\n";
  1209. X    }
  1210. X
  1211. Xsub xor
  1212. X    {
  1213. X    local(*a,*b)=@_;
  1214. X    local(@r,$i);
  1215. X
  1216. X    $#r=31;
  1217. X    foreach $i (0 .. 31)
  1218. X        {
  1219. X        $r[$i]=&compress($a[$i].'^'.$b[$i]);
  1220. X#        $r[$i]=$a[$i]."^".$b[$i];
  1221. X        }
  1222. X    return(@r);
  1223. X    }
  1224. X
  1225. Xsub and
  1226. X    {
  1227. X    local(*a,$m)=@_;
  1228. X    local(@r,$i);
  1229. X
  1230. X    $#r=31;
  1231. X    foreach $i (0 .. 31)
  1232. X        {
  1233. X        $r[$i]=(($m & (1<<$i))?($a[$i]):('--'));
  1234. X        }
  1235. X    return(@r);
  1236. X    }
  1237. X
  1238. Xsub or
  1239. X    {
  1240. X    local(*a,*b)=@_;
  1241. X    local(@r,$i);
  1242. X
  1243. X    $#r=31;
  1244. X    foreach $i (0 .. 31)
  1245. X        {
  1246. X        $r[$i]='--'   if (($a[$i] eq '--') && ($b[$i] eq '--'));
  1247. X        $r[$i]=$a[$i] if (($a[$i] ne '--') && ($b[$i] eq '--'));
  1248. X        $r[$i]=$b[$i] if (($a[$i] eq '--') && ($b[$i] ne '--'));
  1249. X        $r[$i]='++'   if (($a[$i] ne '--') && ($b[$i] ne '--'));
  1250. X        }
  1251. X    return(@r);
  1252. X    }
  1253. X
  1254. Xsub compress
  1255. X    {
  1256. X    local($s)=@_;
  1257. X    local($_,$i,@a,%a,$r);
  1258. X
  1259. X    $s =~ s/\^\^/\^/g;
  1260. X    $s =~ s/^\^//;
  1261. X    $s =~ s/\^$//;
  1262. X    @a=split(/\^/,$s);
  1263. X
  1264. X    while ($#a >= 0)
  1265. X        {
  1266. X        $_=shift(@a);
  1267. X        next unless /\d/;
  1268. X        $a{$_}++;
  1269. X        }
  1270. X    foreach $i (sort keys %a)
  1271. X        {
  1272. X        next if ($a{$i}%2 == 0);
  1273. X        $r.="$i^";
  1274. X        }
  1275. X    chop($r);
  1276. X    return($r);
  1277. X    }
  1278. X1;
  1279. END_OF_FILE
  1280.   if test 1978 -ne `wc -c <'shifts.pl'`; then
  1281.     echo shar: \"'shifts.pl'\" unpacked with wrong size!
  1282.   fi
  1283.   # end of 'shifts.pl'
  1284. fi
  1285. echo shar: End of archive 5 \(of 5\).
  1286. cp /dev/null ark5isdone
  1287. MISSING=""
  1288. for I in 1 2 3 4 5 ; do
  1289.     if test ! -f ark${I}isdone ; then
  1290.     MISSING="${MISSING} ${I}"
  1291.     fi
  1292. done
  1293. if test "${MISSING}" = "" ; then
  1294.     echo You have unpacked all 5 archives.
  1295.     rm -f ark[1-9]isdone
  1296. else
  1297.     echo You still must unpack the following archives:
  1298.     echo "        " ${MISSING}
  1299. fi
  1300. exit 0
  1301. exit 0 # Just in case...
  1302.