~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to cipher/rsa.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-11-03 09:18:26 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20061103091826-89kwl8tk1xypbmtk
Tags: upstream-1.4.5
ImportĀ upstreamĀ versionĀ 1.4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
    mpi_gcd(g, t1, t2);
137
137
    mpi_fdiv_q(f, phi, g);
138
138
 
139
 
    /* find an public exponent.
140
 
       We use 41 as this is quite fast and more secure than the
141
 
       commonly used 17.  Benchmarking the RSA verify function
142
 
       with a 1024 bit key yields (2001-11-08): 
 
139
    /* Find an public exponent.
 
140
       Benchmarking the RSA verify function with a 1024 bit key yields
 
141
       (2001-11-08):
143
142
         e=17    0.54 ms
144
143
         e=41    0.75 ms
145
144
         e=257   0.95 ms
146
145
         e=65537 1.80 ms
 
146
 
 
147
       This code used 41 until 2006-06-28 when it was changed to use
 
148
       65537 as the new best practice.  See FIPS-186-3.
147
149
     */
148
150
    e = mpi_alloc( (32+BITS_PER_MPI_LIMB-1)/BITS_PER_MPI_LIMB );
149
 
    mpi_set_ui( e, 41); 
150
 
    if( !mpi_gcd(t1, e, phi) ) {
151
 
      mpi_set_ui( e, 257); 
152
 
      if( !mpi_gcd(t1, e, phi) ) {
153
 
        mpi_set_ui( e, 65537); 
154
 
        while( !mpi_gcd(t1, e, phi) ) /* (while gcd is not 1) */
155
 
          mpi_add_ui( e, e, 2);
156
 
      }
157
 
    }
 
151
    mpi_set_ui( e, 65537); 
 
152
    while( !mpi_gcd(t1, e, phi) ) /* (while gcd is not 1) */
 
153
      mpi_add_ui( e, e, 2);
158
154
 
159
155
    /* calculate the secret key d = e^1 mod phi */
160
156
    d = mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1)/BITS_PER_MPI_LIMB );