Coverage Report

Created: 2026-09-03 06:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hostap/wpa_supplicant/wpas_glue.c
Line
Count
Source
1
/*
2
 * WPA Supplicant - Glue code to setup EAPOL and RSN modules
3
 * Copyright (c) 2003-2015, 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.
7
 */
8
9
#include "includes.h"
10
11
#include "common.h"
12
#include "eapol_supp/eapol_supp_sm.h"
13
#include "eap_peer/eap.h"
14
#include "rsn_supp/wpa.h"
15
#include "eloop.h"
16
#include "config.h"
17
#include "l2_packet/l2_packet.h"
18
#include "common/wpa_common.h"
19
#include "common/ptksa_cache.h"
20
#include "wpa_supplicant_i.h"
21
#include "driver_i.h"
22
#include "rsn_supp/pmksa_cache.h"
23
#include "sme.h"
24
#include "common/ieee802_11_defs.h"
25
#include "common/wpa_ctrl.h"
26
#include "wpas_glue.h"
27
#include "wps_supplicant.h"
28
#include "bss.h"
29
#include "scan.h"
30
#include "notify.h"
31
#include "wpas_kay.h"
32
33
34
#ifndef CONFIG_NO_CONFIG_BLOBS
35
#if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
36
static void wpa_supplicant_set_config_blob(void *ctx,
37
             struct wpa_config_blob *blob)
38
0
{
39
0
  struct wpa_supplicant *wpa_s = ctx;
40
0
  wpa_config_set_blob(wpa_s->conf, blob);
41
0
  if (wpa_s->conf->update_config) {
42
0
    int ret = wpa_config_write(wpa_s->confname, wpa_s->conf);
43
0
    if (ret) {
44
0
      wpa_printf(MSG_DEBUG, "Failed to update config after "
45
0
           "blob set");
46
0
    }
47
0
  }
48
0
}
49
50
51
static const struct wpa_config_blob *
52
wpa_supplicant_get_config_blob(void *ctx, const char *name)
53
0
{
54
0
  struct wpa_supplicant *wpa_s = ctx;
55
0
  return wpa_config_get_blob(wpa_s->conf, name);
56
0
}
57
#endif /* defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA) */
58
#endif /* CONFIG_NO_CONFIG_BLOBS */
59
60
61
#if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
62
static u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, u8 type,
63
          const void *data, u16 data_len,
64
          size_t *msg_len, void **data_pos)
65
0
{
66
0
  struct ieee802_1x_hdr *hdr;
67
68
0
  *msg_len = sizeof(*hdr) + data_len;
69
0
  hdr = os_malloc(*msg_len);
70
0
  if (hdr == NULL)
71
0
    return NULL;
72
73
0
  hdr->version = wpa_s->conf->eapol_version;
74
0
  hdr->type = type;
75
0
  hdr->length = host_to_be16(data_len);
76
77
0
  if (data)
78
0
    os_memcpy(hdr + 1, data, data_len);
79
0
  else
80
0
    os_memset(hdr + 1, 0, data_len);
81
82
0
  if (data_pos)
83
0
    *data_pos = hdr + 1;
84
85
0
  return (u8 *) hdr;
86
0
}
87
88
89
/**
90
 * wpa_ether_send - Send Ethernet frame
91
 * @wpa_s: Pointer to wpa_supplicant data
92
 * @dest: Destination MAC address
93
 * @proto: Ethertype in host byte order
94
 * @buf: Frame payload starting from IEEE 802.1X header
95
 * @len: Frame payload length
96
 * Returns: >=0 on success, <0 on failure
97
 */
98
int wpa_ether_send(struct wpa_supplicant *wpa_s, const u8 *dest,
99
       u16 proto, const u8 *buf, size_t len)
100
0
{
101
#ifdef CONFIG_TESTING_OPTIONS
102
  if (wpa_s->ext_eapol_frame_io && proto == ETH_P_EAPOL) {
103
    size_t hex_len = 2 * len + 1;
104
    char *hex = os_malloc(hex_len);
105
106
    if (hex == NULL)
107
      return -1;
108
    wpa_snprintf_hex(hex, hex_len, buf, len);
109
    wpa_msg(wpa_s, MSG_INFO, "EAPOL-TX " MACSTR " %s",
110
      MAC2STR(dest), hex);
111
    os_free(hex);
112
    return 0;
113
  }
114
#endif /* CONFIG_TESTING_OPTIONS */
115
116
0
  if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_CONTROL_PORT) {
117
0
    int encrypt = wpa_s->wpa &&
118
0
      wpa_sm_has_ptk_installed(wpa_s->wpa);
119
120
0
    return wpa_drv_tx_control_port(wpa_s, dest, proto, buf, len,
121
0
                 !encrypt);
122
0
  }
123
124
0
  if (wpa_s->l2) {
125
0
    return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
126
0
  }
127
128
0
  return -1;
129
0
}
130
#endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */
131
132
133
#ifdef IEEE8021X_EAPOL
134
135
/**
136
 * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator
137
 * @ctx: Pointer to wpa_supplicant data (wpa_s)
138
 * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
139
 * @buf: EAPOL payload (after IEEE 802.1X header)
140
 * @len: EAPOL payload length
141
 * Returns: >=0 on success, <0 on failure
142
 *
143
 * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
144
 * to the current Authenticator.
145
 */
146
static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
147
             size_t len)
148
0
{
149
0
  struct wpa_supplicant *wpa_s = ctx;
150
0
  u8 *msg, *dst, bssid[ETH_ALEN];
151
0
  struct driver_sta_mlo_info drv_mlo;
152
0
  size_t msglen;
153
0
  int res;
154
155
  /* TODO: could add l2_packet_sendmsg that allows fragments to avoid
156
   * extra copy here */
157
158
0
  if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
159
0
      wpa_s->key_mgmt == WPA_KEY_MGMT_OWE ||
160
0
      wpa_s->key_mgmt == WPA_KEY_MGMT_DPP ||
161
0
      wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
162
    /* Current SSID is not using IEEE 802.1X/EAP, so drop possible
163
     * EAPOL frames (mainly, EAPOL-Start) from EAPOL state
164
     * machines. */
165
0
    wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X "
166
0
         "mode (type=%d len=%lu)", type,
167
0
         (unsigned long) len);
168
0
    return -1;
169
0
  }
170
171
0
  if (pmksa_cache_get_current(wpa_s->wpa) &&
172
0
      type == IEEE802_1X_TYPE_EAPOL_START) {
173
    /*
174
     * We were trying to use PMKSA caching and sending EAPOL-Start
175
     * would abort that and trigger full EAPOL authentication.
176
     * However, we've already waited for the AP/Authenticator to
177
     * start 4-way handshake or EAP authentication, and apparently
178
     * it has not done so since the startWhen timer has reached zero
179
     * to get the state machine sending EAPOL-Start. This is not
180
     * really supposed to happen, but an interoperability issue with
181
     * a deployed AP has been identified where the connection fails
182
     * due to that AP failing to operate correctly if PMKID is
183
     * included in the Association Request frame. To work around
184
     * this, assume PMKSA caching failed and try to initiate full
185
     * EAP authentication.
186
     */
187
0
    if (!wpa_s->current_ssid ||
188
0
        wpa_s->current_ssid->eap_workaround) {
189
0
      wpa_printf(MSG_DEBUG,
190
0
           "RSN: Timeout on waiting for the AP to initiate 4-way handshake for PMKSA caching or EAP authentication - try to force it to start EAP authentication");
191
0
    } else {
192
0
      wpa_printf(MSG_DEBUG,
193
0
           "RSN: PMKSA caching - do not send EAPOL-Start");
194
0
      return -1;
195
0
    }
196
0
  }
197
198
0
  if (is_zero_ether_addr(wpa_s->bssid)) {
199
0
    wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
200
0
         "EAPOL frame");
201
0
    os_memset(&drv_mlo, 0, sizeof(drv_mlo));
202
0
    if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
203
0
        (!wpa_s->valid_links ||
204
0
         wpas_drv_get_sta_mlo_info(wpa_s, &drv_mlo) == 0) &&
205
0
        !is_zero_ether_addr(bssid)) {
206
0
      dst = drv_mlo.valid_links ? drv_mlo.ap_mld_addr : bssid;
207
0
      wpa_printf(MSG_DEBUG, "Using current %s " MACSTR
208
0
           " from the driver as the EAPOL destination",
209
0
           drv_mlo.valid_links ? "AP MLD MAC address" :
210
0
           "BSSID",
211
0
           MAC2STR(dst));
212
0
    } else {
213
0
      dst = wpa_s->last_eapol_src;
214
0
      wpa_printf(MSG_DEBUG, "Using the source address of the"
215
0
           " last received EAPOL frame " MACSTR " as "
216
0
           "the EAPOL destination",
217
0
           MAC2STR(dst));
218
0
    }
