home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / sci / crypt / 5146 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.0 KB  |  59 lines

  1. Newsgroups: sci.crypt
  2. Path: sparky!uunet!pmafire!news.dell.com!swrinde!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!rcain
  3. From: rcain@netcom.com (Robert Cain)
  4. Subject: Re: URNG
  5. Message-ID: <1992Nov21.161216.25901@netcom.com>
  6. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  7. References: <By1C9x.3K1@chinet.chi.il.us>
  8. Date: Sat, 21 Nov 1992 16:12:16 GMT
  9. Lines: 48
  10.  
  11. What follows is the core of the IDEA cipher system.  Starting with a
  12. random key and a random dataIn and then feeding back the dataOut
  13. successively as dataIn, a pretty strong URNG should result.  It generates
  14. 16 bytes at a time.  I don't think much is known about its statistical
  15. properties but it is known to be a strong cipher.
  16.  
  17.  
  18. /******************************************************************************/
  19. /* encryption and decryption algorithm IDEA                                   */
  20.  
  21. void  Idea(dataIn, dataOut, key)
  22.  
  23. u_int16 *dataIn, *dataOut, *key;
  24. {
  25.     register u_int32 round, x0, x1, x2, x3, t0, t1, t2;
  26.  
  27.   x0 = (u_int32)*(dataIn++);
  28.     x1 = (u_int32)*(dataIn++);
  29.   x2 = (u_int32)*(dataIn++);
  30.     x3 = (u_int32)*(dataIn);
  31.   for (round = nofRound; round > 0; round--)
  32.     {
  33.     x0 = Mul(x0, (u_int32)*(key++));
  34.     x1 = (x1 + (u_int32)*(key++)) & ones;
  35.     x2 = (x2 + (u_int32)*(key++)) & ones;
  36.     x3 = Mul(x3, (u_int32)*(key++));
  37.     t0 = Mul((u_int32)*(key++), x0 ^ x2);      
  38.     t1 = Mul((u_int32)*(key++), (t0 + (x1 ^ x3)) & ones);
  39.     t0 = (t0 + t1) & ones;
  40.     x0 ^= t1;
  41.         x3 ^= t0;
  42.     t0 ^= x1;
  43.         x1 = x2 ^ t1;
  44.         x2 = t0;
  45.   }
  46.   *(dataOut++) = (u_int16)(Mul(x0, (u_int32)*(key++)));
  47.   *(dataOut++) = (u_int16)((x2 + (u_int32)*(key++)) & ones);
  48.   *(dataOut++) = (u_int16)((x1 + (u_int32)*(key++)) & ones);
  49.   *(dataOut) = (u_int16)(Mul(x3, (u_int32)*key));
  50. } /* Idea */
  51. -- 
  52. Bob Cain    rcain@netcom.com   408-358-2007
  53.  
  54. "There are some strings.  They're just not attached."
  55.                                                     Victoria Roberts
  56.  
  57.  
  58.                PGP 1.0 or 2.0 public key available on request.
  59.