~nutznboltz-deactivatedaccount/ubuntu/precise/gnutls26/fix-lp926350

« back to all changes in this revision

Viewing changes to lib/gnutls_v2_compat.c

  • Committer: Package Import Robot
  • Author(s): Andreas Metzler
  • Date: 2011-10-01 15:28:13 UTC
  • mfrom: (12.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20111001152813-yygm1c4cxonfxhzy
Tags: 2.12.11-1
* New upstream version.
  + Allow CA importing of 0 certificates to succeed. Closes: #640639
* Add libp11-kit-dev to libgnutls-dev dependencies. (see #643811)
* [20_guiledocstring.diff] guile: Fix docstring extraction with CPP 4.5+.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "gnutls_extensions.h"
43
43
#include "gnutls_auth.h"
44
44
#include "gnutls_v2_compat.h"
 
45
#include "gnutls_constate.h"
45
46
 
46
47
/* This selects the best supported ciphersuite from the ones provided */
47
48
static int
48
49
_gnutls_handshake_select_v2_suite (gnutls_session_t session,
49
 
                                   opaque * data, int datalen)
 
50
                                   opaque * data, int datalen)
50
51
{
51
52
  int i, j, ret;
52
53
  opaque *_data;
53
54
  int _datalen;
54
55
 
55
56
  _gnutls_handshake_log ("HSK[%p]: Parsing a version 2.0 client hello.\n",
56
 
                         session);
 
57
                         session);
57
58
 
58
59
  _data = gnutls_malloc (datalen);
59
60
  if (_data == NULL)
72
73
  for (j = 0; j < datalen; j += 3)
73
74
    {
74
75
      if (data[j] == 0)
75
 
        {
76
 
          memcpy (&_data[i], &data[j + 1], 2);
77
 
          i += 2;
78
 
          _datalen += 2;
79
 
        }
 
76
        {
 
77
          memcpy (&_data[i], &data[j + 1], 2);
 
78
          i += 2;
 
79
          _datalen += 2;
 
80
        }
80
81
    }
81
82
 
82
83
  ret = _gnutls_server_select_suite (session, _data, _datalen);
92
93
 */
93
94
int
94
95
_gnutls_read_client_hello_v2 (gnutls_session_t session, opaque * data,
95
 
                              int datalen)
 
96
                              int datalen)
96
97
{
97
98
  uint16_t session_id_len = 0;
98
99
  int pos = 0;
180
181
  if (_gnutls_get_kx_cred
181
182
      (session,
182
183
       _gnutls_cipher_suite_get_kx_algo (&session->
183
 
                                         security_parameters.current_cipher_suite),
 
184
                                         security_parameters.current_cipher_suite),
184
185
       &err) == NULL && err != 0)
185
186
    {
186
187
      gnutls_assert ();
193
194
   */
194
195
  session->internals.auth_struct =
195
196
    _gnutls_kx_auth_struct (_gnutls_cipher_suite_get_kx_algo
196
 
                            (&session->
197
 
                             security_parameters.current_cipher_suite));
 
197
                            (&session->
 
198
                             security_parameters.current_cipher_suite));
198
199
  if (session->internals.auth_struct == NULL)
199
200
    {
200
201
 
201
202
      _gnutls_handshake_log
202
 
        ("HSK[%p]: SSL 2.0 Hello: Cannot find the appropriate handler for the KX algorithm\n",
203
 
         session);
 
203
        ("HSK[%p]: SSL 2.0 Hello: Cannot find the appropriate handler for the KX algorithm\n",
 
204
         session);
204
205
 
205
206
      gnutls_assert ();
206
207
      return GNUTLS_E_INTERNAL_ERROR;
209
210
 
210
211
 
211
212
  /* read random new values -skip session id for now */
212
 
  DECR_LEN (len, session_id_len);       /* skip session id for now */
 
213
  DECR_LEN (len, session_id_len);       /* skip session id for now */
213
214
  memcpy (session_id, &data[pos], session_id_len);
214
215
  pos += session_id_len;
215
216
 
225
226
  _gnutls_tls_create_random (rnd);
226
227
  _gnutls_set_server_random (session, rnd);
227
228
 
228
 
  session->security_parameters.timestamp = time (NULL);
 
229
  session->security_parameters.timestamp = gnutls_time (NULL);
229
230
 
230
231
 
231
232
  /* RESUME SESSION */
234
235
  ret = _gnutls_server_restore_session (session, session_id, session_id_len);
235
236
 
236
237
  if (ret == 0)
237
 
    {                           /* resumed! */
 
238
    {                           /* resumed! */
238
239
      /* get the new random values */
239
240
      memcpy (session->internals.resumed_security_parameters.server_random,
240
 
              session->security_parameters.server_random, GNUTLS_RANDOM_SIZE);
 
241
              session->security_parameters.server_random, GNUTLS_RANDOM_SIZE);
241
242
      memcpy (session->internals.resumed_security_parameters.client_random,
242
 
              session->security_parameters.client_random, GNUTLS_RANDOM_SIZE);
 
243
              session->security_parameters.client_random, GNUTLS_RANDOM_SIZE);
243
244
 
244
245
      session->internals.resumed = RESUME_TRUE;
245
246
      return 0;
247
248
  else
248
249
    {
249
250
      _gnutls_generate_session_id (session->security_parameters.session_id,
250
 
                                   &session->
251
 
                                   security_parameters.session_id_size);
 
251
                                   &session->
 
252
                                   security_parameters.session_id_size);
252
253
      session->internals.resumed = RESUME_FALSE;
253
254
    }
254
255
 
255
256
  session->internals.compression_method = GNUTLS_COMP_NULL;
 
257
  _gnutls_epoch_set_compression (session, EPOCH_NEXT, session->internals.compression_method);
256
258
 
257
259
  return 0;
258
260
}