219
0
  } else {
220
    /* BSSID was already set (from (Re)Assoc event, so use BSSID or
221
     * AP MLD MAC address (in the case of MLO connection) as the
222
     * EAPOL destination. */
223
0
    dst = wpa_s->valid_links ? wpa_s->ap_mld_addr : wpa_s->bssid;
224
0
  }
225
226
0
  msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL);
227
0
  if (msg == NULL)
228
0
    return -1;
229
230
0
  wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst));
231
0
  wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen);
232
0
  res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen);
233
0
  os_free(msg);
234
0
  return res;
235
0
}
236
237
238
#ifdef CONFIG_WEP
239
/**
240
 * wpa_eapol_set_wep_key - set WEP key for the driver
241
 * @ctx: Pointer to wpa_supplicant data (wpa_s)
242
 * @unicast: 1 = individual unicast key, 0 = broadcast key
243
 * @keyidx: WEP key index (0..3)
244
 * @key: Pointer to key data
245
 * @keylen: Key length in bytes
246
 * Returns: 0 on success or < 0 on error.
247
 */
248
static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
249
         const u8 *key, size_t keylen)
250
{
251
  struct wpa_supplicant *wpa_s = ctx;
252
  if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
253
    int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
254
      WPA_CIPHER_WEP104;
255
    if (unicast)
256
      wpa_s->pairwise_cipher = cipher;
257
    else
258
      wpa_s->group_cipher = cipher;
259
  }
260
  return wpa_drv_set_key(wpa_s, -1, WPA_ALG_WEP,
261
             unicast ? wpa_s->bssid : NULL,
262
             keyidx, unicast, NULL, 0, key, keylen,
263
             unicast ? KEY_FLAG_PAIRWISE_RX_TX :
264
             KEY_FLAG_GROUP_RX_TX_DEFAULT);
265
}
266
#endif /* CONFIG_WEP */
267
268
269
static void wpa_supplicant_aborted_cached(void *ctx)
270
0
{
271
0
  struct wpa_supplicant *wpa_s = ctx;
272
0
  wpa_sm_aborted_cached(wpa_s->wpa);
273
0
}
274
275
276
static const char * result_str(enum eapol_supp_result result)
277
0
{
278
0
  switch (result) {
279
0
  case EAPOL_SUPP_RESULT_FAILURE:
280
0
    return "FAILURE";
281
0
  case EAPOL_SUPP_RESULT_SUCCESS:
282
0
    return "SUCCESS";
283
0
  case EAPOL_SUPP_RESULT_EXPECTED_FAILURE:
284
0
    return "EXPECTED_FAILURE";
285
0
  }
286
0
  return "?";
287
0
}
288
289
290
static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol,
291
            enum eapol_supp_result result,
292
            void *ctx)
293
0
{
294
0
  struct wpa_supplicant *wpa_s = ctx;
295
0
  const u8 *auth_addr;
296
0
  int res, pmk_len;
297
0
  u8 pmk[PMK_LEN_MAX];
298
299
0
  wpa_printf(MSG_DEBUG, "EAPOL authentication completed - result=%s",
300
0
       result_str(result));
301
302
0
  if (wpas_wps_eapol_cb(wpa_s) > 0)
303
0
    return;
304
305
0
  wpa_s->eap_expected_failure = result ==
306
0
    EAPOL_SUPP_RESULT_EXPECTED_FAILURE;
307
308
0
  if (result != EAPOL_SUPP_RESULT_SUCCESS) {
309
0
    int timeout = 2;
310
    /*
311
     * Make sure we do not get stuck here waiting for long EAPOL
312
     * timeout if the AP does not disconnect in case of
313
     * authentication failure.
314
     */
315
0
    if (wpa_s->eapol_failed) {
316
0
      wpa_printf(MSG_DEBUG,
317
0
           "EAPOL authentication failed again and AP did not disconnect us");
318
0
      timeout = 0;
319
0
    }
320
0
    wpa_s->eapol_failed = 1;
321
0
    wpa_supplicant_req_auth_timeout(wpa_s, timeout, 0);
322
0
  } else {
323
0
    wpa_s->eapol_failed = 0;
324
0
    ieee802_1x_notify_create_actor(wpa_s, wpa_s->last_eapol_src);
325
0
  }
326
327
0
  if (result != EAPOL_SUPP_RESULT_SUCCESS ||
328
0
      !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X))
329
0
    return;
330
331
0
  if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt))
332
0
    return;
333
334
0
  wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way "
335
0
       "handshake");
336
337
0
  if (wpa_key_mgmt_sha384(wpa_s->key_mgmt))
338
0
    pmk_len = PMK_LEN_SUITE_B_192;
339
0
  else
340
0
    pmk_len = PMK_LEN;
341
342
0
  if (wpa_key_mgmt_ft(wpa_s->key_mgmt)) {
343
#ifdef CONFIG_IEEE80211R
344
    u8 buf[2 * PMK_LEN];
345
    wpa_printf(MSG_DEBUG, "RSN: Use FT XXKey as PMK for "
346
         "driver-based 4-way hs and FT");
347
    res = eapol_sm_get_key(eapol, buf, 2 * PMK_LEN);
348
    if (res == 0) {
349
      if (wpa_key_mgmt_sha384(wpa_s->key_mgmt))
350
        os_memcpy(pmk, buf, pmk_len);
351
      else
352
        os_memcpy(pmk, buf + PMK_LEN, PMK_LEN);
353
      os_memset(buf, 0, sizeof(buf));
354
    }
355
#else /* CONFIG_IEEE80211R */
356
0
    res = -1;
357
0
#endif /* CONFIG_IEEE80211R */
358
0
  } else {
359
0
    res = eapol_sm_get_key(eapol, pmk, pmk_len);
360
0
    if (res) {
361
      /*
362
       * EAP-LEAP is an exception from other EAP methods: it
363
       * uses only 16-byte PMK.
364
       */
365
0
      res = eapol_sm_get_key(eapol, pmk, 16);
366
0
      pmk_len = 16;
367
0
    }
368
0
  }
369
370
0
  if (res) {
371
0
    wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state "
372
0
         "machines");
373
0
    return;
374
0
  }
375
376
0
  wpa_hexdump_key(MSG_DEBUG, "RSN: Configure PMK for driver-based 4-way "
377
0
      "handshake", pmk, pmk_len);
378
379
0
  if (wpa_drv_set_key(wpa_s, -1, 0, NULL, 0, 0, NULL, 0, pmk,
380
0
          pmk_len, KEY_FLAG_PMK)) {
381
0
    wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver");
382
0
  }
383
384
0
  if (wpa_s->wpa_proto == WPA_PROTO_RSN &&
385
0
      !wpa_key_mgmt_suite_b(wpa_s->key_mgmt) &&
386
0
      !wpa_key_mgmt_ft(wpa_s->key_mgmt)) {
387
0
    auth_addr = wpa_sm_get_auth_addr(wpa_s->wpa);
388
0
    if (!is_zero_ether_addr(auth_addr))
389
0
      wpa_sm_set_pmk(wpa_s->wpa, pmk, pmk_len, NULL,
390
0
               auth_addr);
391
0
  }
392
393
0
  wpa_supplicant_cancel_scan(wpa_s);
394
0
  wpa_supplicant_cancel_auth_timeout(wpa_s);
395
0
  wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
396
397
0
}
398
399
400
static void wpa_supplicant_notify_eapol_done(void *ctx)
401
0
{
402
0
  struct wpa_supplicant *wpa_s = ctx;
403
0
  wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete");
404
0
  if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
405
0
    wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
406
0
  } else {
407
0
    wpa_supplicant_cancel_auth_timeout(wpa_s);
408
0
    wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
409
0
  }
410
0
}
411
412
#endif /* IEEE8021X_EAPOL */
413
414
415
#ifndef CONFIG_NO_WPA
416
417
static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
418
0
{
419
0
  int ret = 0;
420
0
  struct wpa_bss *curr = NULL, *bss;
421
0
  struct wpa_ssid *ssid = wpa_s->current_ssid;
422
0
  const u8 *ie;
423
424
0
  dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
425
0
    if (!ether_addr_equal(bss->bssid, wpa_s->bssid))
426
0
      continue;
427
0
    if (ssid == NULL ||
428
0
        ((bss->ssid_len == ssid->ssid_len &&
429
0
          os_memcmp(bss->ssid, ssid->ssid, ssid->ssid_len) == 0) ||
430
0
         ssid->ssid_len == 0)) {
431
0
      curr = bss;
432
0
      break;
433
0
    }
434
#ifdef CONFIG_OWE
435
    if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
436
        (bss->flags & WPA_BSS_OWE_TRANSITION)) {
437
      curr = bss;
438
      break;
439
    }
