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

Diff for /src/usr.bin/ssh/moduli.c between version 1.9 and 1.9.2.2

version 1.9, 2004/07/11 17:48:47 version 1.9.2.2, 2005/09/02 03:45:00
Line 56 
Line 56 
 #define QTYPE_UNKNOWN           (0)  #define QTYPE_UNKNOWN           (0)
 #define QTYPE_UNSTRUCTURED      (1)  #define QTYPE_UNSTRUCTURED      (1)
 #define QTYPE_SAFE              (2)  #define QTYPE_SAFE              (2)
 #define QTYPE_SCHNOOR           (3)  #define QTYPE_SCHNORR           (3)
 #define QTYPE_SOPHIE_GERMAIN    (4)  #define QTYPE_SOPHIE_GERMAIN    (4)
 #define QTYPE_STRONG            (5)  #define QTYPE_STRONG            (5)
   
Line 112 
Line 112 
 #define TINY_NUMBER     (1UL<<16)  #define TINY_NUMBER     (1UL<<16)
   
 /* Ensure enough bit space for testing 2*q. */  /* Ensure enough bit space for testing 2*q. */
 #define TEST_MAXIMUM    (1UL<<16)  #define TEST_MAXIMUM    (1UL<<16)
 #define TEST_MINIMUM    (QSIZE_MINIMUM + 1)  #define TEST_MINIMUM    (QSIZE_MINIMUM + 1)
 /* real TEST_MINIMUM    (1UL << (SHIFT_WORD - TEST_POWER)) */  /* real TEST_MINIMUM    (1UL << (SHIFT_WORD - TEST_POWER)) */
 #define TEST_POWER      (3)     /* 2**n, n < SHIFT_WORD */  #define TEST_POWER      (3)     /* 2**n, n < SHIFT_WORD */
   
 /* bit operations on 32-bit words */  /* bit operations on 32-bit words */
 #define BIT_CLEAR(a,n)  ((a)[(n)>>SHIFT_WORD] &= ~(1L << ((n) & 31)))  #define BIT_CLEAR(a,n)  ((a)[(n)>>SHIFT_WORD] &= ~(1L << ((n) & 31)))
 #define BIT_SET(a,n)    ((a)[(n)>>SHIFT_WORD] |= (1L << ((n) & 31)))  #define BIT_SET(a,n)    ((a)[(n)>>SHIFT_WORD] |= (1L << ((n) & 31)))
 #define BIT_TEST(a,n)   ((a)[(n)>>SHIFT_WORD] & (1L << ((n) & 31)))  #define BIT_TEST(a,n)   ((a)[(n)>>SHIFT_WORD] & (1L << ((n) & 31)))
   
 /*  /*
  * Prime testing defines   * Prime testing defines
  */   */
   
 /* Minimum number of primality tests to perform */  /* Minimum number of primality tests to perform */
 #define TRIAL_MINIMUM           (4)  #define TRIAL_MINIMUM   (4)
   
 /*  /*
  * Sieving data (XXX - move to struct)   * Sieving data (XXX - move to struct)
Line 144 
Line 144 
 static u_int32_t largebits, largememory;        /* megabytes */  static u_int32_t largebits, largememory;        /* megabytes */
 static BIGNUM *largebase;  static BIGNUM *largebase;
   
 int gen_candidates(FILE *, int, int, BIGNUM *);  int gen_candidates(FILE *, u_int32_t, u_int32_t, BIGNUM *);
 int prime_test(FILE *, FILE *, u_int32_t, u_int32_t);  int prime_test(FILE *, FILE *, u_int32_t, u_int32_t);
   
 /*  /*
Line 241 
Line 241 
  * The list is checked against small known primes (less than 2**30).   * The list is checked against small known primes (less than 2**30).
  */   */
 int  int
 gen_candidates(FILE *out, int memory, int power, BIGNUM *start)  gen_candidates(FILE *out, u_int32_t memory, u_int32_t power, BIGNUM *start)
 {  {
         BIGNUM *q;          BIGNUM *q;
         u_int32_t j, r, s, t;          u_int32_t j, r, s, t;
         u_int32_t smallwords = TINY_NUMBER >> 6;          u_int32_t smallwords = TINY_NUMBER >> 6;
         u_int32_t tinywords = TINY_NUMBER >> 6;          u_int32_t tinywords = TINY_NUMBER >> 6;
         time_t time_start, time_stop;          time_t time_start, time_stop;
         int i, ret = 0;          u_int32_t i;
           int ret = 0;
   
         largememory = memory;          largememory = memory;
   
         if (memory != 0 &&          if (memory != 0 &&
            (memory < LARGE_MINIMUM || memory > LARGE_MAXIMUM)) {              (memory < LARGE_MINIMUM || memory > LARGE_MAXIMUM)) {
                 error("Invalid memory amount (min %ld, max %ld)",                  error("Invalid memory amount (min %ld, max %ld)",
                     LARGE_MINIMUM, LARGE_MAXIMUM);                      LARGE_MINIMUM, LARGE_MAXIMUM);
                 return (-1);                  return (-1);
Line 371 
Line 372 
          * fencepost errors, the last pass is skipped.           * fencepost errors, the last pass is skipped.
          */           */
         for (smallbase = TINY_NUMBER + 3;          for (smallbase = TINY_NUMBER + 3;
              smallbase < (SMALL_MAXIMUM - TINY_NUMBER);              smallbase < (SMALL_MAXIMUM - TINY_NUMBER);
              smallbase += TINY_NUMBER) {              smallbase += TINY_NUMBER) {
                 for (i = 0; i < tinybits; i++) {                  for (i = 0; i < tinybits; i++) {
                         if (BIT_TEST(TinySieve, i))                          if (BIT_TEST(TinySieve, i))
                                 continue; /* 2*i+3 is composite */                                  continue; /* 2*i+3 is composite */
Line 530 
Line 531 
                         break;                          break;
                 case QTYPE_UNSTRUCTURED:                  case QTYPE_UNSTRUCTURED:
                 case QTYPE_SAFE:                  case QTYPE_SAFE:
                 case QTYPE_SCHNOOR:                  case QTYPE_SCHNORR:
                 case QTYPE_STRONG:                  case QTYPE_STRONG:
                 case QTYPE_UNKNOWN:                  case QTYPE_UNKNOWN:
                         debug2("%10u: (%u)", count_in, in_type);                          debug2("%10u: (%u)", count_in, in_type);
Line 548 
Line 549 
                  * due to earlier inconsistencies in interpretation, check                   * due to earlier inconsistencies in interpretation, check
                  * the proposed bit size.                   * the proposed bit size.
                  */                   */
                 if (BN_num_bits(p) != (in_size + 1)) {                  if ((u_int32_t)BN_num_bits(p) != (in_size + 1)) {
                         debug2("%10u: bit size %u mismatch", count_in, in_size);                          debug2("%10u: bit size %u mismatch", count_in, in_size);
                         continue;                          continue;
                 }                  }

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