~ubuntu-branches/ubuntu/saucy/gnutls26/saucy-updates

« back to all changes in this revision

Viewing changes to lib/gnutls_dh.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-12-06 18:29:32 UTC
  • mfrom: (12.1.33 sid)
  • Revision ID: package-import@ubuntu.com-20121206182932-iih7i83juh8cdotf
Tags: 2.12.20-2ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Build gnutls-bin from this source package rather than from gnutls28:
    gnutls28's licensing is currently too strict for many of the free
    software packages built against it in Ubuntu main and we only want to
    support a single version.  Bump its version to achieve this.
* Avoid assuming that gets is declared.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
bigint_t
95
95
gnutls_calc_dh_key (bigint_t f, bigint_t x, bigint_t prime)
96
96
{
97
 
  bigint_t k;
 
97
  bigint_t k, ff, ret;
98
98
  int bits;
 
99
  
 
100
  ff = _gnutls_mpi_mod(f, prime);
 
101
  _gnutls_mpi_add_ui(ff, ff, 1);
 
102
 
 
103
  /* check if f==0,1,p-1. 
 
104
   * or (ff=f+1) equivalently ff==1,2,p */
 
105
  if ((_gnutls_mpi_cmp_ui(ff, 2) == 0) || (_gnutls_mpi_cmp_ui(ff, 1) == 0) ||
 
106
      (_gnutls_mpi_cmp(ff,prime) == 0))
 
107
    {
 
108
      gnutls_assert();
 
109
      ret = NULL;
 
110
      goto cleanup;
 
111
    }
99
112
 
100
113
  bits = _gnutls_mpi_get_nbits (prime);
101
114
  if (bits <= 0 || bits > MAX_BITS)
102
115
    {
103
116
      gnutls_assert ();
104
 
      return NULL;
 
117
      ret = NULL;
 
118
      goto cleanup;
105
119
    }
106
120
 
107
121
  k = _gnutls_mpi_alloc_like (prime);
108
122
  if (k == NULL)
109
 
    return NULL;
 
123
    {
 
124
      gnutls_assert();
 
125
      ret = NULL;
 
126
      goto cleanup;
 
127
    }
 
128
 
110
129
  _gnutls_mpi_powm (k, f, x, prime);
111
 
  return k;
 
130
 
 
131
  ret = k;
 
132
 
 
133
cleanup:
 
134
  _gnutls_mpi_release (&ff);
 
135
  
 
136
  return ret;
112
137
}
113
138
 
114
139
/*-