440
#endif /* CONFIG_OWE */
441
0
  }
442
443
0
  if (curr) {
444
0
    ie = wpa_bss_get_vendor_ie(curr, WPA_IE_VENDOR_TYPE);
445
0
    if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
446
0
      ret = -1;
447
448
0
    ie = wpa_bss_get_ie(curr, WLAN_EID_RSN);
449
0
    if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
450
0
      ret = -1;
451
452
0
    ie = wpa_bss_get_ie(curr, WLAN_EID_RSNX);
453
0
    if (wpa_sm_set_ap_rsnxe(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
454
0
      ret = -1;
455
456
0
    ie = wpa_bss_get_vendor_ie(curr, RSNE_OVERRIDE_IE_VENDOR_TYPE);
457
0
    if (wpa_sm_set_ap_rsne_override(wpa_s->wpa, ie,
458
0
            ie ? 2 + ie[1] : 0))
459
0
      ret = -1;
460
461
0
    ie = wpa_bss_get_vendor_ie(curr,
462
0
             RSNE_OVERRIDE_2_IE_VENDOR_TYPE);
463
0
    if (wpa_sm_set_ap_rsne_override_2(wpa_s->wpa, ie,
464
0
              ie ? 2 + ie[1] : 0))
465
0
      ret = -1;
466
467
0
    ie = wpa_bss_get_vendor_ie(curr, RSNXE_OVERRIDE_IE_VENDOR_TYPE);
468
0
    if (wpa_sm_set_ap_rsnxe_override(wpa_s->wpa, ie,
469
0
             ie ? 2 + ie[1] : 0))
470
0
      ret = -1;
471
472
0
    ie = wpa_bss_get_ie_ext(curr, WLAN_EID_EXT_SECURITY_PROFILE);
473
0
    if (wpa_sm_set_ap_security_profile(wpa_s->wpa, ie,
474
0
               ie ? 2 + ie[1] : 0))
475
0
      ret = -1;
476
0
  } else {
477
0
    ret = -1;
478
0
  }
479
480
0
  return ret;
481
0
}
482
483
484
static int wpa_supplicant_get_beacon_ie(void *ctx)
485
0
{
486
0
  struct wpa_supplicant *wpa_s = ctx;
487
0
  if (wpa_get_beacon_ie(wpa_s) == 0) {
488
0
    return 0;
489
0
  }
490
491
  /* No WPA/RSN IE found in the cached scan results. Try to get updated
492
   * scan results from the driver. */
493
0
  if (wpa_supplicant_update_scan_results(wpa_s, wpa_s->bssid) < 0)
494
0
    return -1;
495
496
0
  return wpa_get_beacon_ie(wpa_s);
497
0
}
498
499
500
static u8 * _wpa_alloc_eapol(void *wpa_s, u8 type,
501
           const void *data, u16 data_len,
502
           size_t *msg_len, void **data_pos)
503
0
{
504
0
  return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos);
505
0
}
506
507
508
static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto,
509
         const u8 *buf, size_t len)
510
0
{
511
0
  return wpa_ether_send(wpa_s, dest, proto, buf, len);
512
0
}
513
514
515
static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s)
516
0
{
517
0
  wpa_supplicant_cancel_auth_timeout(wpa_s);
518
0
}
519
520
521
static void _wpa_supplicant_set_state(void *wpa_s, enum wpa_states state)
522
0
{
523
0
  wpa_supplicant_set_state(wpa_s, state);
524
0
}
525
526
527
/**
528
 * wpa_supplicant_get_state - Get the connection state
529
 * @wpa_s: Pointer to wpa_supplicant data
530
 * Returns: The current connection state (WPA_*)
531
 */
532
static enum wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
533
0
{
534
0
  return wpa_s->wpa_state;
535
0
}
536
537
538
static enum wpa_states _wpa_supplicant_get_state(void *wpa_s)
539
0
{
540
0
  return wpa_supplicant_get_state(wpa_s);
541
0
}
542
543
544
static void _wpa_supplicant_deauthenticate(void *wpa_s, u16 reason_code)
545
0
{
546
0
  wpa_supplicant_deauthenticate(wpa_s, reason_code);
547
  /* Schedule a scan to make sure we continue looking for networks */
548
0
  wpa_supplicant_req_scan(wpa_s, 5, 0);
549
0
}
550
551
552
static void _wpa_supplicant_reconnect(void *wpa_s)
553
0
{
554
0
  wpa_supplicant_reconnect(wpa_s);
555
0
}
556
557
558
static void * wpa_supplicant_get_network_ctx(void *wpa_s)
559
0
{
560
0
  return wpa_supplicant_get_ssid(wpa_s);
561
0
}
562
563
564
static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
565
0
{
566
0
  struct wpa_supplicant *wpa_s = ctx;
567
0
  return wpa_drv_get_bssid(wpa_s, bssid);
568
0
}
569
570
571
static int wpa_supplicant_set_key(void *_wpa_s, int link_id, enum wpa_alg alg,
572
          const u8 *addr, int key_idx, int set_tx,
573
          const u8 *seq, size_t seq_len,
574
          const u8 *key, size_t key_len,
575
          enum key_flag key_flag)
576
0
{
577
0
  struct wpa_supplicant *wpa_s = _wpa_s;
578
0
  int ret;
579
580
0
  if (alg == WPA_ALG_TKIP && key_idx == 0 && key_len == 32) {
581
    /* Clear the MIC error counter when setting a new PTK. */
582
0
    wpa_s->mic_errors_seen = 0;
583
0
  }
584
#ifdef CONFIG_TESTING_GET_GTK
585
  if (key_idx > 0 && addr && is_broadcast_ether_addr(addr) &&
586
      alg != WPA_ALG_NONE && key_len <= sizeof(wpa_s->last_gtk)) {
587
    os_memcpy(wpa_s->last_gtk, key, key_len);
588
    wpa_s->last_gtk_len = key_len;
589
  }
590
#endif /* CONFIG_TESTING_GET_GTK */
591
#ifdef CONFIG_TESTING_OPTIONS
592
  if (addr && !is_broadcast_ether_addr(addr) &&
593
      !(key_flag & KEY_FLAG_MODIFY)) {
594
    wpa_s->last_tk_alg = alg;
595
    os_memcpy(wpa_s->last_tk_addr, addr, ETH_ALEN);
596
    wpa_s->last_tk_key_idx = key_idx;
597
    if (key)
598
      os_memcpy(wpa_s->last_tk, key, key_len);
599
    wpa_s->last_tk_len = key_len;
600
  }
601
#endif /* CONFIG_TESTING_OPTIONS */
602
603
0
  ret = wpa_drv_set_key(wpa_s, link_id, alg, addr, key_idx, set_tx, seq,
604
0
            seq_len, key, key_len, key_flag);
605
0
  if (ret == 0 && (key_idx == 6 || key_idx == 7) &&
606
0
      alg != WPA_ALG_NONE && key_len > 0)
607
0
    wpa_s->bigtk_set = true;
608
609
0
  return ret;
610
0
}
611
612
613
static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
614
               int protection_type,
615
               int key_type)
616
0
{
617
0
  return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type,
618
0
            key_type);
619
0
}
620
621
622
static struct wpa_ssid * wpas_get_network_ctx(struct wpa_supplicant *wpa_s,
623
                void *network_ctx)
624
0
{
625
0
  struct wpa_ssid *ssid;
626
627
0
  for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
628
0
    if (network_ctx == ssid)
629
0
      return ssid;
630
0
  }
631
632
0
  return NULL;
633
0
}
634
635
636
static int wpa_supplicant_add_pmkid(void *_wpa_s, void *network_ctx,
637
            const u8 *bssid, const u8 *pmkid,
638
            const u8 *fils_cache_id,
639
            const u8 *pmk, size_t pmk_len,
640
            u32 pmk_lifetime, u8 pmk_reauth_threshold,
641
            int akmp)
642
0
{
643
0
  struct wpa_supplicant *wpa_s = _wpa_s;
644
0
  struct wpa_ssid *ssid;
645
0
  struct wpa_pmkid_params params;
646
647
0
  os_memset(&params, 0, sizeof(params));
648
0
  ssid = wpas_get_network_ctx(wpa_s, network_ctx);
649
0
  if (ssid) {
650
0
    wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_ADDED MACSTR " %d",
651
0
      MAC2STR(bssid), ssid->id);
652
0
    if ((akmp == WPA_KEY_MGMT_FT_IEEE8021X ||
653
0
         akmp == WPA_KEY_MGMT_FT_IEEE8021X_SHA384) &&
654
0
        !ssid->ft_eap_pmksa_caching) {
655
      /* Since we will not be using PMKSA caching for FT-EAP
656
       * within wpa_supplicant to avoid known interop issues
657
       * with APs, do not add this PMKID to the driver either
658
       * so that we won't be hitting those interop issues
659
       * with driver-based RSNE generation. */
660
0
      wpa_printf(MSG_DEBUG,
661
0
           "FT: Do not add PMKID entry to the driver since FT-EAP PMKSA caching is not enabled in configuration");
662
0
      return 0;
663
0
    }
664
0
  }
