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

  1. Newsgroups: sci.crypt
  2. Path: sparky!uunet!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.162754.26769@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:27:54 GMT
  9. Lines: 47
  10.  
  11. I should have attributed that IDEA code fragment to Richard De Moliner
  12. of the Swiss Federal Institute of Technology.  Now that I think about
  13. it it probably would be fine to seed the dataIn with all zeros and
  14. begin the URNG stream with the first output.  Only the key then would
  15. need be known by two people to generate the same stream. 
  16.  
  17. I forgot the Mul() function and some constants.  They are included below.
  18.  
  19. Bob
  20.  
  21. #define mulMod        0x10001 /* 2**16 + 1                                    */
  22. #define addMod        0x10000 /* 2**16                                        */
  23. #define ones           0xFFFF /* 2**16 - 1                                    */
  24.  
  25. #define nofKeyPerRound      6 /* number of used keys per round                */
  26. #define nofRound            8 /* number of rounds                             */
  27.  
  28. /* multiplication                                                             */
  29.  
  30. u_int32 Mul(a, b)
  31.  
  32. u_int32 a, b;
  33. {
  34.     int32 p;
  35.   u_int32 q;
  36.   
  37.   if (a == 0)
  38.         p = mulMod - b; 
  39.   else if (b == 0)
  40.         p = mulMod - a;
  41.   else
  42.     {
  43.         q = a * b;
  44.         p = (q & ones) - (q >> 16);
  45.         if (p <= 0)
  46.             p += mulMod;
  47.     }
  48.   return (u_int32)(p & ones);
  49. } /* Mul */
  50. -- 
  51. Bob Cain    rcain@netcom.com   408-358-2007
  52.  
  53. "There are some strings.  They're just not attached."
  54.                                                     Victoria Roberts
  55.  
  56.  
  57.                PGP 1.0 or 2.0 public key available on request.
  58.