~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to lib/socks_sspi.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2014-11-10 08:48:21 UTC
  • mfrom: (3.4.52 sid)
  • Revision ID: package-import@ubuntu.com-20141110084821-inwi9tek417xe4te
Tags: 7.38.0-3ubuntu1
* Merge from Debian. Remaining changes:
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
* Dropped patches:
  - debian/patches/09_fix-timeout-in-poll-and-wait.patch: upstream
  - debian/patches/CVE-2014-3613.patch: upstream
  - debian/patches/CVE-2014-3620.patch: upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
8
 * Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
9
 
 * Copyright (C) 2012 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
 
9
 * Copyright (C) 2012 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
 *
11
11
 * This software is licensed as described in the file COPYING, which
12
12
 * you should have received as part of this distribution. The terms
43
43
#include "memdebug.h"
44
44
 
45
45
/*
46
 
 * Definitions required from ntsecapi.h are directly provided below this point
47
 
 * to avoid including ntsecapi.h due to a conflict with OpenSSL's safestack.h
48
 
 */
49
 
#define KERB_WRAP_NO_ENCRYPT 0x80000001
50
 
 
51
 
/*
52
46
 * Helper sspi error functions.
53
47
 */
54
48
static int check_sspi_err(struct connectdata *conn,
76
70
  ssize_t actualread;
77
71
  ssize_t written;
78
72
  int result;
79
 
  /* Needs GSSAPI authentication */
 
73
  /* Needs GSS-API authentication */
80
74
  SECURITY_STATUS status;
81
75
  unsigned long sspi_ret_flags = 0;
82
76
  int gss_enc;
91
85
  char *service_name = NULL;
92
86
  unsigned short us_length;
93
87
  unsigned long qop;
94
 
  unsigned char socksreq[4]; /* room for gssapi exchange header only */
 
88
  unsigned char socksreq[4]; /* room for GSS-API exchange header only */
95
89
  char *service = data->set.str[STRING_SOCKS5_GSSAPI_SERVICE];
96
90
 
97
 
  /*   GSSAPI request looks like
 
91
  /*   GSS-API request looks like
98
92
   * +----+------+-----+----------------+
99
93
   * |VER | MTYP | LEN |     TOKEN      |
100
94
   * +----+------+----------------------+
201
195
    }
202
196
 
203
197
    if(sspi_send_token.cbBuffer != 0) {
204
 
      socksreq[0] = 1;    /* gssapi subnegotiation version */
 
198
      socksreq[0] = 1;    /* GSS-API subnegotiation version */
205
199
      socksreq[1] = 1;    /* authentication message type */
206
200
      us_length = htons((short)sspi_send_token.cbBuffer);
207
201
      memcpy(socksreq+2, &us_length, sizeof(short));
252
246
 
253
247
    /* analyse response */
254
248
 
255
 
    /*   GSSAPI response looks like
 
249
    /*   GSS-API response looks like
256
250
     * +----+------+-----+----------------+
257
251
     * |VER | MTYP | LEN |     TOKEN      |
258
252
     * +----+------+----------------------+
329
323
    failf(data, "Failed to determine user name.");
330
324
    return CURLE_COULDNT_CONNECT;
331
325
  }
332
 
  infof(data, "SOCKS5 server authencticated user %s with gssapi.\n",
 
326
  infof(data, "SOCKS5 server authencticated user %s with GSS-API.\n",
333
327
        names.sUserName);
334
328
  s_pSecFn->FreeContextBuffer(names.sUserName);
335
329
 
336
330
  /* Do encryption */
337
 
  socksreq[0] = 1;    /* gssapi subnegotiation version */
 
331
  socksreq[0] = 1;    /* GSS-API subnegotiation version */
338
332
  socksreq[1] = 2;    /* encryption message type */
339
333
 
340
334
  gss_enc = 0; /* no data protection */
345
339
  else if(sspi_ret_flags & ISC_REQ_INTEGRITY)
346
340
    gss_enc = 1;
347
341
 
348
 
  infof(data, "SOCKS5 server supports gssapi %s data protection.\n",
 
342
  infof(data, "SOCKS5 server supports GSS-API %s data protection.\n",
349
343
        (gss_enc==0)?"no":((gss_enc==1)?"integrity":"confidentiality") );
350
344
  /* force to no data protection, avoid encryption/decryption for now */
351
345
  gss_enc = 0;
593
587
  }
594
588
 
595
589
  infof(data, "SOCKS5 access with%s protection granted.\n",
596
 
        (socksreq[0]==0)?"out gssapi data":
597
 
        ((socksreq[0]==1)?" gssapi integrity":" gssapi confidentiality"));
 
590
        (socksreq[0]==0)?"out GSS-API data":
 
591
        ((socksreq[0]==1)?" GSS-API integrity":" GSS-API confidentiality"));
598
592
 
599
593
  /* For later use if encryption is required
600
594
     conn->socks5_gssapi_enctype = socksreq[0];