665
0
  if (ssid && fils_cache_id) {
666
0
    params.ssid = ssid->ssid;
667
0
    params.ssid_len = ssid->ssid_len;
668
0
    params.fils_cache_id = fils_cache_id;
669
0
  } else {
670
0
    params.bssid = bssid;
671
0
  }
672
673
0
  params.pmkid = pmkid;
674
0
  params.pmk = pmk;
675
0
  params.pmk_len = pmk_len;
676
0
  params.pmk_lifetime = pmk_lifetime;
677
0
  params.pmk_reauth_threshold = pmk_reauth_threshold;
678
679
0
  return wpa_drv_add_pmkid(wpa_s, &params);
680
0
}
681
682
683
static int wpa_supplicant_remove_pmkid(void *_wpa_s, void *network_ctx,
684
               const u8 *bssid, const u8 *pmkid,
685
               const u8 *fils_cache_id)
686
0
{
687
0
  struct wpa_supplicant *wpa_s = _wpa_s;
688
0
  struct wpa_ssid *ssid;
689
0
  struct wpa_pmkid_params params;
690
691
0
  os_memset(&params, 0, sizeof(params));
692
0
  ssid = wpas_get_network_ctx(wpa_s, network_ctx);
693
0
  if (ssid)
694
0
    wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_REMOVED MACSTR " %d",
695
0
      MAC2STR(bssid), ssid->id);
696
0
  if (ssid && fils_cache_id) {
697
0
    params.ssid = ssid->ssid;
698
0
    params.ssid_len = ssid->ssid_len;
699
0
    params.fils_cache_id = fils_cache_id;
700
0
  } else {
701
0
    params.bssid = bssid;
702
0
  }
703
704
0
  params.pmkid = pmkid;
705
706
0
  return wpa_drv_remove_pmkid(wpa_s, &params);
707
0
}
708
709
710
#ifdef CONFIG_IEEE80211R
711
static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
712
          const u8 *ies, size_t ies_len)
713
{
714
  struct wpa_supplicant *wpa_s = ctx;
715
  if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
716
    return sme_update_ft_ies(wpa_s, md, ies, ies_len);
717
  return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
718
}
719
720
721
static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
722
           const u8 *target_ap,
723
           const u8 *ies, size_t ies_len)
724
{
725
  struct wpa_supplicant *wpa_s = ctx;
726
  int ret;
727
  u8 *data, *pos;
728
  size_t data_len;
729
730
  if (action != 1) {
731
    wpa_printf(MSG_ERROR, "Unsupported send_ft_action action %d",
732
         action);
733
    return -1;
734
  }
735
736
  /*
737
   * Action frame payload:
738
   * Category[1] = 6 (Fast BSS Transition)
739
   * Action[1] = 1 (Fast BSS Transition Request)
740
   * STA Address
741
   * Target AP Address
742
   * FT IEs
743
   */
744
745
  data_len = 2 + 2 * ETH_ALEN + ies_len;
746
  data = os_malloc(data_len);
747
  if (data == NULL)
748
    return -1;
749
  pos = data;
750
  *pos++ = 0x06; /* FT Action category */
751
  *pos++ = action;
752
  os_memcpy(pos, wpa_s->own_addr, ETH_ALEN);
753
  pos += ETH_ALEN;
754
  os_memcpy(pos, target_ap, ETH_ALEN);
755
  pos += ETH_ALEN;
756
  os_memcpy(pos, ies, ies_len);
757
758
  ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0,
759
          wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid,
760
          data, data_len, 0);
761
  os_free(data);
762
763
  return ret;
764
}
765
766
767
static int wpa_supplicant_mark_authenticated(void *ctx, const u8 *target_ap)
768
{
769
  struct wpa_supplicant *wpa_s = ctx;
770
  struct wpa_driver_auth_params params;
771
  struct wpa_bss *bss;
772
773
  bss = wpa_bss_get_bssid(wpa_s, target_ap);
774
  if (bss == NULL)
775
    return -1;
776
777
  os_memset(&params, 0, sizeof(params));
778
  params.bssid = target_ap;
779
  params.freq = bss->freq;
780
  params.ssid = bss->ssid;
781
  params.ssid_len = bss->ssid_len;
782
  params.auth_alg = WPA_AUTH_ALG_FT;
783
  params.local_state_change = 1;
784
  return wpa_drv_authenticate(wpa_s, &params);
785
}
786
#endif /* CONFIG_IEEE80211R */
787
788
789
#ifdef CONFIG_TDLS
790
791
static int wpa_supplicant_tdls_get_capa(void *ctx, int *tdls_supported,
792
          int *tdls_ext_setup,
793
          int *tdls_chan_switch)
794
{
795
  struct wpa_supplicant *wpa_s = ctx;
796
797
  *tdls_supported = 0;
798
  *tdls_ext_setup = 0;
799
  *tdls_chan_switch = 0;
800
801
  if (!wpa_s->drv_capa_known)
802
    return -1;
803
804
  if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_SUPPORT)
805
    *tdls_supported = 1;
806
807
  if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP)
808
    *tdls_ext_setup = 1;
809
810
  if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_CHANNEL_SWITCH)
811
    *tdls_chan_switch = 1;
812
813
  return 0;
814
}
815
816
817
static int wpa_supplicant_send_tdls_mgmt(void *ctx, const u8 *dst,
818
           u8 action_code, u8 dialog_token,
819
           u16 status_code, u32 peer_capab,
820
           int initiator, const u8 *buf,
821
           size_t len, int link_id)
822
{
823
  struct wpa_supplicant *wpa_s = ctx;
824
  return wpa_drv_send_tdls_mgmt(wpa_s, dst, action_code, dialog_token,
825
              status_code, peer_capab, initiator, buf,
826
              len, link_id);
827
}
828
829
830
static int wpa_supplicant_tdls_oper(void *ctx, int oper, const u8 *peer)
831
{
832
  struct wpa_supplicant *wpa_s = ctx;
833
  return wpa_drv_tdls_oper(wpa_s, oper, peer);
834
}
835
836
837
static int wpa_supplicant_tdls_peer_addset(
838
  void *ctx, const u8 *peer, int add, u16 aid, u16 capability,
839
  const u8 *supp_rates, size_t supp_rates_len,
840
  const struct ieee80211_ht_capabilities *ht_capab,
841
  const struct ieee80211_vht_capabilities *vht_capab,
842
  const struct ieee80211_he_capabilities *he_capab,
843
  size_t he_capab_len,
844
  const struct ieee80211_he_6ghz_band_cap *he_6ghz_he_capab,
845
  u8 qosinfo, int wmm, const u8 *ext_capab, size_t ext_capab_len,
846
  const u8 *supp_channels, size_t supp_channels_len,
847
  const u8 *supp_oper_classes, size_t supp_oper_classes_len,
848
  const struct ieee80211_eht_capabilities *eht_capab,
849
  size_t eht_capab_len, int mld_link_id)
850
{
851
  struct wpa_supplicant *wpa_s = ctx;
852
  struct hostapd_sta_add_params params;
853
854
  os_memset(&params, 0, sizeof(params));
855
856
  params.addr = peer;
857
  params.aid = aid;
858
  params.capability = capability;
859
  params.flags = WPA_STA_TDLS_PEER | WPA_STA_AUTHORIZED;
860
861
  /*
862
   * Don't rely only on qosinfo for WMM capability. It may be 0 even when
863
   * present. Allow the WMM IE to also indicate QoS support.
864
   */
865
  if (wmm || qosinfo)
866
    params.flags |= WPA_STA_WMM;
867
868
  params.ht_capabilities = ht_capab;
869
  params.vht_capabilities = vht_capab;
870
  params.he_capab = he_capab;
871
  params.he_capab_len = he_capab_len;
872
  params.he_6ghz_capab = he_6ghz_he_capab;
873
  params.qosinfo = qosinfo;
874
  params.listen_interval = 0;
875
  params.supp_rates = supp_rates;
876
  params.supp_rates_len = supp_rates_len;
877
  params.set = !add;
878
  params.ext_capab = ext_capab;
879
  params.ext_capab_len = ext_capab_len;
880
  params.supp_channels = supp_channels;
881
  params.supp_channels_len = supp_channels_len;
882
  params.supp_oper_classes = supp_oper_classes;
883
  params.supp_oper_classes_len = supp_oper_classes_len;
884
  params.eht_capab = eht_capab;
885
  params.eht_capab_len = eht_capab_len;
886
  params.mld_link_id = mld_link_id;
887
888
  return wpa_drv_sta_add(wpa_s, &params);
889
}
890
891
892
static int wpa_supplicant_tdls_enable_channel_switch(
893
  void *ctx, const u8 *addr, u8 oper_class,
894
  const struct hostapd_freq_params *params)
