~ubuntu-branches/ubuntu/trusty/wpa/trusty

« back to all changes in this revision

Viewing changes to src/eap_peer/eap_gpsk.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2014-03-04 16:13:24 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140304161324-md40gw8imcectbuu
Tags: 2.1-0ubuntu1
* New upstream release (LP: #1099755)
* debian/get-orig-source: update for new git repository for the current
  hostap/wpasupplicant versions.
* Dropped patches due to being applied upstream and included in the current
  source tarball:
  - debian/patches/11_wpa_gui_ftbfs_gcc_4_7.patch
  - debian/patches/13_human_readable_signal.patch
  - debian/patches/git_deinit_p2p_context_on_mgmt_remove_ff1f9c8.patch
  - debian/patches/libnl3-includes.patch
* debian/patches/git_accept_client_cert_from_server.patch: revert the commit:
  "OpenSSL: Do not accept SSL Client certificate for server", which breaks
  many AAA servers that include both client and server EKUs. Cherry-picked
  from hostap git commit b62d5b5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * EAP peer method: EAP-GPSK (RFC 5433)
3
 
 * Copyright (c) 2006-2008, Jouni Malinen <j@w1.fi>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License version 2 as
7
 
 * published by the Free Software Foundation.
8
 
 *
9
 
 * Alternatively, this software may be distributed under the terms of BSD
10
 
 * license.
11
 
 *
12
 
 * See README and COPYING for more details.
 
3
 * Copyright (c) 2006-2014, Jouni Malinen <j@w1.fi>
 
4
 *
 
5
 * This software may be distributed under the terms of the BSD license.
 
6
 * See README for more details.
13
7
 */
14
8
 
15
9
#include "includes.h"
29
23
        size_t sk_len;
30
24
        u8 pk[EAP_GPSK_MAX_PK_LEN];
31
25
        size_t pk_len;
32
 
        u8 session_id;
33
 
        int session_id_set;
 
26
        u8 session_id[128];
 
27
        size_t id_len;
34
28
        u8 *id_peer;
35
29
        size_t id_peer_len;
36
30
        u8 *id_server;
39
33
        int specifier; /* CSuite/Specifier */
40
34
        u8 *psk;
41
35
        size_t psk_len;
 
36
        u16 forced_cipher; /* force cipher or 0 to allow all supported */
42
37
};
43
38
 
44
39
 
86
81
        struct eap_gpsk_data *data;
87
82
        const u8 *identity, *password;
88
83
        size_t identity_len, password_len;
 
84
        const char *phase1;
89
85
 
90
86
        password = eap_get_config_password(sm, &password_len);
91
87
        if (password == NULL) {
109
105
                data->id_peer_len = identity_len;
110
106
        }
111
107
 
 
108
        phase1 = eap_get_config_phase1(sm);
 
109
        if (phase1) {
 
110
                const char *pos;
 
111
 
 
112
                pos = os_strstr(phase1, "cipher=");
 
113
                if (pos) {
 
114
                        data->forced_cipher = atoi(pos + 7);
 
115
                        wpa_printf(MSG_DEBUG, "EAP-GPSK: Forced cipher %u",
 
116
                                   data->forced_cipher);
 
117
                }
 
118
        }
 
119
 
112
120
        data->psk = os_malloc(password_len);
113
121
        if (data->psk == NULL) {
114
122
                eap_gpsk_deinit(sm, data);
201
209
                           i, vendor, specifier);
202
210
                if (data->vendor == EAP_GPSK_VENDOR_IETF &&
203
211
                    data->specifier == EAP_GPSK_CIPHER_RESERVED &&
204
 
                    eap_gpsk_supported_ciphersuite(vendor, specifier)) {
 
212
                    eap_gpsk_supported_ciphersuite(vendor, specifier) &&
 
213
                    (!data->forced_cipher || data->forced_cipher == specifier))
 
214
                {
205
215
                        data->vendor = vendor;
206
216
                        data->specifier = specifier;
207
217
                }
279
289
        pos = eap_gpsk_process_csuite_list(sm, data, &csuite_list,
280
290
                                           &csuite_list_len, pos, end);
281
291
        if (pos == NULL) {
 
292
                ret->methodState = METHOD_DONE;
282
293
                eap_gpsk_state(data, FAILURE);
283
294
                return NULL;
284
295
        }
360
371
                return NULL;
361
372
        }
362
373
 
 
374
        if (eap_gpsk_derive_session_id(data->psk, data->psk_len,
 
375
                                       data->vendor, data->specifier,
 
376
                                       data->rand_peer, data->rand_server,
 
377
                                       data->id_peer, data->id_peer_len,
 
378
                                       data->id_server, data->id_server_len,
 
379
                                       EAP_TYPE_GPSK,
 
380
                                       data->session_id, &data->id_len) < 0) {
 
381
                wpa_printf(MSG_DEBUG, "EAP-GPSK: Failed to derive Session-Id");
 
382
                eap_gpsk_state(data, FAILURE);
 
383
                wpabuf_free(resp);
 
384
                return NULL;
 
385
        }
 
386
        wpa_hexdump(MSG_DEBUG, "EAP-GPSK: Derived Session-Id",
 
387
                    data->session_id, data->id_len);
 
388
 
363
389
        /* No PD_Payload_1 */
364
390
        wpabuf_put_be16(resp, 0);
365
391
 
714
740
}
715
741
 
716
742
 
 
743
static u8 * eap_gpsk_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
 
744
{
 
745
        struct eap_gpsk_data *data = priv;
 
746
        u8 *sid;
 
747
 
 
748
        if (data->state != SUCCESS)
 
749
                return NULL;
 
750
 
 
751
        sid = os_malloc(data->id_len);
 
752
        if (sid == NULL)
 
753
                return NULL;
 
754
        os_memcpy(sid, data->session_id, data->id_len);
 
755
        *len = data->id_len;
 
756
 
 
757
        return sid;
 
758
}
 
759
 
 
760
 
717
761
int eap_peer_gpsk_register(void)
718
762
{
719
763
        struct eap_method *eap;
730
774
        eap->isKeyAvailable = eap_gpsk_isKeyAvailable;
731
775
        eap->getKey = eap_gpsk_getKey;
732
776
        eap->get_emsk = eap_gpsk_get_emsk;
 
777
        eap->getSessionId = eap_gpsk_get_session_id;
733
778
 
734
779
        ret = eap_peer_method_register(eap);
735
780
        if (ret)