jboede@auscso.UUCP (Jon Boede) (03/18/88)
I posted a question on this a while back and it was summarily ignored, perhaps because it's such an easy question... anyhow, I'm still trying to get it to work. What I'm looking for is a function that will encrypt or decrypt a string passed to it using the DES functions in the standard library. I have a v7 manual that documents this and it seems fairly simple yet I continue to have no luck. Assuming that I could attack a while string in 8 character (64 bit) chunks, I've written the following which fails nicely because I immediately encrypt then decrypt the bit array (block of chars) and I don't get back what I put in! Thanks, Jon main() { char blk2[64], text[32], block[64], key[9]; register bit, loop; strcpy(key,"xyzzy678"); /* load and set the key block */ for (loop=0; loop < 8; loop++) { for (bit=0; bit < 8; bit++) block[loop*8+bit] = ((int)key[loop] & (1<<bit)) ? '\1' : '\0'; } setkey(block); strcpy(text,"thisisometext"); /* going to do just first 8 chars */ for (loop=0; loop < 8; loop++) for (bit=0; bit < 8; bit++) block[loop*8+bit] = ((int)*(text+loop) & (1<<bit)) ? '\1' : '\0'; for (loop=0; loop < 64; loop++) blk2[loop] = block[loop]; encrypt(block,0); /* encrypt it */ encrypt(block,1); /* decrypt it */ for (loop=0; loop < 64; loop++) if (blk2[loop] != block[loop]) { puts("different"); exit(0); } puts("same"); exit(0); } -- Jon Boede jboede@auscso.UUCP, jon%bodedo@im4u.cs.utexas.edu 1301 Trace Dr. #204, Austin, TX 78741-1735 (512) 462-3287 "People who are incapable of making decisions are the ones that hit those barrels at freeway exits."
jboede@auscso.UUCP (Jon Boede) (03/25/88)
In article <2830@cheviot.newcastle.ac.uk> amh@mari (Andrew Hilborne) writes: > I have also written (an even shorter) program which appears to show that > the setkey(3)/encrypt(3) library routines are broken, this time on > BSD4.2. I don't have it here, but the basics are that the program > fragment: > > setkey(key); > encrypt(block, 0); > encrypt(block, 1); > > Should be a no-op on "block", but is not. [ The orignal posting said that it looked broken under SysV and SCO XENIX ] I was contacted after my posting to this newsgroup by someone who works at SCO (great company, BTW, second time someone from there has called to help and both times they've been great help, but anyway...) he said that 1) the code I posted *should* have worked and 2) he looked at the source for encrypt(3) and it is, in fact, broken. In his opinion, encrypt(3) has been broken for at least 6 years. The plot thickens. My 7th edition manual talks about DES-this and DES-that in crypt(3). It describes encrypt(3) such: encrypt(block,ed_flag); unsigned char *block; int ed_flag; If ed_flag was 0 it encrypted, else decrypted. BUT! When I actually went to the SysV manuals, crypt(3) no longer mentioned DES, calling it the "hashing function". The reeeealy interesting part is that encrypt is now... void encrypt(block,ignored); unsigned char *block; It said that the second variable is ignored but must be given. This, of course, makes encrypt(3) a one way function. Did AT&T break crypt on purpose? To satisfy export regulations? Surely they didn't know it was broken and then didn't feel like fixing it! Seems a little fishy to me... enquiring minds wanna know! Jon -- Jon Boede jboede@auscso.UUCP, jon%bodedo@im4u.cs.utexas.edu 1301 Trace Dr. #204, Austin, TX 78741-1735 (512) 462-3287 "People who are incapable of making decisions are the ones that hit those barrels at freeway exits."
bumby@math.rutgers.edu (Richard Bumby) (10/12/89)
Since this thread seems to be changing direction, it might be appropriate to add that when I bought an "international adapter" so that I could take my Toshiba laptop overseas, it came in a box labeled "EXPORT RESTRICTED"! Even hardware appears to be subject to security clearance. -- --R. T. Bumby ** Math ** Rutgers ** New Brunswick ** (in one form or another for all kinds of mail) [bumby@math.rutgers.edu]
dg@lakart.UUCP (David Goodenough) (10/17/89)
bumby@math.rutgers.edu (Richard Bumby) sez: > Since this thread seems to be changing direction, it might be > appropriate to add that when I bought an "international adapter" so > that I could take my Toshiba laptop overseas, it came in a box labeled > "EXPORT RESTRICTED"! Even hardware appears to be subject to security > clearance. You betcha!! A fellow worker took his Mac 2 CX, PHD, SSC, whatever (the 68020 version) on holiday with him to Italy last year. Had to sign all sorts of declarations to make sure he brought it back. The fact that I could take my trusty old CP/M machine to Italy with a 68020 chip stuck inside it with gaffers tape is probably totally irrelevant. Customs / Immigration / Export / whoever are trying to do something, and are mostly succeeding. But it's still fairly easy to slide a fast one past them. Assuming you're prepared to take the risk. -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+
Wade.Hought@p0.f18.n114.z1.fidonet.org (Wade Hought) (03/26/90)
I don't know if thisis the correct echo for this question, but here goes. Does anyone know how to use the encrypt() function in UNIX? I can get the crypt() to work, but not the other. -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!18.0!Wade.Hought Internet: Wade.Hought@p0.f18.n114.z1.fidonet.org