895
{
896
  struct wpa_supplicant *wpa_s = ctx;
897
898
  return wpa_drv_tdls_enable_channel_switch(wpa_s, addr, oper_class,
899
              params);
900
}
901
902
903
static int wpa_supplicant_tdls_disable_channel_switch(void *ctx, const u8 *addr)
904
{
905
  struct wpa_supplicant *wpa_s = ctx;
906
907
  return wpa_drv_tdls_disable_channel_switch(wpa_s, addr);
908
}
909
910
#endif /* CONFIG_TDLS */
911
912
#endif /* CONFIG_NO_WPA */
913
914
915
enum wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field)
916
0
{
917
0
  if (os_strcmp(field, "IDENTITY") == 0)
918
0
    return WPA_CTRL_REQ_EAP_IDENTITY;
919
0
  else if (os_strcmp(field, "PASSWORD") == 0)
920
0
    return WPA_CTRL_REQ_EAP_PASSWORD;
921
0
  else if (os_strcmp(field, "NEW_PASSWORD") == 0)
922
0
    return WPA_CTRL_REQ_EAP_NEW_PASSWORD;
923
0
  else if (os_strcmp(field, "PIN") == 0)
924
0
    return WPA_CTRL_REQ_EAP_PIN;
925
0
  else if (os_strcmp(field, "OTP") == 0)
926
0
    return WPA_CTRL_REQ_EAP_OTP;
927
0
  else if (os_strcmp(field, "PASSPHRASE") == 0)
928
0
    return WPA_CTRL_REQ_EAP_PASSPHRASE;
929
0
  else if (os_strcmp(field, "SIM") == 0)
930
0
    return WPA_CTRL_REQ_SIM;
931
0
  else if (os_strcmp(field, "PSK_PASSPHRASE") == 0)
932
0
    return WPA_CTRL_REQ_PSK_PASSPHRASE;
933
0
  else if (os_strcmp(field, "EXT_CERT_CHECK") == 0)
934
0
    return WPA_CTRL_REQ_EXT_CERT_CHECK;
935
0
  return WPA_CTRL_REQ_UNKNOWN;
936
0
}
937
938
939
const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field,
940
                 const char *default_txt,
941
                 const char **txt)
942
0
{
943
0
  const char *ret = NULL;
944
945
0
  *txt = default_txt;
946
947
0
  switch (field) {
948
0
  case WPA_CTRL_REQ_EAP_IDENTITY:
949
0
    *txt = "Identity";
950
0
    ret = "IDENTITY";
951
0
    break;
952
0
  case WPA_CTRL_REQ_EAP_PASSWORD:
953
0
    *txt = "Password";
954
0
    ret = "PASSWORD";
955
0
    break;
956
0
  case WPA_CTRL_REQ_EAP_NEW_PASSWORD:
957
0
    *txt = "New Password";
958
0
    ret = "NEW_PASSWORD";
959
0
    break;
960
0
  case WPA_CTRL_REQ_EAP_PIN:
961
0
    *txt = "PIN";
962
0
    ret = "PIN";
963
0
    break;
964
0
  case WPA_CTRL_REQ_EAP_OTP:
965
0
    ret = "OTP";
966
0
    break;
967
0
  case WPA_CTRL_REQ_EAP_PASSPHRASE:
968
0
    *txt = "Private key passphrase";
969
0
    ret = "PASSPHRASE";
970
0
    break;
971
0
  case WPA_CTRL_REQ_SIM:
972
0
    ret = "SIM";
973
0
    break;
974
0
  case WPA_CTRL_REQ_PSK_PASSPHRASE:
975
0
    *txt = "PSK or passphrase";
976
0
    ret = "PSK_PASSPHRASE";
977
0
    break;
978
0
  case WPA_CTRL_REQ_EXT_CERT_CHECK:
979
0
    *txt = "External server certificate validation";
980
0
    ret = "EXT_CERT_CHECK";
981
0
    break;
982
0
  default:
983
0
    break;
984
0
  }
985
986
  /* txt needs to be something */
987
0
  if (*txt == NULL) {
988
0
    wpa_printf(MSG_WARNING, "No message for request %d", field);
989
0
    ret = NULL;
990
0
  }
991
992
0
  return ret;
993
0
}
994
995
996
void wpas_send_ctrl_req(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
997
      const char *field_name, const char *txt)
998
0
{
999
0
  wpa_msg(wpa_s, MSG_INFO, WPA_CTRL_REQ "%s-%d:%s needed for SSID %s",
1000
0
    field_name, ssid->id, txt,
1001
0
    wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
1002
0
}
1003
1004
1005
#ifdef IEEE8021X_EAPOL
1006
#if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
1007
static void wpa_supplicant_eap_param_needed(void *ctx,
1008
              enum wpa_ctrl_req_type field,
1009
              const char *default_txt)
1010
0
{
1011
0
  struct wpa_supplicant *wpa_s = ctx;
1012
0
  struct wpa_ssid *ssid = wpa_s->current_ssid;
1013
0
  const char *field_name, *txt = NULL;
1014
1015
0
  if (ssid == NULL)
1016
0
    return;
1017
1018
0
  if (field == WPA_CTRL_REQ_EXT_CERT_CHECK)
1019
0
    ssid->eap.pending_ext_cert_check = PENDING_CHECK;
1020
0
  wpas_notify_network_request(wpa_s, ssid, field, default_txt);
1021
1022
0
  field_name = wpa_supplicant_ctrl_req_to_string(field, default_txt,
1023
0
                   &txt);
1024
0
  if (field_name == NULL) {
1025
0
    wpa_printf(MSG_WARNING, "Unhandled EAP param %d needed",
1026
0
         field);
1027
0
    return;
1028
0
  }
1029
1030
0
  wpas_notify_eap_status(wpa_s, "eap parameter needed", field_name);
1031
1032
0
  wpas_send_ctrl_req(wpa_s, ssid, field_name, txt);
1033
0
}
1034
#else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
1035
#define wpa_supplicant_eap_param_needed NULL
1036
#endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
1037
1038
1039
#ifdef CONFIG_EAP_PROXY
1040
1041
static void wpa_supplicant_eap_proxy_cb(void *ctx)
1042
{
1043
  struct wpa_supplicant *wpa_s = ctx;
1044
  size_t len;
1045
1046
  wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, -1,
1047
                 wpa_s->imsi, &len);
1048
  if (wpa_s->mnc_len > 0) {
1049
    wpa_s->imsi[len] = '\0';
1050
    wpa_printf(MSG_DEBUG, "eap_proxy: IMSI %s (MNC length %d)",
1051
         wpa_s->imsi, wpa_s->mnc_len);
1052
  } else {
1053
    wpa_printf(MSG_DEBUG, "eap_proxy: IMSI not available");
1054
  }
1055
}
1056
1057
1058
static void wpa_sm_sim_state_error_handler(struct wpa_supplicant *wpa_s)
1059
{
1060
  int i;
1061
  struct wpa_ssid *ssid;
1062
  const struct eap_method_type *eap_methods;
1063
1064
  if (!wpa_s->conf)
1065
    return;
1066
1067
  for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
1068
    eap_methods = ssid->eap.eap_methods;
1069
    if (!eap_methods)
1070
      continue;
1071
1072
    for (i = 0; eap_methods[i].method != EAP_TYPE_NONE; i++) {
1073
      if (eap_methods[i].vendor == EAP_VENDOR_IETF &&
1074
          (eap_methods[i].method == EAP_TYPE_SIM ||
1075
           eap_methods[i].method == EAP_TYPE_AKA ||
1076
           eap_methods[i].method == EAP_TYPE_AKA_PRIME)) {
1077
        wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
1078
        break;
1079
      }
1080
    }
1081
  }
1082
}
1083
1084
1085
static void
1086
wpa_supplicant_eap_proxy_notify_sim_status(void *ctx,
1087
             enum eap_proxy_sim_state sim_state)
