Xref: utzoo comp.binaries.ibm.pc.d:7848 sci.crypt:2910 comp.lang.c:28586 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!munnari.oz.au!bruce!alanf From: alanf@bruce.OZ (Alan Grant Finlay) Newsgroups: comp.binaries.ibm.pc.d,aus.computers.ibm-pc,sci.crypt,comp.lang.c Subject: Tangle 3.0 (replaces Crytp 2.0) encryption distribution notice Message-ID: <2146@bruce.OZ> Date: 9 May 90 12:28:13 GMT Organization: Monash Uni. Computer Science, Australia Lines: 321 In accordance with advice from various sources I have changed the name for the next version of my encryption utility from "crypt" to "tangle". This will hopefully not cause too much confusion with Knuth's tangle program. Tangle 3.0 is an improved version of Crypt 2.0, and uses a different algorithm which is not compatible with the old one. Version 2 files are not supported contrary to previous indications. This decision was taken to avoid an overly complex source for this new version. The source is tagged on the end of this message. Executables and documentation are being distributed via "comp.binaries.ibm.pc". The program will run on an IBM-PC compatible under MS-DOS or similar. The specific improvements for version 3 are: 1) The password is erased from memory before exit. (N.B. I use the term password rather than key to emphasise that it is intended to be a character string.) 2) A password checksum is displayed to reduce the risk of undetected miskeying. 3) The algorithm implements the countermeasure to a chosen plaintext attack I discovered and discussed in news group "sci.crypt". 4) The 8 bit planes are now no longer independent. I said that the next version would implement a "pipe" command to avoid the need to keep typing in a password etc. I have changed my mind since the security risk to those not familiar with MS-DOS etc were to great. In particular the fact that MS-DOS "pipes" are really temporary files in disguise. I have been told that the previous algorithm was no faster than software DES implementations however there are still some redeeming properties. Firstly the key space is huge in comparison, brute force attack is significantly harder than for DES when for example a 15 character password is used. Secondly this is an alternative to DES, who knows what progress has been made in cracking DES? Thirdly this algorithm is easy to implement in parallel with a speedup proportional to the block size (an advantage in the not too distant future). Fourth this algorithm is much easier to understand than DES and the source is distributed so the user can check it, compile it himself, and not worry about substitution of executables. For those that can read such things the algorithm is as follows: For each block, let us call it page[x,y] where 0<=x #include #include #include #define ENCRYPT 1 /* Choose tangle (1) or untangle (0) */ #define DEBUG 0 /* Show page after each shuffle if non zero */ #define TRUE -1 #define FALSE 0 #define LIMIT 100 /* Maximum block size is LIMIT*LIMIT */ #define SECURE 10 /* The number of block transformations */ #define MINB 450 /* Minimum block size - insecure if too small */ typedef unsigned char line[LIMIT]; char copyright[40] = "(c) copyright 1989,1990, Alan Finlay"; unpat(page,wide,high) /* Simple substitution to eliminate simple patterns */ line page[LIMIT]; /* [width,height] */ int wide,high; { int i,j,k; k = 0; for (i=0;iLIMIT) wide = LIMIT; high = blocksize/wide+1; if (high>LIMIT) high = LIMIT; while (1) { blocksize = wide*high; if (fsize<(long) blocksize) break; else { /* Multiple blocks, check for last block too small */ if (((fsize-1)%blocksize)>(blocksize*3/4)) break; /* (fsize-1) is used above so perfect fit is accepted! */ high--; wide--; /* Try a smaller block */ } if (wide<50) break; } printf("The width and height are (%d,%d)\n",wide,high); printf("The last block is %ld bytes\n",((fsize-1)%blocksize)+1); fprintf(outfile,"%d,%d,%d,",vers,wide,high); #else fscanf(infile,"%d,%d,%d,",&invers,&wide,&high); if (invers!=vers) { printf("This is version %d of the encryption program.\n",vers); printf("The input file is for program version %d or invalid.\n",invers); exit(1); } #endif /* Get password */ while(1) { puts("\nPlease enter your password"); fgets(code,LIMIT,stdin); clen = strlen(code); if (clen>9) break; puts("Insecure password, try a longer one."); puts("For security do not use a name or word in any dictionary."); puts("For example use something like \"Dazed and Konfuzed\""); } for (i=0;i<25;i++) puts(" "); /* Clear the screen */ if (clen>wide) puts("Warning: tail of password ignored"); /* Extend password to possible limit, not null terminated */ for (i=clen;i