~ubuntu-branches/ubuntu/vivid/wpasupplicant/vivid

« back to all changes in this revision

Viewing changes to eap_tls_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2006-10-05 08:04:01 UTC
  • mfrom: (1.1.5 upstream) (3 etch)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061005080401-r8lqlix4390yos7b
Tags: 0.5.5-2
* Update madwifi headers to latest SVN. (Closes: #388316)
* Remove failed attempt at action locking. [debian/functions.sh,
  debian/wpa_action.sh]
* Add hysteresis checking functions, to avoid "event loops" while
  using wpa-roam. [debian/functions.sh, debian/wpa_action.sh]
* Change of co-maintainer email address.
* Add ishex() function to functions.sh to determine wpa-psk value type in
  plaintext or hex. This effectively eliminates the need for the bogus and
  somewhat confusing wpa-passphrase contruct specific to our scripts and
  allows wpa-psk to work with either a 8 to 63 character long plaintext
  string or 64 character long hex string.
* Adjust README.modes to not refer to the redundant wpa-passphrase stuff.
* Add big fat NOTE about acceptable wpa-psk's to top of example gallery.
* Strip surrounding quotes from wpa-ssid if present, instead of just whining
  about them.
* Update email address in copyright blurb of functions.sh, ifupdown.sh and
  wpa_action.sh.  

Show diffs side-by-side

added added

removed removed

Lines of Context:
344
344
                }
345
345
        } else {
346
346
                data->tls_in_left = 0;
347
 
                data->tls_in = malloc(in_len);
 
347
                data->tls_in = malloc(in_len ? in_len : 1);
348
348
                if (data->tls_in == NULL)
349
349
                        return NULL;
350
350
                memcpy(data->tls_in, in_data, in_len);
357
357
 
358
358
 
359
359
static int eap_tls_process_input(struct eap_sm *sm, struct eap_ssl_data *data,
360
 
                                 const u8 *in_data, size_t in_len)
 
360
                                 const u8 *in_data, size_t in_len,
 
361
                                 u8 **out_data, size_t *out_len)
361
362
{
362
363
        const u8 *msg;
363
364
        size_t msg_len;
364
365
        int need_more_input;
 
366
        u8 *appl_data;
 
367
        size_t appl_data_len;
365
368
 
366
369
        msg = eap_tls_data_reassemble(sm, data, in_data, in_len,
367
370
                                      &msg_len, &need_more_input);
376
379
                free(data->tls_out);
377
380
                WPA_ASSERT(data->tls_out == NULL);
378
381
        }
 
382
        appl_data = NULL;
379
383
        data->tls_out = tls_connection_handshake(sm->ssl_ctx, data->conn,
380
384
                                                 msg, msg_len,
381
 
                                                 &data->tls_out_len);
 
385
                                                 &data->tls_out_len,
 
386
                                                 &appl_data, &appl_data_len);
382
387
 
383
388
        /* Clear reassembled input data (if the buffer was needed). */
384
389
        data->tls_in_left = data->tls_in_total = data->tls_in_len = 0;
385
390
        free(data->tls_in);
386
391
        data->tls_in = NULL;
387
392
 
 
393
        if (appl_data &&
 
394
            tls_connection_established(sm->ssl_ctx, data->conn) &&
 
395
            !tls_connection_get_failed(sm->ssl_ctx, data->conn)) {
 
396
                wpa_hexdump_key(MSG_MSGDUMP, "SSL: Application data",
 
397
                                appl_data, appl_data_len);
 
398
                *out_data = appl_data;
 
399
                *out_len = appl_data_len;
 
400
                return 2;
 
401
        }
 
402
 
 
403
        free(appl_data);
 
404
 
388
405
        return 0;
389
406
}
390
407
 
483
500
        if (data->tls_out_len == 0) {
484
501
                /* No more data to send out - expect to receive more data from
485
502
                 * the AS. */
486
 
                int res = eap_tls_process_input(sm, data, in_data, in_len);
 
503
                int res = eap_tls_process_input(sm, data, in_data, in_len,
 
504
                                                out_data, out_len);
487
505
                if (res)
488
506
                        return res;
489
507
        }
572
590
                   size_t buflen, int verbose)
573
591
{
574
592
        char name[128];
575
 
        int len = 0;
 
593
        int len = 0, ret;
576
594
 
577
595
        if (tls_get_cipher(sm->ssl_ctx, data->conn, name, sizeof(name)) == 0) {
578
 
                len += snprintf(buf + len, buflen - len,
579
 
                                "EAP TLS cipher=%s\n", name);
 
596
                ret = snprintf(buf + len, buflen - len,
 
597
                               "EAP TLS cipher=%s\n", name);
 
598
                if (ret < 0 || (size_t) ret >= buflen - len)
 
599
                        return len;
 
600
                len += ret;
580
601
        }
581
602
 
582
603
        return len;