1088
{
1089
  struct wpa_supplicant *wpa_s = ctx;
1090
1091
  wpa_printf(MSG_DEBUG, "eap_proxy: SIM card status %u", sim_state);
1092
  switch (sim_state) {
1093
  case SIM_STATE_ERROR:
1094
    wpa_sm_sim_state_error_handler(wpa_s);
1095
    break;
1096
  default:
1097
    wpa_printf(MSG_DEBUG, "eap_proxy: SIM card status unknown");
1098
    break;
1099
  }
1100
}
1101
1102
#endif /* CONFIG_EAP_PROXY */
1103
1104
1105
static void wpa_supplicant_port_cb(void *ctx, int authorized)
1106
0
{
1107
0
  struct wpa_supplicant *wpa_s = ctx;
1108
#ifdef CONFIG_AP
1109
  if (wpa_s->ap_iface) {
1110
    wpa_printf(MSG_DEBUG, "AP mode active - skip EAPOL Supplicant "
1111
         "port status: %s",
1112
         authorized ? "Authorized" : "Unauthorized");
1113
    return;
1114
  }
1115
#endif /* CONFIG_AP */
1116
0
  wpa_printf(MSG_DEBUG, "EAPOL: Supplicant port status: %s",
1117
0
       authorized ? "Authorized" : "Unauthorized");
1118
0
  wpa_drv_set_supp_port(wpa_s, authorized);
1119
0
}
1120
1121
1122
static void wpa_supplicant_cert_cb(void *ctx, struct tls_cert_data *cert,
1123
           const char *cert_hash)
1124
0
{
1125
0
  struct wpa_supplicant *wpa_s = ctx;
1126
1127
0
  wpas_notify_certification(wpa_s, cert, cert_hash);
1128
0
}
1129
1130
1131
static void wpa_supplicant_status_cb(void *ctx, const char *status,
1132
             const char *parameter)
1133
0
{
1134
0
  struct wpa_supplicant *wpa_s = ctx;
1135
1136
0
  wpas_notify_eap_status(wpa_s, status, parameter);
1137
0
}
1138
1139
1140
static void wpa_supplicant_eap_error_cb(void *ctx, int error_code)
1141
0
{
1142
0
  struct wpa_supplicant *wpa_s = ctx;
1143
1144
0
  wpas_notify_eap_error(wpa_s, error_code);
1145
0
}
1146
1147
1148
static int wpa_supplicant_eap_auth_start_cb(void *ctx)
1149
0
{
1150
0
  struct wpa_supplicant *wpa_s = ctx;
1151
1152
0
  if (!wpa_s->new_connection && wpa_s->deny_ptk0_rekey &&
1153
0
      !wpa_sm_ext_key_id_active(wpa_s->wpa)) {
1154
0
    wpa_msg(wpa_s, MSG_INFO,
1155
0
      "WPA: PTK0 rekey not allowed, reconnecting");
1156
0
    wpa_supplicant_reconnect(wpa_s);
1157
0
    return -1;
1158
0
  }
1159
0
  return 0;
1160
0
}
1161
1162
1163
static void wpa_supplicant_set_anon_id(void *ctx, const u8 *id, size_t len)
1164
0
{
1165
0
  struct wpa_supplicant *wpa_s = ctx;
1166
0
  char *str;
1167
0
  int res;
1168
1169
0
  wpa_hexdump_ascii(MSG_DEBUG, "EAP method updated anonymous_identity",
1170
0
        id, len);
1171
1172
0
  if (wpa_s->current_ssid == NULL)
1173
0
    return;
1174
1175
0
  if (id == NULL) {
1176
0
    if (wpa_config_set(wpa_s->current_ssid, "anonymous_identity",
1177
0
           "NULL", 0) < 0)
1178
0
      return;
1179
0
  } else {
1180
0
    str = os_malloc(len * 2 + 1);
1181
0
    if (str == NULL)
1182
0
      return;
1183
0
    wpa_snprintf_hex(str, len * 2 + 1, id, len);
1184
0
    res = wpa_config_set(wpa_s->current_ssid, "anonymous_identity",
1185
0
             str, 0);
1186
0
    os_free(str);
1187
0
    if (res < 0)
1188
0
      return;
1189
0
  }
1190
1191
0
  if (wpa_s->conf->update_config) {
1192
0
    res = wpa_config_write(wpa_s->confname, wpa_s->conf);
1193
0
    if (res) {
1194
0
      wpa_printf(MSG_DEBUG, "Failed to update config after "
1195
0
           "anonymous_id update");
1196
0
    }
1197
0
  }
1198
0
}
1199
1200
1201
static bool wpas_encryption_required(void *ctx)
1202
0
{
1203
0
  struct wpa_supplicant *wpa_s = ctx;
1204
1205
0
  return wpa_s->wpa &&
1206
0
    wpa_sm_has_ptk_installed(wpa_s->wpa) &&
1207
0
    wpa_sm_pmf_enabled(wpa_s->wpa);
1208
0
}
1209
1210
#endif /* IEEE8021X_EAPOL */
1211
1212
1213
int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
1214
0
{
1215
0
#ifdef IEEE8021X_EAPOL
1216
0
  struct eapol_ctx *ctx;
1217
0
  ctx = os_zalloc(sizeof(*ctx));
1218
0
  if (ctx == NULL) {
1219
0
    wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context.");
1220
0
    return -1;
1221
0
  }
1222
1223
0
  ctx->ctx = wpa_s;
1224
0
  ctx->msg_ctx = wpa_s;
1225
0
  ctx->eapol_send_ctx = wpa_s;
1226
0
  ctx->preauth = 0;
1227
0
  ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done;
1228
0
  ctx->eapol_send = wpa_supplicant_eapol_send;
1229
#ifdef CONFIG_WEP
1230
  ctx->set_wep_key = wpa_eapol_set_wep_key;
1231
#endif /* CONFIG_WEP */
1232
0
#ifndef CONFIG_NO_CONFIG_BLOBS
1233
0
  ctx->set_config_blob = wpa_supplicant_set_config_blob;
1234
0
  ctx->get_config_blob = wpa_supplicant_get_config_blob;
1235
0
#endif /* CONFIG_NO_CONFIG_BLOBS */
1236
0
  ctx->aborted_cached = wpa_supplicant_aborted_cached;
1237
0
#ifndef CONFIG_OPENSC_ENGINE_PATH
1238
0
  ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path;
1239
0
#endif /* CONFIG_OPENSC_ENGINE_PATH */
1240
0
#ifndef CONFIG_PKCS11_ENGINE_PATH
1241
0
  ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
1242
0
#endif /* CONFIG_PKCS11_ENGINE_PATH */
1243
0
#ifndef CONFIG_PKCS11_MODULE_PATH
1244
0
  ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
1245
0
#endif /* CONFIG_PKCS11_MODULE_PATH */
1246
0
  ctx->openssl_ciphers = wpa_s->conf->openssl_ciphers;
1247
0
  ctx->wps = wpa_s->wps;
1248
0
  ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
1249
#ifdef CONFIG_EAP_PROXY
1250
  ctx->eap_proxy_cb = wpa_supplicant_eap_proxy_cb;
1251
  ctx->eap_proxy_notify_sim_status =
1252
    wpa_supplicant_eap_proxy_notify_sim_status;
1253
#endif /* CONFIG_EAP_PROXY */
1254
0
  ctx->port_cb = wpa_supplicant_port_cb;
1255
0
  ctx->cb = wpa_supplicant_eapol_cb;
1256
0
  ctx->cert_cb = wpa_supplicant_cert_cb;
1257
0
  ctx->cert_in_cb = wpa_s->conf->cert_in_cb;
1258
0
  ctx->status_cb = wpa_supplicant_status_cb;
1259
0
  ctx->eap_error_cb = wpa_supplicant_eap_error_cb;
1260
0
  ctx->confirm_auth_cb = wpa_supplicant_eap_auth_start_cb;
1261
0
  ctx->set_anon_id = wpa_supplicant_set_anon_id;
1262
0
  ctx->encryption_required = wpas_encryption_required;
1263
0
  ctx->cb_ctx = wpa_s;
1264
0
  wpa_s->eapol = eapol_sm_init(ctx);
1265
0
  if (wpa_s->eapol == NULL) {
1266
0
    os_free(ctx);
1267
0
    wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state "
1268
0
         "machines.");
1269
0
    return -1;
1270
0
  }
1271
0
#endif /* IEEE8021X_EAPOL */
1272
1273
0
  return 0;
1274
0
}
1275
1276
1277
#ifndef CONFIG_NO_WPA
1278
1279
static void wpa_supplicant_set_rekey_offload(void *ctx,
1280
               const u8 *kek, size_t kek_len,
1281
               const u8 *kck, size_t kck_len,
1282
               const u8 *replay_ctr)
1283
0
{
1284
0
  struct wpa_supplicant *wpa_s = ctx;
1285
1286
0
  wpa_drv_set_rekey_info(wpa_s, kek, kek_len, kck, kck_len, replay_ctr);
1287
0
}
1288
1289
1290
static int wpa_supplicant_key_mgmt_set_pmk(void *ctx, const u8 *pmk,
1291
             size_t pmk_len)
