[BACK]Return to dh.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/dh.c between version 1.8 and 1.9

version 1.8, 2001/03/05 17:58:22 version 1.9, 2001/03/27 17:46:49
Line 69 
Line 69 
         if (cp == NULL || *strsize == '\0' ||          if (cp == NULL || *strsize == '\0' ||
             (dhg->size = atoi(strsize)) == 0)              (dhg->size = atoi(strsize)) == 0)
                 goto fail;                  goto fail;
           /* The whole group is one bit larger */
           dhg->size++;
         gen = strsep(&cp, " "); /* gen */          gen = strsep(&cp, " "); /* gen */
         if (cp == NULL || *gen == '\0')          if (cp == NULL || *gen == '\0')
                 goto fail;                  goto fail;
Line 95 
Line 97 
 }  }
   
 DH *  DH *
 choose_dh(int minbits)  choose_dh(int min, int wantbits, int max)
 {  {
         FILE *f;          FILE *f;
         char line[1024];          char line[1024];
Line 118 
Line 120 
                 BN_free(dhg.g);                  BN_free(dhg.g);
                 BN_free(dhg.p);                  BN_free(dhg.p);
   
                 if ((dhg.size > minbits && dhg.size < best) ||                  if (dhg.size > max || dhg.size < min)
                     (dhg.size > best && best < minbits)) {                          continue;
   
                   if ((dhg.size > wantbits && dhg.size < best) ||
                       (dhg.size > best && best < wantbits)) {
                         best = dhg.size;                          best = dhg.size;
                         bestcount = 0;                          bestcount = 0;
                 }                  }
Line 129 
Line 134 
         fclose (f);          fclose (f);
   
         if (bestcount == 0) {          if (bestcount == 0) {
                 log("WARNING: no primes in %s, using old prime", _PATH_DH_PRIMES);                  log("WARNING: no suitable primes in %s", _PATH_DH_PRIMES);
                 return (dh_new_group1());                  return (NULL);
         }          }
   
         f = fopen(_PATH_DH_PRIMES, "r");          f = fopen(_PATH_DH_PRIMES, "r");
Line 142 
Line 147 
         which = arc4random() % bestcount;          which = arc4random() % bestcount;
         while (fgets(line, sizeof(line), f)) {          while (fgets(line, sizeof(line), f)) {
                 if (!parse_prime(linenum, line, &dhg))                  if (!parse_prime(linenum, line, &dhg))
                           continue;
                   if (dhg.size > max || dhg.size < min)
                         continue;                          continue;
                 if (dhg.size != best)                  if (dhg.size != best)
                         continue;                          continue;

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9