alo@kampi.hut.fi (Antti Louko) (03/10/89)
Submitted by: alo@kampi.hut.fi (Antti Louko) Posting-number: Volume 18, Issue 7 Archive-name: des-no-usa/Part01 Moderator's note: This is a posting of DES routines suitable for use with MIT's kerberos. It was created in Finland, and is being posted from Australia, and so is entirely free of US export controls. I don't usually make comp.sources.unix postings that originate outside Australia, but there is no European sub-moderator (yet?) and this is rather a special case. Where possible I will be taking special care to make sure that as much of the net as is possible receives this posting without it having passed through the US on the way. Unfortunately there is no way I can make that true for everyone. The following note is from the original author (Antti Louko) ... Here is my DES-package. I hope that the lack of documentation doesn't prevent posting this package in comp.sources.unix. I have tried to implement library functions to match those of kerberos-des-package. So kerberos manual pages give some hints what the library functions do. As I have said earlier, at least the library functions should be compiled with gcc, if one wants the best performance. If it is needed I (or somebody else with gcc) can provide assembler- or .o- files for VAX- and SUN3- architecures. These files should be checksummed of course to prevent any tampering. :-) Antti Louko (alo@kampi.hut.fi) Since that was written I have received an updated version that does include a man page for the library routines. I have added Makefiles for standard make (those in the original were for GNU make only). Note, these are very primitive Makefiles, if you change anything, "make clean" and recompile from scratch. I also added some "#ifdef BSD" lines to give this a reasonable chance of compiling in a sys V environment (at the expense of giving up the -t (timing) option to des-certify, and of leaving echo enabled when requesting passwords). I am sure that if someone was to provide Sys V versions of the code that ends up missing and mail it to Antti, that a patch will be forthcoming. I suggest that if you're located in the US you don't attempt to modify these routines, their purity may be lost if tainted by contributions from such a restrictive country. Notes: you need "getopt(3)" for the programs to link, if your system lacks it, you can get it from a comp.sources.unix archive near you. If you remove the .h files from lib that "make clean" tells you you can remove, you will need Larry Wall's "perl" program to replace them. Also available in a comp.sources.unix archive near you. You should define BIG_ENDIAN if you are on a big endian host. See lib/des-private.h (I added the definitions for sparc and interdata, no guarantees that the routines work on those hosts). There are 2 files in the 'prog' directory that I uuencoded (now F1.uu and F2.uu), I have no idea what they are useful for, if anything, however should you need them, they will need to be uudecoded (to give F1 and F2). : -------------------------------- cut here --------------------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 2)." # Contents: README VERSION COPYRIGHT GNUmakefile Makefile Makerules # sun.ed man man/des.1 man/libdes.3 prog prog/Makerules # prog/des-certify.c prog/des.c prog/testdata prog/.gdbinit # prog/GNUmakefile prog/Makefile prog/F1.uu prog/F2.uu tables # tables/IP tables/IP-1 tables/E tables/S tables/GNUmakefile # tables/REMOVABLE tables/fp.make tables/P tables/mk-ip # tables/ip.make tables/eight.make tables/Makerules # tables/spe-table.make tables/ksched.dontmake # tables/shift4.dontmake lib MANIFEST # Wrapped by kre@munnari on Fri Mar 10 18:29:39 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(546 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' X-*- text -*- XThis is a DES program package made by Antti Louko (alo@santra.hut.fi) X XCopyright 1989 Antti Louko. All Rights Reserved. X XCOPYRIGHT FILE TELLS WHAT YOU ARE ALLOWED TO DO WITH THIS SOFTWARE X XThis program should compile just fine on VAX with BSD 4.3. On SUNS, Xyou should edit Makerules to include -msoft-float option if you don't Xhave FPU. For other machines you should typedef des_u_long to be an Xunsigned 32-bit integer type. If processor needs aligned multi-byte Xaccesses, you may have to modify copy* -macros in des-private.h file. END_OF_FILE if test 546 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'VERSION' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'VERSION'\" else echo shar: Extracting \"'VERSION'\" \(33 characters\) sed "s/^X//" >'VERSION' <<'END_OF_FILE' XVersion: 1.0 XDate: March 9 1989 END_OF_FILE if test 33 -ne `wc -c <'VERSION'`; then echo shar: \"'VERSION'\" unpacked with wrong size! fi # end of 'VERSION' fi if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'COPYRIGHT'\" else echo shar: Extracting \"'COPYRIGHT'\" \(518 characters\) sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE' X-*- text -*- XCopyright 1989 Antti Louko. All Rights Reserved. X XThis is a DES implementation written by Antti Louko X(alo@kampi.hut.fi). It is based on DES description found in D.E.R. XDenning's book Cryptography and Data Security. At this time you may Xuse this program for non-commercial use. If you modify the program, Xyou must add a comment in the modified file indicating who modified Xit. For commercial purposes please contact me. X XIf you find bugs or otherwise modify this program, please send Xchanges back to me. END_OF_FILE if test 518 -ne `wc -c <'COPYRIGHT'`; then echo shar: \"'COPYRIGHT'\" unpacked with wrong size! fi # end of 'COPYRIGHT' fi if test -f 'GNUmakefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'GNUmakefile'\" else echo shar: Extracting \"'GNUmakefile'\" \(84 characters\) sed "s/^X//" >'GNUmakefile' <<'END_OF_FILE' X# This make file is for GNU make X XSUBDIRS= tables lib prog X Xinclude Makerules X Xall: END_OF_FILE if test 84 -ne `wc -c <'GNUmakefile'`; then echo shar: \"'GNUmakefile'\" unpacked with wrong size! fi # end of 'GNUmakefile' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(258 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# X# Kludged standard make Makefile (adapted from GNU make version). kre X# XCFLAGS= -O #SUN -msoft-float XPRINT= enscript XMAKE= make X XSUBDIRS= tables lib prog X Xall clean print: X for i in $(SUBDIRS); do (cd $$i; $(MAKE) $@); done X X$(SUBDIRS): X cd $@; $(MAKE) END_OF_FILE if test 258 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'Makerules' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makerules'\" else echo shar: Extracting \"'Makerules'\" \(560 characters\) sed "s/^X//" >'Makerules' <<'END_OF_FILE' XCC:= gcc XCFLAGS:= -O #SUN -msoft-float XPRINT:= enscript X XMAINTOPS:= all clean print s-files X.PHONY: $(MAINTOPS) X Xifdef PRINTFILES Xprint: X $(PRINT) $(PRINTFILES) Xendif X Xifdef LMAINTOPS X$(LMAINTOPS): %: %-local X X.PHONY: $(addsuffix -local,$(LMAINTOPS)) Xendif X Xifneq ($(origin SUBDIRS),file) XSUBDIRS:= Xendif X Xifdef SUBDIRS X$(MAINTOPS): X for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done Xelse X$(MAINTOPS): Xendif X Xifdef SUBDIRS X$(SUBDIRS): X $(MAKE) -C $@ Xendif X Xifneq ($(origin S_FILES),file) XS_FILES:= Xendif X Xs-files: $(S_FILES) X X%.s: %.c X $(CC) -S $(CFLAGS) $^ END_OF_FILE if test 560 -ne `wc -c <'Makerules'`; then echo shar: \"'Makerules'\" unpacked with wrong size! fi # end of 'Makerules' fi if test -f 'sun.ed' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sun.ed'\" else echo shar: Extracting \"'sun.ed'\" \(92 characters\) sed "s/^X//" >'sun.ed' <<'END_OF_FILE' X#! /bin/sh Xed Makerules << EOF Xg/#SUN/s///g Xw Xq XEOF Xed Makefile << EOF Xg/#SUN/s///g Xw Xq XEOF END_OF_FILE if test 92 -ne `wc -c <'sun.ed'`; then echo shar: \"'sun.ed'\" unpacked with wrong size! fi # end of 'sun.ed' fi if test ! -d 'man' ; then echo shar: Creating directory \"'man'\" mkdir 'man' fi if test -f 'man/des.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'man/des.1'\" else echo shar: Extracting \"'man/des.1'\" \(2158 characters\) sed "s/^X//" >'man/des.1' <<'END_OF_FILE' X.TH DES 1 "March 9, 1989" X.GN 2 X.SH NAME Xdes \- encrypt and decrypt using DES algorithm X.SH SYNOPSIS X.B des X[ X.B -k X.I keystring X] [ X.B -e X] [ X.B -d X] [ X.B -x X] [ X.B -X X] [ X.B -c X.I count X] [ X.B -p X] [ X.I inputfile X[ X.I outputfile X] ] X.SH DESCRIPTION X.I Des Xreads X.I inputfile Xand writes the en/decrypted data to X.I outputfile\c X\&. XIf file name is not given in command line, des uses standard input or output. XThe X.I keystring Xis transformed by a one-way funtion into a 8-byte key, Xwhich is then used by the algorithm. If no X.I keystring Xis given on command line, Xdes asks one with getpass(3). X.PP XDes encrypts when given X.B -e Xflag and decrypts with X.B -d\c X\&. XWith X.B -x Xflag des encrypts normally, but it doesn't produce any encrypted Xoutput, instead it prints 8-byte cryptographic checksum of input data. XThe checksum is printed to standard error file. XThis checksum can be used to verify whether the input data has been modified. XIt is computationally hard to change the input data in such a way that Xthe checksum wouldn't change. X.B -X Xis similar to X.B -x Xbut it prints the input data to output file unchanged. XUsing this feature you can for example produce a compressed tar archive Xand its checksum Xat the same time with command: X.PP X(tar cf - dir | des -X | compress > dir.tar.Z) >& dir.cksum X.PP XWith X.B -c Xdes makes encryption X.I count Xtimes for each 8kbyte block. XThis possibly makes the encrypted data harder to break. X.PP XBy default, des encrypts the data using cipher block chaining (CBC) mode. XWith X.B -p Xflag, des uses XPCBC mode, which makes it possible to detect if the data have been tampered Xafter encryption. X.SH FILES X/dev/tty is used to read a keystring by getpass(3) X.SH AUTHOR XAntti Louko (alo@kampi.hut.fi), Helsinki University of Technology XComputing Centre X.SH BUGS XThis program is at most as strong as DES algorithm itself. XSo, we urge the user to use this program only after he has assured Xhimself that DES is strong enough AND he has read the source code of this Xprogram and its libraries AND he has compiled the program himself with a Xtroyan-free compiler. I DON'T GUARANTEE THAT THIS PROGRAM IS A DECENT XENCRYPTION PROGRAM. END_OF_FILE if test 2158 -ne `wc -c <'man/des.1'`; then echo shar: \"'man/des.1'\" unpacked with wrong size! fi # end of 'man/des.1' fi if test -f 'man/libdes.3' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'man/libdes.3'\" else echo shar: Extracting \"'man/libdes.3'\" \(2347 characters\) sed "s/^X//" >'man/libdes.3' <<'END_OF_FILE' X.TH LIBDES 3 "March 9, 1989" X.GN 2 X.SH NAME Xdes_set_key, des_ecb_encrypt, des_cbc_encrypt, des_pcbc_encrypt, string_to_key X.SH SYNOPSIS X.nf X.nj X.B #include <des.h> X.PP X.B des_set_key(key,schedule) X.B C_Block *key; X.B Key_schedule *schedule; X.PP X.B des_ecb_encrypt(input,output,schedule,mode) X.B C_Block *input; X.B C_Block *output; X.B Key_schedule *schedule; X.B int mode; X.PP X.B des_cbc_encrypt(input,output,length,schedule,ivec,mode) X.B C_Block *input; X.B C_Block *output; X.B int length; X.B Key_schedule *schedule; X.B C_Block *ivec; X.B int mode; X.PP X.B des_pcbc_encrypt(input,output,length,schedule,ivec,mode) X.B C_Block *input; X.B C_Block *output; X.B int length; X.B Key_schedule *schedule; X.B C_Block *ivec; X.B int mode; X.PP X.B string_to_key(asckey,key) X.B char *asckey; X.B C_Block *key; X.PP X.fi X.SH DESCRIPTION XThese library functions implement DES-algorithm with different Xvariations. Type X.I C_Block Xis a data type containing eight bytes of Xinformation. The least significant bit of the first byte of X.I C_Block Xis bit number 1 as specified in DES standard. X.I C_Block Xis defined as follows: X.PP X.nf X.nj X.B typedef unsigned char des_u_char; X.B typedef struct { X.B des_u_char data[8]; X.B } C_Block; X.fi X.PP XA key schedule must be computed before encryption routines can be used. XThis is done with function X.I des_set_key, Xwhich computes X.B schedule Xfrom X.I key. X.I Des_ecb_encrypt Xencrypts one block of data at X.I *input Xto X.I *output Xusing X.I schedule. XIf mode is X.I DES_ENCRYPT, Xthe data is encrypted; if mode is X.I DES_DECRYPT, Xthe data is decrypted. If initial permutation or/and Xfinal permutation is not wanted, mode can be ored (|) with X.I DES_NOIPERM Xor/and X.I DES_NOFPERM. X.PP X.I Des_cbc_encrypt Xencrypts length bytes of data at X.I *input Xto X.I *output Xin cipher block chaining mode. Initial vector is at X.I *ivec. X.I *ivec Xis also updated to contain the final vector. X.PP X.I Des_pcbc_encrypt Xuses a modified cipher block chaining. This mode can Xbe used to detect if encrypted data have been tampered. In pcbc mode Xchanging ciphertext data affects all the following decrypted cleartext Xdata. X.PP X.I String_to_key Xfunction converts ascii string X.I asckey Xinto a DES key X.I *key Xusing one way function which is based on DES algorithm. X X.SH AUTHOR XAntti Louko (alo@kampi.hut.fi), Helsinki University of Technology XComputing Centre END_OF_FILE if test 2347 -ne `wc -c <'man/libdes.3'`; then echo shar: \"'man/libdes.3'\" unpacked with wrong size! fi # end of 'man/libdes.3' fi if test ! -d 'prog' ; then echo shar: Creating directory \"'prog'\" mkdir 'prog' fi if test -f 'prog/Makerules' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/Makerules'\" else echo shar: Extracting \"'prog/Makerules'\" \(560 characters\) sed "s/^X//" >'prog/Makerules' <<'END_OF_FILE' XCC:= gcc XCFLAGS:= -O #SUN -msoft-float XPRINT:= enscript X XMAINTOPS:= all clean print s-files X.PHONY: $(MAINTOPS) X Xifdef PRINTFILES Xprint: X $(PRINT) $(PRINTFILES) Xendif X Xifdef LMAINTOPS X$(LMAINTOPS): %: %-local X X.PHONY: $(addsuffix -local,$(LMAINTOPS)) Xendif X Xifneq ($(origin SUBDIRS),file) XSUBDIRS:= Xendif X Xifdef SUBDIRS X$(MAINTOPS): X for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done Xelse X$(MAINTOPS): Xendif X Xifdef SUBDIRS X$(SUBDIRS): X $(MAKE) -C $@ Xendif X Xifneq ($(origin S_FILES),file) XS_FILES:= Xendif X Xs-files: $(S_FILES) X X%.s: %.c X $(CC) -S $(CFLAGS) $^ END_OF_FILE if test 560 -ne `wc -c <'prog/Makerules'`; then echo shar: \"'prog/Makerules'\" unpacked with wrong size! fi # end of 'prog/Makerules' fi if test -f 'prog/des-certify.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/des-certify.c'\" else echo shar: Extracting \"'prog/des-certify.c'\" \(4460 characters\) sed "s/^X//" >'prog/des-certify.c' <<'END_OF_FILE' X#include "des.h" X#ifdef BSD X#include <sys/time.h> X#include <sys/resource.h> X#endif X#include <stdio.h> X Xstatic des_u_char rev8bits[] = { X#include "eight.h" X}; X Xint gflag; Xint vflag; Xint tflag; Xint count = 1; X Xextern char *optarg; Xextern int optind; X Xmain(argc,argv,envp) X Xint argc; Xchar **argv; Xchar **envp; X X{ X char s[100]; X char s_k[30]; X char s_p[30]; X char s_c[30]; X C_Block b_key; X C_Block b_plain; X C_Block b_cipher; X char s_c1[30]; X char s_p1[30]; X char s_p2[30]; X C_Block b_cipher1; X C_Block b_plain1; X C_Block b_plain2; X C_Block b_t; X Key_schedule sched; X int err; X int c; X int e_c,e_p1,e_p2; X int i; X X while ((c = getopt(argc,argv,"vn:tg")) != EOF) { X switch (c) { X case 'v': X vflag++; X break; X case 'n': X count = atoi(optarg); X break; X case 't': X tflag++; X break; X case 'g': X gflag++; X break; X default: X break; X } X } X if (gflag) { X tflag = 0; X count = 1; X } X while(fgets(s,sizeof(s),stdin)) { X e_c = e_p1 = e_p2 = err = 0; X if (sscanf(s,"%s %s %s",s_k,s_p,s_c) != 3) X break; X s_to_b(s_k,&b_key); X s_to_b(s_p,&b_plain); X s_to_b(s_c,&b_cipher); X des_set_key(&b_key,&sched); X if (tflag) X timing(0,count); X des_ecb_encrypt(&b_plain,&b_cipher1,&sched,DES_ENCRYPT); X des_ecb_encrypt(&b_cipher1,&b_plain2,&sched,DES_DECRYPT); X des_ecb_encrypt(&b_cipher,&b_plain1,&sched,DES_DECRYPT); X for(i = 3; i < count; i++) X des_ecb_encrypt(&b_plain,&b_t,&sched,DES_ENCRYPT); X if (tflag) X timing(1,count); X b_to_s(&b_key,s_k); X b_to_s(&b_plain,s_p); X b_to_s(&b_cipher,s_c); X b_to_s(&b_cipher1,s_c1); X b_to_s(&b_plain1,s_p1); X b_to_s(&b_plain2,s_p2); X if (b_cmp(&b_cipher,&b_cipher1)) { X err++; X e_c++; X } X if (b_cmp(&b_plain,&b_plain1)) { X err++; X e_p1++; X } X if (b_cmp(&b_plain,&b_plain2)) { X err++; X e_p2++; X } X if (gflag) { X printf("%s %s %s\n",s_k,s_p,s_c1); X } else { X printf("%-2s Key: %s Pla: %s Cip: %s",err ? "" : "OK",s_k,s_p,s_c); X if (vflag) { X printf("\n"); X if (e_c) X printf("%49sCip: %s\n","",s_c1); X if (e_p1) X printf("%26sPl1: %s\n","",s_p1); X if (e_p2) X printf("%26sPl2: %s\n","",s_p2); X } else { X if (e_c) printf(" c"); X if (e_p1) printf(" p1"); X if (e_p2) printf(" p2"); X printf("\n"); X } X if (tflag) X timing(2,count); X } X } X if (tflag) X timing(3,count); X return 0; X} X Xb_cmp(b1,b2) X XC_Block *b1; XC_Block *b2; X X{ X int i; X X for(i = 0; i < 8; i++) { X if (b1->data[i] != b2->data[i]) X return 1; X } X return 0; X} X Xb_to_s(b,s) X Xchar *s; XC_Block *b; X X{ X int i; X for(i = 0; i < 8; i++) { X sprintf(&s[i*2],"%02x",rev8bits[b->data[i]]); X } X} X Xs_to_b(s,b) X Xchar *s; XC_Block *b; X X{ X int i; X int j; X int c; X int cc; X X for(i = 0; i < 8; i++) { X cc = 0; X for(j = 0; j < 2; j++) { X c = s[i*2+j] & 0xff; X if (c >= '0' && c <= '9') X c -= '0'; X else if (c >= 'A' && c <= 'F') X c -= ('A'-10); X else if (c >= 'a' && c <= 'f') X c -= ('a'-10); X else X return 1; X cc = (cc << 4) + c; X } X b->data[i] = rev8bits[cc]; X } X return 0; X} X Xdouble Xs_to_speed(s,count) X Xdouble s; Xint count; X X{ X return (8.0/1024.0)*(double)count/s; X} X Xtiming(x,count) X Xint x; Xint count; X X{ X#ifdef BSD X static struct rusage r[2]; X int s,us; X double kbps; X double ss; X static int n; X static double total; X static double mint; X static double maxt; X static int cannot; X X switch (x) { X case 0: X case 1: X getrusage(RUSAGE_SELF,&r[x]); X cannot = 0; X break; X case 2: X s = r[1].ru_utime.tv_sec - r[0].ru_utime.tv_sec; X us = r[1].ru_utime.tv_usec - r[0].ru_utime.tv_usec; X if (us < 0) { X s--; X us += 1000000; X } X ss = (double)s+(double)us/1000000.0; X printf("%6d encryptions, utime: %8.2f ",count,ss); X if (ss > 0.01) { X printf("%8.3f kbytes/s.",s_to_speed(ss,count)); X } else { X printf("cannot calculate performance"); X cannot = 1; X } X printf("\n"); X if (n == 0) { X mint = maxt = ss; X } else { X if (ss < mint) X mint = ss; X if (ss > maxt) X maxt = ss; X } X total += ss; X n++; X break; X case 3: X if (n > 1 && !cannot) { X printf("Average speed: %8.3f kbytes/s\n",s_to_speed(total/n,count)); X printf("Maximum speed: %8.3f kbytes/s\n",s_to_speed(mint,count)); X printf("Minimum speed: %8.3f kbytes/s\n",s_to_speed(maxt,count)); X } X } X#endif X} END_OF_FILE if test 4460 -ne `wc -c <'prog/des-certify.c'`; then echo shar: \"'prog/des-certify.c'\" unpacked with wrong size! fi # end of 'prog/des-certify.c' fi if test -f 'prog/des.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/des.c'\" else echo shar: Extracting \"'prog/des.c'\" \(3787 characters\) sed "s/^X//" >'prog/des.c' <<'END_OF_FILE' X/* Copyright 1989 Antti Louko. All Rights Reserved. X X/* This program encrypts and decrypts files with des algorithm. It can X be used in three different modes: ecb, cbc or pcbc modes. -p selects X pcbc mode, the default is cbc mode. X X Command syntax is: des [-e] [-d] [-h] [-k key] [-p] [infile [outfile]] X X des encrypts with -e flag and decrypt with -d flag. X X */ X X#include "des.h" X# include <stdio.h> X X#define myfopen fopen X X#define BUFSIZE 8192 X X#define MODE_ECB 1 X#define MODE_CBC 2 X#define MODE_PCBC 3 X Xextern int optind; Xextern char *optarg; X Xint eflag; Xint dflag; Xint hflag; Xint bflag; Xint xflag; Xint Xflag; Xint c_count; Xint cbc = MODE_CBC; Xint do_output; X Xint corr; X Xchar *getpass(); X Xstatic char *Xkey = "A-very-long-checksumkey"; X Xmain(argc,argv,envp) X Xint argc; Xchar **argv; Xchar **envp; X X{ X char *iname,*oname; X FILE *fin,*fout; X int c; X char *key = 0; X Key_schedule Key; X int mode; X C_Block bkey; X int ok; X int n; X int n2; X char buf[BUFSIZE+8]; X int b; X int cnt; X int dmode; X C_Block ivec; X X ivec = des_zero_block; X fin = stdin; X fout = stdout; X while ((c = getopt(argc,argv,"hedpxXk:c:")) != EOF) { X switch (c) { X case 'h': X hflag++; X break; X case 'e': X eflag++; X do_output++; X break; X case 'd': X dflag++; X do_output++; X break; X case 'k': X key = optarg; X break; X case 'c': X c_count = atoi(optarg); X break; X case 'x': X xflag++; X break; X case 'X': X Xflag++; X xflag++; X break; X case 'p': X cbc = MODE_PCBC; X break; X } X } X if (eflag + dflag + xflag!= 1) { X fprintf(stderr,"Only one from -x, -X, -e and -d\n"); X exit(1); X } X if (dflag) X mode = DES_DECRYPT; X else X mode = DES_ENCRYPT; X if (xflag) { X eflag = 1; X cbc = MODE_PCBC; X bflag = 0; X } X argv += optind; X if (*argv) fin = myfopen(*argv++,"r"); X if (!fin) fprintf(stderr,"Cannot open input file\n"); X if (*argv) fout = myfopen(*argv++,"w"); X if (!fout) fprintf(stderr,"Cannot open output file\n"); X if (!key && xflag) X key = Xkey; X if (!key) { X if (!(key = alo_read_password((hflag ? X "Enter hex key: " : X "Enter keyword: ") X ,1))) X exit(1); X } X if (hflag) { X if (des_hex_to_key(key,&bkey) == -1) { X fprintf(stderr,"Invalid hex key\n"); X exit(1); X } X } else { X string_to_key(key,&bkey); X } X des_set_key(&bkey,&Key); X for(ok = 1; ok ;) { X int nread; X if ((n = nread = fread(buf,1,BUFSIZE,fin)) < BUFSIZE) { X ok = 0; X b = n%8; X if (!dflag) { X n2 = ((n+8)&(~7)) - 1; X buf[n2] = b; X while (n < n2) X buf[n++] = 0; X n = n2+1; X } else { X if (b != 0) X corr++; X } X } X if (Xflag) { X if ((n2 = fwrite(buf,1,nread,fout)) < nread) { X fprintf(stderr,"Cannot write %d bytes; wrote %d bytes\n",nread,n2); X } X } X cnt = (n+7)/8; X c = c_count ? c_count : 1; X for(; c > 0; c--) { X switch (cbc) { X case MODE_CBC: X des_cbc_encrypt(buf,buf,cnt*8,&Key,&ivec,mode); X break; X case MODE_PCBC: X des_pcbc_encrypt(buf,buf,cnt*8,&Key,&ivec,mode); X break; X } X } X if (dflag) { X if (ok) { X c = getc(fin); X if (c == EOF) { X ok = 0; X } else { X ungetc(c,fin); X } X } X if (!ok) { X b = buf[n-1]; X if (b > 7 || b < 0) { X corr++; X b = 7; X } else X n -= 8-b; X } X } X if (do_output) { X if ((n2 = fwrite(buf,1,n,fout)) != n) { X fprintf(stderr,"Cannot write %d bytes; wrote %d bytes\n",n,n2); X exit(1); X } X } X } X if (corr) { X fprintf(stderr,"Encrypted file is corrupted\n"); X exit(1); X } X if (xflag) { X print_h(stderr,&ivec); X fprintf(stderr,"\n"); X } X return 0; X} X Xprint_h(f,x) X XFILE *f; XC_Block *x; X X{ X int i; X X for(i = 0; i < 8; i++) X fprintf(f,"%02x",x->data[i]); X} END_OF_FILE if test 3787 -ne `wc -c <'prog/des.c'`; then echo shar: \"'prog/des.c'\" unpacked with wrong size! fi # end of 'prog/des.c' fi if test -f 'prog/testdata' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/testdata'\" else echo shar: Extracting \"'prog/testdata'\" \(612 characters\) sed "s/^X//" >'prog/testdata' <<'END_OF_FILE' X0000000000000000 0000000000000000 8ca64de9c1b123a7 X0101010101010101 0000000000000000 8ca64de9c1b123a7 Xffffffffffffffff ffffffffffffffff 7359b2163e4edc58 Xfefefefefefefefe ffffffffffffffff 7359b2163e4edc58 Xfefefefefefefefe 9823873621837678 173c550deced7865 X1111111111111111 1111111111111111 f40379ab9e0ec533 X2222222222222222 2222222222222222 0f8adffb11dc2784 X6234868327468237 8334675273657623 5b78ee694f5cd9d5 X5fe7273a321ddcdf 1968e7fe541e071f 6ba7427b542ca74e Xaa11a725d984543f 3ad3dd6743e42cd9 514d7e3d7443c5a8 X3d9ab7008771215d c4476015ae6ddb83 c7e46d079e41ec22 Xd69cc9c8a7a632fa 28f99bdab349a0a3 19bb4e040ee87609 END_OF_FILE if test 612 -ne `wc -c <'prog/testdata'`; then echo shar: \"'prog/testdata'\" unpacked with wrong size! fi # end of 'prog/testdata' fi if test -f 'prog/.gdbinit' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/.gdbinit'\" else echo shar: Extracting \"'prog/.gdbinit'\" \(11 characters\) sed "s/^X//" >'prog/.gdbinit' <<'END_OF_FILE' Xdir ../lib END_OF_FILE if test 11 -ne `wc -c <'prog/.gdbinit'`; then echo shar: \"'prog/.gdbinit'\" unpacked with wrong size! fi # end of 'prog/.gdbinit' fi if test -f 'prog/GNUmakefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/GNUmakefile'\" else echo shar: Extracting \"'prog/GNUmakefile'\" \(383 characters\) sed "s/^X//" >'prog/GNUmakefile' <<'END_OF_FILE' XLMAINTOPS:= all clean XPROGS:= des-certify des XSOURCES:= $(addsuffix .c,$(PROGS)) XOBJS:= $(addsuffix .o,$(PROGS)) XLOADLIBES:= ../lib/libdes.a XPRINTFILES:= $(SOURCES) X X.PHONY: all clean test X Xall-local: $(PROGS) $(OBJS) X Xinclude Makerules X XCFLAGS:= $(CFLAGS) -I../lib X Xclean-local: X rm -f $(PROGS) $(OBJS) X X$(PROGS): $(LOADLIBES) X Xtest: X head -1 testdata | ./des-certify -n1024 -t -v END_OF_FILE if test 383 -ne `wc -c <'prog/GNUmakefile'`; then echo shar: \"'prog/GNUmakefile'\" unpacked with wrong size! fi # end of 'prog/GNUmakefile' fi if test -f 'prog/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/Makefile'\" else echo shar: Extracting \"'prog/Makefile'\" \(568 characters\) sed "s/^X//" >'prog/Makefile' <<'END_OF_FILE' X# X# kludged standard make Makefile - derivedfrom GNU makefile ... kre X# XCFLAGS= -DBSD -c -O -I../lib -Dconst= #SUN -msoft-float XPROGS= des-certify des XSOURCES= des-certify.c des.c XOBJS= des-certify.o des.o XLOADLIBES= ../lib/libdes.a XPRINT= enscript XPRINTFILES= $(SOURCES) X Xall: $(PROGS) X Xdes: des.o $(LOADLIBES) X $(CC) -o des des.o $(LOADLIBES) X Xdes-certify: des-certify.o $(LOADLIBES) X $(CC) -o des-certify des-certify.o $(LOADLIBES) X Xclean: X rm -f $(PROGS) $(OBJS) X Xtest: des-certify X sed 1q testdata | ./des-certify -n1024 -t -v X Xprint: X $(PRINT) $(PRINTFILES) END_OF_FILE if test 568 -ne `wc -c <'prog/Makefile'`; then echo shar: \"'prog/Makefile'\" unpacked with wrong size! fi # end of 'prog/Makefile' fi if test -f 'prog/F1.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/F1.uu'\" else echo shar: Extracting \"'prog/F1.uu'\" \(5435 characters\) sed "s/^X//" >'prog/F1.uu' <<'END_OF_FILE' Xbegin 644 F1 XM47M2Z&.$JE[B>4)NIOH<_,1:`7,@!80'12BT\*F'*7#10&!I-ZE2J5MF.J(Y XMI!ZFM52KC[KG\ENM)X.TG`8C4Q\,1BS;,41%FZ`NM!_O8OF[]A;1)HX@;]*? XM]C;"%VULA?%*JEU1S4''W,E=0=@IW=+."Q<4Z]:V=I3MG']&?;K\#21YG=WB XMLU4[8PGJ)>'AL/:Z3F1TKYE9T7)BMVN,Z+5[@]17;0K2W">&[A3A'@J#6(9@ XMQE=U[/"B\2!:LZ.S63^B?EO>.N**RA:JFFUL$AJ!\6D'@='BX/4!X-/=R'+] XMI'"`=?YT@DG:2=J?TY$>:S@+A#=-OXNQVS*9GBHE?&30UJ\]C+C[021,*,PW XM[@&7Q(]TU>V-GZ^;16<"?`%^-K\R?P9/C&]J09Q1)49?<51!15MQ.-9$JI%* XMGUSQ]0);#[MQRM:7G2VQS$@Z_:":-JA$-TY?XCTR5>SP11F*C>1&A6><[#!< XMKF)Z_0E,`G?*YC;"6UE<`%P5?PCUIP6<#,OBN`6I8>RL!S11@->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%: XM-_:AR5H#$!O$3O':5HI"*[^E9GUP#ASP:NAEI`M-))*GN;>/MKCG$P#8*SHV XM":#UO,2A*3WTB#!M];:$'(=W[-@)I.?^Y#EIWX<PT_.U7G.<+?S??*$"T#). XM/:S<A26`O'R2/55<P"5'AGY^AAN6@=A+E<3KNC\^>DTR(F1&'W3J4`<!C2F] XM?/8OKC&]6RDN_<I:7(ES[=?5.0MX7@X(C;V(_ZC`FJ7_V#],S-<=L5.=_<,G XM6.?FS=[KJM5^C,UY1B`Q@L'3B/Q,@/-4'F-R#0K*D/<,\O,UI1K<7*$O>?^3 XM4VG[!%03VD&67HI+/D6O$.P4.D-EAG#6X5S@CP&#VL\#(7+27EZI#[7G(\.: XM76Y6P@R(5?`E![59=9N!V$FN&UG'F2WB]L%[+@KZIP?S2K-Y9_/(`I-'X_AP XMKEO!F5X67G('3Y&7/_#(+E.5_U)X8G$F(UW<"L3_B(!N96+L#YQ!3DA(\>*= XMZ^],*JNP/6/M`GU0W_70H/`U6<^?,J+].2L,O\_J!'&2^GH4K?UZA3J`#M2$ XM`5Z;RH4*,&)A43V^W"45YH>+SNW>*$I5FN'<KA]I_9A1LYS#\K))JD@G.^25 XM)54;O9/2!%&>Z7M%(F_`L*3.&'GQCMEZ5F2G,W,"G,-M)\A!F_FQ17<`ACG, XM6H+D#!G')T."MNAZ;?`O+#A^1:'R8%:3F;=EU7RDE_;:DJ9?R^:APG(^)\#' X-(N4Q%/ZJ3<H;&8DX%_`O X` Xend END_OF_FILE if test 5435 -ne `wc -c <'prog/F1.uu'`; then echo shar: \"'prog/F1.uu'\" unpacked with wrong size! fi # end of 'prog/F1.uu' fi if test -f 'prog/F2.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prog/F2.uu'\" else echo shar: Extracting \"'prog/F2.uu'\" \(5753 characters\) sed "s/^X//" >'prog/F2.uu' <<'END_OF_FILE' Xbegin 644 F2 XMI\_XC8WG-:401R`BLD6G?O`W<;\LG@IR`9/`Z`U<>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W()F#8.?K.YKNS:EZ^\NZ7HT`/(S^'#/?:1H*'GVNB XMLE_,(F)OCHRPWTJ-RMWAP*9&EZMM#,#[W9I\4>F:@([1H?H8]0@G"2\[O`'Y XM<C3!_!MXH4OW=@"T1X)D`^;\]YZUE:>#YI&9T28NR$Z(2GY4",`>V*AO#RX5 XM::F_!+4Y9UI?OE,#B@NHU8M(Y2)U*",LIPO<#EP)G_^\6ZKI'S,6I*KM9WU_ XM<NK)*UH?/0TA5!=8&+:=]L#>V-GP2*I_9BZ16X'`VLH;6Y??HEL0G29&D,'V XM5&MGCK8^;R5U(M,F7=LO5XV8K[ZP+@C>4BO+&HN<O+0W,KBN()U@[H?Y%]^M XMLNL.G5OA#NV[V??KP!Q3$;.8*ALU6#B)E!6GK(3>(JW3MKYG"FT)"DR=96/Y XMOWBE"C*/XI*@$->\T7S2_[)X!K^10\^L8.6)PQ&O/P3YP"'.%.):H0:#PJ/F XM+'I"]A9@1]AGK7+U(!Y>\864WK?W?_61*WTMXLVU*Q*^2*V`(,&R/T6:8)2? X4G+.!M./9(@L7$^=GQ;(O9T92E][W X` Xend END_OF_FILE if test 5753 -ne `wc -c <'prog/F2.uu'`; then echo shar: \"'prog/F2.uu'\" unpacked with wrong size! fi # end of 'prog/F2.uu' fi if test ! -d 'tables' ; then echo shar: Creating directory \"'tables'\" mkdir 'tables' fi if test -f 'tables/IP' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/IP'\" else echo shar: Extracting \"'tables/IP'\" \(392 characters\) sed "s/^X//" >'tables/IP' <<'END_OF_FILE' X 58 50 42 34 26 18 10 2 X 60 52 44 36 28 20 12 4 X 62 54 46 38 30 22 14 6 X 64 56 48 40 32 24 16 8 X 57 49 41 33 25 17 9 1 X 59 51 43 35 27 19 11 3 X 61 53 45 37 29 21 13 5 X 63 55 47 39 31 23 15 7 END_OF_FILE if test 392 -ne `wc -c <'tables/IP'`; then echo shar: \"'tables/IP'\" unpacked with wrong size! fi # end of 'tables/IP' fi if test -f 'tables/IP-1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/IP-1'\" else echo shar: Extracting \"'tables/IP-1'\" \(392 characters\) sed "s/^X//" >'tables/IP-1' <<'END_OF_FILE' X 40 8 48 16 56 24 64 32 X 39 7 47 15 55 23 63 31 X 38 6 46 14 54 22 62 30 X 37 5 45 13 53 21 61 29 X 36 4 44 12 52 20 60 28 X 35 3 43 11 51 19 59 27 X 34 2 42 10 50 18 58 26 X 33 1 41 9 49 17 57 25 END_OF_FILE if test 392 -ne `wc -c <'tables/IP-1'`; then echo shar: \"'tables/IP-1'\" unpacked with wrong size! fi # end of 'tables/IP-1' fi if test -f 'tables/E' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/E'\" else echo shar: Extracting \"'tables/E'\" \(296 characters\) sed "s/^X//" >'tables/E' <<'END_OF_FILE' X 32 1 2 3 4 5 X 4 5 6 7 8 9 X 8 9 10 11 12 13 X 12 13 14 15 16 17 X 16 17 18 19 20 21 X 20 21 22 23 24 25 X 24 25 26 27 28 29 X 28 29 30 31 32 1 END_OF_FILE if test 296 -ne `wc -c <'tables/E'`; then echo shar: \"'tables/E'\" unpacked with wrong size! fi # end of 'tables/E' fi if test -f 'tables/S' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/S'\" else echo shar: Extracting \"'tables/S'\" \(1536 characters\) sed "s/^X//" >'tables/S' <<'END_OF_FILE' X14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7 X 0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8 X 4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0 X15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13 X15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10 X 3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5 X 0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15 X13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9 X10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8 X13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1 X13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7 X 1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12 X 7 13 14 3 0 6 9 10 1 2 8 5 11 12 4 15 X13 8 11 5 6 15 0 3 4 7 2 12 1 10 14 9 X10 6 9 0 12 11 7 13 15 1 3 14 5 2 8 4 X 3 15 0 6 10 1 13 8 9 4 5 11 12 7 2 14 X 2 12 4 1 7 10 11 6 8 5 3 15 13 0 14 9 X14 11 2 12 4 7 13 1 5 0 15 10 3 9 8 6 X 4 2 1 11 10 13 7 8 15 9 12 5 6 3 0 14 X11 8 12 7 1 14 2 13 6 15 0 9 10 4 5 3 X12 1 10 15 9 2 6 8 0 13 3 4 14 7 5 11 X10 15 4 2 7 12 9 5 6 1 13 14 0 11 3 8 X 9 14 15 5 2 8 12 3 7 0 4 10 1 13 11 6 X 4 3 2 12 9 5 15 10 11 14 1 7 6 0 8 13 X 4 11 2 14 15 0 8 13 3 12 9 7 5 10 6 1 X13 0 11 7 4 9 1 10 14 3 5 12 2 15 8 6 X 1 4 11 13 12 3 7 14 10 15 6 8 0 5 9 2 X 6 11 13 8 1 4 10 7 9 5 0 15 14 2 3 12 X13 2 8 4 6 15 11 1 10 9 3 14 5 0 12 7 X 1 15 13 8 10 3 7 4 12 5 6 11 0 14 9 2 X 7 11 4 1 9 12 14 2 0 6 10 13 15 3 5 8 X 2 1 14 7 4 10 8 13 15 12 9 0 3 5 6 11 END_OF_FILE if test 1536 -ne `wc -c <'tables/S'`; then echo shar: \"'tables/S'\" unpacked with wrong size! fi # end of 'tables/S' fi if test -f 'tables/GNUmakefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/GNUmakefile'\" else echo shar: Extracting \"'tables/GNUmakefile'\" \(323 characters\) sed "s/^X//" >'tables/GNUmakefile' <<'END_OF_FILE' XLMAINTOPS= all clean XRPAR=) XLPAR=( XSOURCES= $(wildcard *.make) XHS= $(addprefix ../lib/,$(addsuffix .h,$(basename $(SOURCES)))) XPRINTFILES:= mk-ip $(SOURCES) X Xall-local: $(HS) X.PHONY: all-local X Xinclude Makerules X Xclean-local: X echo "These files can be removed: $(HS)" X echo $(HS) > REMOVABLE X X../lib/%.h: %.make X ./$^ > $@ END_OF_FILE if test 323 -ne `wc -c <'tables/GNUmakefile'`; then echo shar: \"'tables/GNUmakefile'\" unpacked with wrong size! fi # end of 'tables/GNUmakefile' fi if test -f 'tables/REMOVABLE' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/REMOVABLE'\" else echo shar: Extracting \"'tables/REMOVABLE'\" \(58 characters\) sed "s/^X//" >'tables/REMOVABLE' <<'END_OF_FILE' X../lib/spe-table.h ../lib/eight.h ../lib/ip.h ../lib/fp.h END_OF_FILE if test 58 -ne `wc -c <'tables/REMOVABLE'`; then echo shar: \"'tables/REMOVABLE'\" unpacked with wrong size! fi # end of 'tables/REMOVABLE' fi if test -f 'tables/fp.make' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/fp.make'\" else echo shar: Extracting \"'tables/fp.make'\" \(26 characters\) sed "s/^X//" >'tables/fp.make' <<'END_OF_FILE' X#! /bin/sh X./mk-ip < IP-1 END_OF_FILE if test 26 -ne `wc -c <'tables/fp.make'`; then echo shar: \"'tables/fp.make'\" unpacked with wrong size! fi chmod +x 'tables/fp.make' # end of 'tables/fp.make' fi if test -f 'tables/P' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/P'\" else echo shar: Extracting \"'tables/P'\" \(264 characters\) sed "s/^X//" >'tables/P' <<'END_OF_FILE' X 16 7 20 21 X 29 12 28 17 X 1 15 23 26 X 5 18 31 10 X 2 8 24 14 X 32 27 3 9 X 19 13 30 6 X 22 11 4 25 END_OF_FILE if test 264 -ne `wc -c <'tables/P'`; then echo shar: \"'tables/P'\" unpacked with wrong size! fi # end of 'tables/P' fi if test -f 'tables/mk-ip' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/mk-ip'\" else echo shar: Extracting \"'tables/mk-ip'\" \(494 characters\) sed "s/^X//" >'tables/mk-ip' <<'END_OF_FILE' X#!/usr/bin/perl X X# This makes inline-code for initial and final permutations. X X$i = 0; Xwhile (<>) { X @a = split(" ",$_); X while ($x = shift(@a)) { X $T[$i] = $x - 1; X $i++; X } X} X Xfor($i = 0; $i < 64; $i++) { X $ibit = $T[$i]; X $Iname = ($ibit >= 32) ? "R" : "L"; X $Oname = ($i >= 32) ? "R_result" : "L_result"; X printf "if (%s & 0x%08x) %s |= 0x%08x;\n" X ,$Iname,1<<($ibit%32),$Oname,1<<($i%32); X} X X# Local variables: X# mode: c X# tab-width: 8 X# c-indent-level: 4 X# end: END_OF_FILE if test 494 -ne `wc -c <'tables/mk-ip'`; then echo shar: \"'tables/mk-ip'\" unpacked with wrong size! fi chmod +x 'tables/mk-ip' # end of 'tables/mk-ip' fi if test -f 'tables/ip.make' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/ip.make'\" else echo shar: Extracting \"'tables/ip.make'\" \(24 characters\) sed "s/^X//" >'tables/ip.make' <<'END_OF_FILE' X#! /bin/sh X./mk-ip < IP END_OF_FILE if test 24 -ne `wc -c <'tables/ip.make'`; then echo shar: \"'tables/ip.make'\" unpacked with wrong size! fi chmod +x 'tables/ip.make' # end of 'tables/ip.make' fi if test -f 'tables/eight.make' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/eight.make'\" else echo shar: Extracting \"'tables/eight.make'\" \(318 characters\) sed "s/^X//" >'tables/eight.make' <<'END_OF_FILE' X#!/usr/bin/perl X X# This makes a $nb-bit bit-reverse-table X X$nb = 8; X$upper = (1 << $nb); X Xfor($i = 0; $i < $upper; $i++) { X $k = 0; X for($j = 0; $j < $nb; $j++) { X $k |= (($i >> $j) & 01) << ($nb - 1 - $j); X } X printf "%04o,\n",$k; X} X X# Local variables: X# mode: c X# tab-width: 8 X# c-indent-level: 4 X# end: END_OF_FILE if test 318 -ne `wc -c <'tables/eight.make'`; then echo shar: \"'tables/eight.make'\" unpacked with wrong size! fi chmod +x 'tables/eight.make' # end of 'tables/eight.make' fi if test -f 'tables/Makerules' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/Makerules'\" else echo shar: Extracting \"'tables/Makerules'\" \(560 characters\) sed "s/^X//" >'tables/Makerules' <<'END_OF_FILE' XCC:= gcc XCFLAGS:= -O #SUN -msoft-float XPRINT:= enscript X XMAINTOPS:= all clean print s-files X.PHONY: $(MAINTOPS) X Xifdef PRINTFILES Xprint: X $(PRINT) $(PRINTFILES) Xendif X Xifdef LMAINTOPS X$(LMAINTOPS): %: %-local X X.PHONY: $(addsuffix -local,$(LMAINTOPS)) Xendif X Xifneq ($(origin SUBDIRS),file) XSUBDIRS:= Xendif X Xifdef SUBDIRS X$(MAINTOPS): X for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done Xelse X$(MAINTOPS): Xendif X Xifdef SUBDIRS X$(SUBDIRS): X $(MAKE) -C $@ Xendif X Xifneq ($(origin S_FILES),file) XS_FILES:= Xendif X Xs-files: $(S_FILES) X X%.s: %.c X $(CC) -S $(CFLAGS) $^ END_OF_FILE if test 560 -ne `wc -c <'tables/Makerules'`; then echo shar: \"'tables/Makerules'\" unpacked with wrong size! fi # end of 'tables/Makerules' fi if test -f 'tables/spe-table.make' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/spe-table.make'\" else echo shar: Extracting \"'tables/spe-table.make'\" \(1678 characters\) sed "s/^X//" >'tables/spe-table.make' <<'END_OF_FILE' X#!/usr/bin/perl X# This makes combined S-box --> P-permutation --> E-permutation tables X# for each six-bit input data for each S-box. X#$| = 1; Xfor($i = 0; $i < 16; $i++) { X $reverse4[$i] = ((($i & 0x08) >> 3) | X (($i & 0x04) >> 1) | X (($i & 0x02) << 1) | X (($i & 0x01) << 3)); X} X X$j = 0; Xdie "Cannot open S" until open(f,"S"); Xwhile (<f>) { X @a = split(" ",$_); X for($i = 0; $i < 16; $i++) { X $x = shift(@a); X $S[$j] = $x; X $j++; X } X} X X$j = 0; Xdie "Cannot open P" until open(f,"P"); Xwhile (<f>) { X @a = split(" ",$_); X for($i = 0; $i < 4; $i++) { X $x = shift(@a); X $P[$j] = $x; X $j++; X } X} X X$j = 0; Xdie "Cannot open E" until open(f,"E"); Xwhile (<f>) { X @a = split(" ",$_); X for($i = 0; $i < 6; $i++) { X $x = shift(@a); X $E[$j] = $x; X $j++; X } X} X X$L[1024] = 0; Xfor($snum = 0; $snum < 8; $snum++) { X for($i3 = 0; $i3 < 64; $i3++) { X $i2 = ((($i3 & 0x01) << 5) | X (($i3 & 0x02) << 2) | X (($i3 & 0x04) ) | X (($i3 & 0x08) >> 2) | X (($i3 & 0x10) >> 4) | X (($i3 & 0x20) >> 1)); X $i2 = $S[64 * $snum + $i2]; X $i2 = $reverse4[$i2]; X for($i = 0; $i < 48; $i++) { X $i4 = $P[$E[$i]-1]-1; X if (int($i4/4) == $snum && (($i2 >> ($i4 % 4)) & 01)) { X $L[$snum * 128 + int($i / 24)*64 + $i3] |= (1 << ($i % 24)); X $aa = $L[$snum * 128 + int($i / 24)*64 + $i3]; X } X } X } X $i0 = $snum*128; $i1 = $i0+128; X for($i = $i0; $i < $i1; $i++) { X $x = $L[$i]; X $x = ((($x & 000000077) ) | X (($x & 000007700) << 2) | X (($x & 000770000) << 4) | X (($x & 077000000) << 6)); X printf "0x%08x,\n",$x; X } X} X X# Local variables: X# mode: c X# tab-width: 8 X# c-indent-level: 4 X# end: END_OF_FILE if test 1678 -ne `wc -c <'tables/spe-table.make'`; then echo shar: \"'tables/spe-table.make'\" unpacked with wrong size! fi chmod +x 'tables/spe-table.make' # end of 'tables/spe-table.make' fi if test -f 'tables/ksched.dontmake' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/ksched.dontmake'\" else echo shar: Extracting \"'tables/ksched.dontmake'\" \(1056 characters\) sed "s/^X//" >'tables/ksched.dontmake' <<'END_OF_FILE' X#!/usr/bin/perl X$| = 1; X X@PC1 = ( X 57,49,41,33,25,17, 9, X 1,58,50,42,34,26,18, X 10, 2,59,51,43,35,27, X 19,11, 3,60,52,44,36, X 63,55,47,39,31,23,15, X 7,62,54,46,38,30,22, X 14, 6,61,53,45,37,29, X 21,13, 5,28,20,12, 4); X X@PC2 = ( X 14,17,11,24, 1, 5, X 3,28,15, 6,21,10, X 23,19,12, 4,26, 8, X 16, 7,27,20,13, 2, X 41,52,31,37,47,55, X 30,40,51,45,33,48, X 44,49,39,56,34,53, X 46,42,50,36,29,32); X X@LS = (1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1); Xfor($a = 0, $i = 0; $i < 16; $i++) { X $a += $LS[$i]; X $LS[$i] = $a; X} X Xfor($i = 0; $i < 16; $i++) { X printf "A0 = A1 = 0;\n"; X for($j = 0; $j < 48; $j++) { X $m = $PC2[$j] - 1; X $side = int($m / 28); X $col = $m % 28; X $aside = int($j / 24); X $abit = $j % 24; X $abit = int($abit/6)*8 + ($abit%6); X $col = ($col + $LS[$i] + 28) % 28; X $kbit = $PC1[$col + $side*28] - 1; X $side = int($kbit/32); X $col = $kbit%32; X printf "if (I%d & 0x%08x) A%d |= 0x%08x;\n",$side,(1 << $col) X ,$aside,1 << $abit; X } X printf "*kp++ = A0; *kp++ = A1;\n"; X} X X# Local variables: X# mode: c X# tab-width: 8 X# c-indent-level: 4 X# end: END_OF_FILE if test 1056 -ne `wc -c <'tables/ksched.dontmake'`; then echo shar: \"'tables/ksched.dontmake'\" unpacked with wrong size! fi chmod +x 'tables/ksched.dontmake' # end of 'tables/ksched.dontmake' fi if test -f 'tables/shift4.dontmake' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tables/shift4.dontmake'\" else echo shar: Extracting \"'tables/shift4.dontmake'\" \(192 characters\) sed "s/^X//" >'tables/shift4.dontmake' <<'END_OF_FILE' X#!/usr/bin/perl X Xfor($i = 0; $i < 64; $i++) { X $x = ($i >> 1) & 0x0f; X printf "MAC(0x%02x,0x%02x),\n",$x,$x<<4; X} X X# Local variables: X# mode: c X# tab-width: 8 X# c-indent-level: 4 X# end: END_OF_FILE if test 192 -ne `wc -c <'tables/shift4.dontmake'`; then echo shar: \"'tables/shift4.dontmake'\" unpacked with wrong size! fi chmod +x 'tables/shift4.dontmake' # end of 'tables/shift4.dontmake' fi if test ! -d 'lib' ; then echo shar: Creating directory \"'lib'\" mkdir 'lib' fi if test -f 'MANIFEST' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'MANIFEST'\" else echo shar: Extracting \"'MANIFEST'\" \(2098 characters\) sed "s/^X//" >'MANIFEST' <<'END_OF_FILE' X File Name Archive # Description X----------------------------------------------------------- X README 1 X VERSION 1 X COPYRIGHT 1 X GNUmakefile 1 X Makefile 1 X Makerules 1 X sun.ed 1 X man 1 X man/des.1 1 X man/libdes.3 1 X prog 1 X prog/Makerules 1 X prog/des-certify.c 1 X prog/des.c 1 X prog/testdata 1 X prog/.gdbinit 1 X prog/GNUmakefile 1 X prog/Makefile 1 X prog/F1.uu 1 X prog/F2.uu 1 X tables 1 X tables/IP 1 X tables/IP-1 1 X tables/E 1 X tables/S 1 X tables/GNUmakefile 1 X tables/REMOVABLE 1 X tables/fp.make 1 X tables/P 1 X tables/mk-ip 1 X tables/ip.make 1 X tables/eight.make 1 X tables/Makerules 1 X tables/spe-table.make 1 X tables/ksched.dontmake 1 X tables/shift4.dontmake 1 X tables/Makefile 2 X lib 1 X lib/spe-table.h 2 X lib/eight.h 2 X lib/ip.h 2 X lib/ksched.c 2 X lib/des.h 2 X lib/fp.h 2 X lib/des-private.h 2 X lib/des-data.c 2 X lib/Makerules 2 X lib/des-expand.c 2 X lib/des-fun.c 2 X lib/des-perms.c 2 X lib/ecb-encrypt.c 2 X lib/GNUmakefile 2 X lib/cbc-encrypt.c 2 X lib/cbc-cksum.c 2 X lib/des-reverse.c 2 X lib/pcbc-encrypt.c 2 X lib/string-to-key.c 2 X lib/des-hash.c 2 X lib/alo-getpass.c 2 X lib/alo-getline.c 2 X lib/read-passwd.c 2 X lib/des-hex.c 2 X lib/Makefile 2 X MANIFEST 1 This shipping list END_OF_FILE if test 2098 -ne `wc -c <'MANIFEST'`; then echo shar: \"'MANIFEST'\" unpacked with wrong size! fi # end of 'MANIFEST' fi echo shar: End of archive 1 \(of 2\). cp /dev/null ark1isdone MISSING="" for I in 1 2 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked both archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0