/[lwip]/lwip/src/netif/ppp/randm.c
ViewVC logotype

Diff of /lwip/src/netif/ppp/randm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by jani, Tue May 27 14:37:56 2003 UTC revision 1.2 by jani, Fri May 30 08:49:34 2003 UTC
# Line 78  void avChurnRand(char *randData, u32_t r Line 78  void avChurnRand(char *randData, u32_t r
78  {  {
79      MD5_CTX md5;      MD5_CTX md5;
80    
81  //  ppp_trace(LOG_INFO, "churnRand: %u@%P\n", randLen, randData);  /*  ppp_trace(LOG_INFO, "churnRand: %u@%P\n", randLen, randData); */
82      MD5Init(&md5);      MD5Init(&md5);
83      MD5Update(&md5, (u_char *)randPool, sizeof(randPool));      MD5Update(&md5, (u_char *)randPool, sizeof(randPool));
84      if (randData)      if (randData)
85          MD5Update(&md5, (u_char *)randData, randLen);          MD5Update(&md5, (u_char *)randData, randLen);
86      else {      else {
87          struct {          struct {
88              // INCLUDE fields for any system sources of randomness              /* INCLUDE fields for any system sources of randomness */
89              char foobar;              char foobar;
90          } sysData;          } sysData;
91    
92          // Load sysData fields here.          /* Load sysData fields here. */
93          ;          ;
94          MD5Update(&md5, (u_char *)&sysData, sizeof(sysData));          MD5Update(&md5, (u_char *)&sysData, sizeof(sysData));
95      }      }
96      MD5Final((u_char *)randPool, &md5);      MD5Final((u_char *)randPool, &md5);
97  //  ppp_trace(LOG_INFO, "churnRand: -> 0\n");  /*  ppp_trace(LOG_INFO, "churnRand: -> 0\n"); */
98  }  }
99    
100  /*  /*
# Line 150  u32_t avRandom() Line 150  u32_t avRandom()
150  /*****************************/  /*****************************/
151  /*** LOCAL DATA STRUCTURES ***/  /*** LOCAL DATA STRUCTURES ***/
152  /*****************************/  /*****************************/
153  static int  avRandomized = 0;       // Set when truely randomized.  static int  avRandomized = 0;       /* Set when truely randomized. */
154  static u32_t avRandomSeed = 0;      // Seed used for random number generation.  static u32_t avRandomSeed = 0;      /* Seed used for random number generation. */
155    
156    
157  /***********************************/  /***********************************/
# Line 173  static u32_t avRandomSeed = 0;      // S Line 173  static u32_t avRandomSeed = 0;      // S
173   */   */
174  void avRandomInit()  void avRandomInit()
175  {  {
176    #if 0
177      /* Get a pointer into the last 4 bytes of clockBuf. */      /* Get a pointer into the last 4 bytes of clockBuf. */
178      u32_t *lptr1 = (u32_t *)((char *)&clockBuf[3]);      u32_t *lptr1 = (u32_t *)((char *)&clockBuf[3]);
179    
 #if 0  
180      /*      /*
181       * Initialize our seed using the real-time clock, the idle       * Initialize our seed using the real-time clock, the idle
182       * counter, the millisecond timer, and the hardware timer       * counter, the millisecond timer, and the hardware timer
# Line 188  void avRandomInit() Line 188  void avRandomInit()
188       * randomize the lower 16 bits of the seed.       * randomize the lower 16 bits of the seed.
189       */       */
190      readClk();      readClk();
191  //    avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr      avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr
192  //             + ppp_mtime() + ((u32_t)TM1 << 16) + TM1;               + ppp_mtime() + ((u32_t)TM1 << 16) + TM1;
193  #else  #else
194      avRandomSeed += ppp_jiffies(); /* XXX */      avRandomSeed += ppp_jiffies(); /* XXX */
195  #endif  #endif
# Line 214  void avRandomize(void) Line 214  void avRandomize(void)
214          avRandomInit();          avRandomInit();
215          /* The initialization function also updates the seed. */          /* The initialization function also updates the seed. */
216      } else {      } else {
217  //        avRandomSeed += (avRandomSeed << 16) + TM1;  /*        avRandomSeed += (avRandomSeed << 16) + TM1; */
218          avRandomSeed += (ppp_jiffies() - last_jiffies); /* XXX */          avRandomSeed += (ppp_jiffies() - last_jiffies); /* XXX */
219      }      }
220      last_jiffies = ppp_jiffies();      last_jiffies = ppp_jiffies();

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26