1292
0
{
1293
0
  struct wpa_supplicant *wpa_s = ctx;
1294
1295
0
  if (wpa_s->conf->key_mgmt_offload &&
1296
0
      (wpa_s->drv_flags & WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD))
1297
0
    return wpa_drv_set_key(wpa_s, -1, 0, NULL, 0, 0,
1298
0
               NULL, 0, pmk, pmk_len, KEY_FLAG_PMK);
1299
0
  else
1300
0
    return 0;
1301
0
}
1302
1303
1304
static void wpa_supplicant_fils_hlp_rx(void *ctx, const u8 *dst, const u8 *src,
1305
               const u8 *pkt, size_t pkt_len)
1306
0
{
1307
0
  struct wpa_supplicant *wpa_s = ctx;
1308
0
  char *hex;
1309
0
  size_t hexlen;
1310
1311
0
  hexlen = pkt_len * 2 + 1;
1312
0
  hex = os_malloc(hexlen);
1313
0
  if (!hex)
1314
0
    return;
1315
0
  wpa_snprintf_hex(hex, hexlen, pkt, pkt_len);
1316
0
  wpa_msg(wpa_s, MSG_INFO, FILS_HLP_RX "dst=" MACSTR " src=" MACSTR
1317
0
    " frame=%s", MAC2STR(dst), MAC2STR(src), hex);
1318
0
  os_free(hex);
1319
0
}
1320
1321
1322
static int wpa_supplicant_channel_info(void *_wpa_s,
1323
               struct wpa_channel_info *ci)
1324
0
{
1325
0
  struct wpa_supplicant *wpa_s = _wpa_s;
1326
1327
0
  return wpa_drv_channel_info(wpa_s, ci);
1328
0
}
1329
1330
1331
static void disable_wpa_wpa2(struct wpa_ssid *ssid)
1332
0
{
1333
0
  ssid->proto &= ~WPA_PROTO_WPA;
1334
0
  ssid->proto |= WPA_PROTO_RSN;
1335
0
  ssid->key_mgmt &= ~(WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_FT_PSK |
1336
0
          WPA_KEY_MGMT_PSK_SHA256);
1337
0
  ssid->group_cipher &= ~WPA_CIPHER_TKIP;
1338
0
  if (!(ssid->group_cipher & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
1339
0
            WPA_CIPHER_GCMP_256 | WPA_CIPHER_CCMP_256)))
1340
0
    ssid->group_cipher |= WPA_CIPHER_CCMP;
1341
0
  ssid->ieee80211w = MGMT_FRAME_PROTECTION_REQUIRED;
1342
0
}
1343
1344
1345
void wpas_transition_disable(struct wpa_supplicant *wpa_s, u8 bitmap)
1346
0
{
1347
0
  struct wpa_ssid *ssid;
1348
0
  int changed = 0;
1349
1350
0
  wpa_msg(wpa_s, MSG_INFO, TRANSITION_DISABLE "%02x", bitmap);
1351
1352
0
  ssid = wpa_s->current_ssid;
1353
0
  if (!ssid)
1354
0
    return;
1355
1356
#ifdef CONFIG_SAE
1357
  if ((bitmap & TRANSITION_DISABLE_WPA3_PERSONAL) &&
1358
      wpa_key_mgmt_sae(wpa_s->key_mgmt) &&
1359
      wpa_key_mgmt_sae(ssid->key_mgmt) &&
1360
      (ssid->ieee80211w != MGMT_FRAME_PROTECTION_REQUIRED ||
1361
       (ssid->group_cipher & WPA_CIPHER_TKIP))) {
1362
    wpa_printf(MSG_DEBUG,
1363
         "WPA3-Personal transition mode disabled based on AP notification");
1364
    disable_wpa_wpa2(ssid);
1365
    changed = 1;
1366
  }
1367
1368
  if ((bitmap & TRANSITION_DISABLE_SAE_PK) &&
1369
      wpa_key_mgmt_sae(wpa_s->key_mgmt) &&
1370
#ifdef CONFIG_SME
1371
      wpa_s->sme.sae.state == SAE_ACCEPTED &&
1372
      wpa_s->sme.sae.pk &&
1373
#endif /* CONFIG_SME */
1374
      wpa_key_mgmt_sae(ssid->key_mgmt) &&
1375
      (ssid->sae_pk != SAE_PK_MODE_ONLY ||
1376
       ssid->ieee80211w != MGMT_FRAME_PROTECTION_REQUIRED ||
1377
       (ssid->group_cipher & WPA_CIPHER_TKIP))) {
1378
    wpa_printf(MSG_DEBUG,
1379
         "SAE-PK: SAE authentication without PK disabled based on AP notification");
1380
    disable_wpa_wpa2(ssid);
1381
    ssid->sae_pk = SAE_PK_MODE_ONLY;
1382
    changed = 1;
1383
  }
1384
#endif /* CONFIG_SAE */
1385
1386
0
  if ((bitmap & TRANSITION_DISABLE_WPA3_ENTERPRISE) &&
1387
0
      wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) &&
1388
0
      (ssid->key_mgmt & (WPA_KEY_MGMT_IEEE8021X |
1389
0
             WPA_KEY_MGMT_FT_IEEE8021X |
1390
0
             WPA_KEY_MGMT_IEEE8021X_SHA256 |
1391
0
             WPA_KEY_MGMT_IEEE8021X_SHA384)) &&
1392
0
      (ssid->ieee80211w != MGMT_FRAME_PROTECTION_REQUIRED ||
1393
0
       (ssid->group_cipher & WPA_CIPHER_TKIP))) {
1394
0
    disable_wpa_wpa2(ssid);
1395
0
    changed = 1;
1396
0
  }
1397
1398
0
  if ((bitmap & TRANSITION_DISABLE_ENHANCED_OPEN) &&
1399
0
      wpa_s->key_mgmt == WPA_KEY_MGMT_OWE &&
1400
0
      (ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
1401
0
      !ssid->owe_only) {
1402
0
    ssid->owe_only = 1;
1403
0
    changed = 1;
1404
0
  }
1405
1406
0
  if (!changed)
1407
0
    return;
1408
1409
0
#ifndef CONFIG_NO_CONFIG_WRITE
1410
0
  if (wpa_s->conf->update_config &&
1411
0
      wpa_config_write(wpa_s->confname, wpa_s->conf))
1412
0
    wpa_printf(MSG_DEBUG, "Failed to update configuration");
1413
0
#endif /* CONFIG_NO_CONFIG_WRITE */
1414
0
}
1415
1416
1417
static void wpa_supplicant_transition_disable(void *_wpa_s, u8 bitmap)
1418
0
{
1419
0
  struct wpa_supplicant *wpa_s = _wpa_s;
1420
0
  wpas_transition_disable(wpa_s, bitmap);
1421
0
}
1422
1423
1424
static void wpa_supplicant_store_ptk(void *ctx, const u8 *addr, int cipher,
1425
             u32 life_time, const struct wpa_ptk *ptk)
1426
0
{
1427
0
  struct wpa_supplicant *wpa_s = ctx;
1428
1429
0
  ptksa_cache_add(wpa_s->ptksa, wpa_s->own_addr, addr, cipher, life_time,
1430
0
      ptk, NULL, NULL, 0, 0);
1431
0
}
1432
1433
1434
#ifdef CONFIG_PASN
1435
static int wpa_supplicant_set_ltf_keyseed(void *_wpa_s, const u8 *own_addr,
1436
            const u8 *peer_addr,
1437
            size_t ltf_keyseed_len,
1438
            const u8 *ltf_keyseed)
1439
{
1440
  struct wpa_supplicant *wpa_s = _wpa_s;
1441
1442
  return wpa_drv_set_secure_ranging_ctx(wpa_s, own_addr, peer_addr, 0, 0,
1443
                NULL, ltf_keyseed_len,
1444
                ltf_keyseed, 0);
1445
}
1446
#endif /* CONFIG_PASN */
1447
1448
1449
static void
1450
wpa_supplicant_notify_pmksa_cache_entry(void *_wpa_s,
1451
          struct rsn_pmksa_cache_entry *entry)
1452
0
{
1453
0
  struct wpa_supplicant *wpa_s = _wpa_s;
1454
1455
0
  wpas_notify_pmk_cache_added(wpa_s, entry);
1456
0
}
1457
1458
1459
static void wpa_supplicant_ssid_verified(void *_wpa_s)
1460
0
{
1461
0
  struct wpa_supplicant *wpa_s = _wpa_s;
1462
1463
0
  wpa_s->ssid_verified = true;
1464
0
  wpa_msg(wpa_s, MSG_INFO, "RSN: SSID matched expected value");
1465
0
}
1466
1467
1468
static void wpa_supplicant_sae_pw_id_change(void *_wpa_s,
1469
              struct wpabuf_array *wa)
