dewo1@ihuxn.UUCP (dew) (01/10/84)
Has anyone ever tried to decrypt a message using the setkey/encrypt functions supplied in UNIX? I am running on a 3B20S, under USG 5.0 UNIX. I need to take a message, encrypt it, and then decrypt it. Thinking that I might as well use the best - after all, these are the functions that are used to encrypt passwords - I tried using these two functions. No luck. I could not get the text decrypted. I checked out how passwd(1) works, to see if it decrypted, but it does not - just compares two encrypted strings. Has anyone got any ideas? I will use other functions if they are available. Doug Whitten ihuxn!dewo1
mayer@rochester.UUCP (Jim Mayer) (01/10/84)
There is a bug in the encrypt/setkey stuff under 4.1c. The problem is that the "E table" is initialized only in the crypt routine. If encrypt/setkey are used independently of crypt the "E table" is left undefined. You can use the routines if you call "crypt" first, but the encryption will be done with a non standard table. To fix the problem, move the initialization "for" loop into "setkey". You will also have to move the declaration of the "e" and "E" arrays up above the "setkey" definition (otherwise they are undefined). The following stuff is a "diff" between the old and new versions. -- Jim Mayer (rochester!mayer) 23a24,38 > * The E bit-selection table. > */ > static char E[48]; > static char e[] = { > 32, 1, 2, 3, 4, 5, ... > 28,29,30,31,32, 1, > }; > > /* 104a120,125 > * Remember to initialize the E table first! > */ > for(i=0;i<48;i++) > E[i] = e[i]; > > /* 144,158d164 < * The E bit-selection table. < */ < static char E[48]; < static char e[] = { < 32, 1, 2, 3, 4, 5, ... < 28,29,30,31,32, 1, < }; < < /* 344,346d349 < < for(i=0;i<48;i++) < E[i] = e[i];