1470
0
{
1471
0
  struct wpa_supplicant *wpa_s = _wpa_s;
1472
0
  struct wpa_ssid *ssid = wpa_s->current_ssid;
1473
1474
0
  wpa_msg(wpa_s, MSG_INFO, "RSN: Received %u SAE Password Identifier(s)",
1475
0
    wa->num);
1476
0
  if (!ssid) {
1477
0
    wpabuf_array_free(wa);
1478
0
    return;
1479
0
  }
1480
1481
0
  wpabuf_array_free(ssid->alt_sae_password_ids);
1482
0
  ssid->alt_sae_password_ids = wa;
1483
1484
0
#ifndef CONFIG_NO_CONFIG_WRITE
1485
0
  if (wpa_s->conf->update_config &&
1486
0
      wpa_config_write(wpa_s->confname, wpa_s->conf))
1487
0
    wpa_printf(MSG_DEBUG, "SAE: Failed to update configuration");
1488
0
#endif /* CONFIG_NO_CONFIG_WRITE */
1489
0
}
1490
1491
#endif /* CONFIG_NO_WPA */
1492
1493
1494
int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
1495
0
{
1496
0
#ifndef CONFIG_NO_WPA
1497
0
  struct wpa_sm_ctx *ctx;
1498
1499
0
  wpa_s->ptksa = ptksa_cache_init();
1500
0
  if (!wpa_s->ptksa) {
1501
0
    wpa_printf(MSG_ERROR, "Failed to allocate PTKSA");
1502
0
    return -1;
1503
0
  }
1504
1505
0
  ctx = os_zalloc(sizeof(*ctx));
1506
0
  if (ctx == NULL) {
1507
0
    wpa_printf(MSG_ERROR, "Failed to allocate WPA context.");
1508
1509
0
    ptksa_cache_deinit(wpa_s->ptksa);
1510
0
    wpa_s->ptksa = NULL;
1511
1512
0
    return -1;
1513
0
  }
1514
1515
0
  ctx->ctx = wpa_s;
1516
0
  ctx->msg_ctx = wpa_s;
1517
0
  ctx->set_state = _wpa_supplicant_set_state;
1518
0
  ctx->get_state = _wpa_supplicant_get_state;
1519
0
  ctx->deauthenticate = _wpa_supplicant_deauthenticate;
1520
0
  ctx->reconnect = _wpa_supplicant_reconnect;
1521
0
  ctx->set_key = wpa_supplicant_set_key;
1522
0
  ctx->get_network_ctx = wpa_supplicant_get_network_ctx;
1523
0
  ctx->get_bssid = wpa_supplicant_get_bssid;
1524
0
  ctx->ether_send = _wpa_ether_send;
1525
0
  ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie;
1526
0
  ctx->alloc_eapol = _wpa_alloc_eapol;
1527
0
  ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout;
1528
0
  ctx->add_pmkid = wpa_supplicant_add_pmkid;
1529
0
  ctx->remove_pmkid = wpa_supplicant_remove_pmkid;
1530
0
#ifndef CONFIG_NO_CONFIG_BLOBS
1531
0
  ctx->set_config_blob = wpa_supplicant_set_config_blob;
1532
0
  ctx->get_config_blob = wpa_supplicant_get_config_blob;
1533
0
#endif /* CONFIG_NO_CONFIG_BLOBS */
1534
0
  ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection;
1535
#ifdef CONFIG_IEEE80211R
1536
  ctx->update_ft_ies = wpa_supplicant_update_ft_ies;
1537
  ctx->send_ft_action = wpa_supplicant_send_ft_action;
1538
  ctx->mark_authenticated = wpa_supplicant_mark_authenticated;
1539
#endif /* CONFIG_IEEE80211R */
1540
#ifdef CONFIG_TDLS
1541
  ctx->tdls_get_capa = wpa_supplicant_tdls_get_capa;
1542
  ctx->send_tdls_mgmt = wpa_supplicant_send_tdls_mgmt;
1543
  ctx->tdls_oper = wpa_supplicant_tdls_oper;
1544
  ctx->tdls_peer_addset = wpa_supplicant_tdls_peer_addset;
1545
  ctx->tdls_enable_channel_switch =
1546
    wpa_supplicant_tdls_enable_channel_switch;
1547
  ctx->tdls_disable_channel_switch =
1548
    wpa_supplicant_tdls_disable_channel_switch;
1549
#endif /* CONFIG_TDLS */
1550
0
  ctx->set_rekey_offload = wpa_supplicant_set_rekey_offload;
1551
0
  ctx->key_mgmt_set_pmk = wpa_supplicant_key_mgmt_set_pmk;
1552
0
  ctx->fils_hlp_rx = wpa_supplicant_fils_hlp_rx;
1553
0
  ctx->channel_info = wpa_supplicant_channel_info;
1554
0
  ctx->transition_disable = wpa_supplicant_transition_disable;
1555
0
  ctx->store_ptk = wpa_supplicant_store_ptk;
1556
#ifdef CONFIG_PASN
1557
  ctx->set_ltf_keyseed = wpa_supplicant_set_ltf_keyseed;
1558
#endif /* CONFIG_PASN */
1559
0
  ctx->notify_pmksa_cache_entry = wpa_supplicant_notify_pmksa_cache_entry;
1560
0
  ctx->ssid_verified = wpa_supplicant_ssid_verified;
1561
0
  ctx->sae_pw_id_change = wpa_supplicant_sae_pw_id_change;
1562
1563
0
  wpa_s->wpa = wpa_sm_init(ctx);
1564
0
  if (wpa_s->wpa == NULL) {
1565
0
    wpa_printf(MSG_ERROR,
1566
0
         "Failed to initialize WPA state machine");
1567
0
    os_free(ctx);
1568
0
    ptksa_cache_deinit(wpa_s->ptksa);
1569
0
    wpa_s->ptksa = NULL;
1570
0
    return -1;
1571
0
  }
1572
0
#endif /* CONFIG_NO_WPA */
1573
1574
0
  return 0;
1575
0
}
1576
1577
1578
void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
1579
          struct wpa_ssid *ssid)
1580
0
{
1581
0
  struct rsn_supp_config conf;
1582
0
  if (ssid) {
1583
0
    os_memset(&conf, 0, sizeof(conf));
1584
0
    conf.network_ctx = ssid;
1585
0
    conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
1586
0
#ifdef IEEE8021X_EAPOL
1587
0
    conf.proactive_key_caching = ssid->proactive_key_caching < 0 ?
1588
0
      wpa_s->conf->okc : ssid->proactive_key_caching;
1589
0
    conf.eap_workaround = ssid->eap_workaround;
1590
0
    conf.eap_conf_ctx = &ssid->eap;
1591
0
#endif /* IEEE8021X_EAPOL */
1592
0
    conf.ssid = ssid->ssid;
1593
0
    conf.ssid_len = ssid->ssid_len;
1594
0
    conf.wpa_ptk_rekey = ssid->wpa_ptk_rekey;
1595
0
    conf.wpa_deny_ptk0_rekey = ssid->wpa_deny_ptk0_rekey;
1596
0
    conf.owe_ptk_workaround = ssid->owe_ptk_workaround;
1597
#ifdef CONFIG_P2P
1598
    if (ssid->p2p_group && wpa_s->current_bss &&
1599
        !wpa_s->p2p_disable_ip_addr_req) {
1600
      struct wpabuf *p2p;
1601
      p2p = wpa_bss_get_vendor_ie_multi(wpa_s->current_bss,
1602
                P2P_IE_VENDOR_TYPE);
1603
      if (p2p) {
1604
        u8 group_capab;
1605
        group_capab = p2p_get_group_capab(p2p);
1606
        if (group_capab &
1607
            P2P_GROUP_CAPAB_IP_ADDR_ALLOCATION)
1608
          conf.p2p = 1;
1609
        wpabuf_free(p2p);
1610
      }
1611
    }
1612
#endif /* CONFIG_P2P */
1613
0
    conf.wpa_rsc_relaxation = wpa_s->conf->wpa_rsc_relaxation;
1614
#ifdef CONFIG_FILS
1615
    if (wpa_key_mgmt_fils(wpa_s->key_mgmt))
1616
      conf.fils_cache_id =
1617
        wpa_bss_get_fils_cache_id(wpa_s->current_bss);
1618
#endif /* CONFIG_FILS */
1619
0
    if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_BEACON_PROTECTION) ||
1620
0
        (wpa_s->drv_flags2 &
1621
0
         WPA_DRIVER_FLAGS2_BEACON_PROTECTION_CLIENT))
1622
0
      conf.beacon_prot = ssid->beacon_prot;
1623
1624
#ifdef CONFIG_PASN
1625
#ifdef CONFIG_TESTING_OPTIONS
1626
    conf.force_kdk_derivation = wpa_s->conf->force_kdk_derivation;
1627
#endif /* CONFIG_TESTING_OPTIONS */
1628
#endif /* CONFIG_PASN */
1629
0
  }
1630
0
  wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL);
1631
0
}