2016-11-04 02:12:21 -04:00
|
|
|
/*
|
|
|
|
* wpa_supplicant - WPA definitions
|
|
|
|
* Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of BSD
|
|
|
|
* license.
|
|
|
|
*
|
|
|
|
* See README and COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WPA_H
|
|
|
|
#define WPA_H
|
|
|
|
|
2019-08-08 01:27:22 -04:00
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
2020-07-21 01:07:34 -04:00
|
|
|
#include "esp32/rom/ets_sys.h" // will be removed in idf v5.0
|
2020-01-16 22:47:08 -05:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
|
|
#include "esp32s2/rom/ets_sys.h"
|
2019-08-08 01:27:22 -04:00
|
|
|
#endif
|
2018-08-13 04:37:56 -04:00
|
|
|
#include "utils/common.h"
|
|
|
|
#include "common/defs.h"
|
|
|
|
#include "common/wpa_common.h"
|
2019-11-12 01:05:08 -05:00
|
|
|
#include "esp_wifi_types.h"
|
2018-08-13 04:37:56 -04:00
|
|
|
#include "esp_wifi_crypto_types.h"
|
|
|
|
#include "wpa_i.h"
|
2016-11-04 02:12:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
#define WPA_SM_STATE(_sm) ((_sm)->wpa_state)
|
|
|
|
|
|
|
|
struct wpa_sm;
|
|
|
|
|
|
|
|
int wpa_sm_rx_eapol(u8 *src_addr, u8 *buf, u32 len);
|
2019-09-19 07:23:56 -04:00
|
|
|
bool wpa_sta_is_cur_pmksa_set(void);
|
2018-08-13 04:37:56 -04:00
|
|
|
bool wpa_sta_in_4way_handshake(void);
|
2020-07-08 06:26:05 -04:00
|
|
|
bool wpa_sta_cur_pmksa_matches_akm(void);
|
2016-11-04 02:12:21 -04:00
|
|
|
|
2018-08-13 04:37:56 -04:00
|
|
|
#define WPA_ASSERT assert
|
2016-11-04 02:12:21 -04:00
|
|
|
|
|
|
|
struct l2_ethhdr {
|
|
|
|
u8 h_dest[ETH_ALEN];
|
|
|
|
u8 h_source[ETH_ALEN];
|
|
|
|
be16 h_proto;
|
|
|
|
} STRUCT_PACKED;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set_key - Configure encryption key
|
|
|
|
* @ifname: Interface name (for multi-SSID/VLAN support)
|
|
|
|
* @priv: private driver interface data
|
|
|
|
* @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
|
|
|
|
* %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
|
|
|
|
* %WPA_ALG_NONE clears the key.
|
|
|
|
* @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
|
|
|
|
* broadcast/default keys
|
|
|
|
* @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
|
|
|
|
* IGTK
|
|
|
|
* @set_tx: configure this key as the default Tx key (only used when
|
|
|
|
* driver does not support separate unicast/individual key
|
|
|
|
* @seq: sequence number/packet number, seq_len octets, the next
|
|
|
|
* packet number to be used for in replay protection; configured
|
|
|
|
* for Rx keys (in most cases, this is only used with broadcast
|
|
|
|
* keys and set to zero for unicast keys)
|
|
|
|
* @seq_len: length of the seq, depends on the algorithm:
|
|
|
|
* TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
|
|
|
|
* @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
|
|
|
|
* 8-byte Rx Mic Key
|
|
|
|
* @key_len: length of the key buffer in octets (WEP: 5 or 13,
|
|
|
|
* TKIP: 32, CCMP: 16, IGTK: 16)
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*
|
|
|
|
* Configure the given key for the kernel driver. If the driver
|
|
|
|
* supports separate individual keys (4 default keys + 1 individual),
|
|
|
|
* addr can be used to determine whether the key is default or
|
|
|
|
* individual. If only 4 keys are supported, the default key with key
|
|
|
|
* index 0 is used as the individual key. STA must be configured to use
|
|
|
|
* it as the default Tx key (set_tx is set) and accept Rx for all the
|
|
|
|
* key indexes. In most cases, WPA uses only key indexes 1 and 2 for
|
|
|
|
* broadcast keys, so key index 0 is available for this kind of
|
|
|
|
* configuration.
|
|
|
|
*
|
|
|
|
* Please note that TKIP keys include separate TX and RX MIC keys and
|
|
|
|
* some drivers may expect them in different order than wpa_supplicant
|
|
|
|
* is using. If the TX/RX keys are swapped, all TKIP encrypted packets
|
|
|
|
* will tricker Michael MIC errors. This can be fixed by changing the
|
|
|
|
* order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
|
|
|
|
* in driver_*.c set_key() implementation, see driver_ndis.c for an
|
|
|
|
* example on how this can be done.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* send_eapol - Optional function for sending EAPOL packets
|
|
|
|
* @priv: private driver interface data
|
|
|
|
* @dest: Destination MAC address
|
|
|
|
* @proto: Ethertype
|
|
|
|
* @data: EAPOL packet starting with IEEE 802.1X header
|
|
|
|
* @data_len: Size of the EAPOL packet
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*
|
|
|
|
* This optional function can be used to override l2_packet operations
|
|
|
|
* with driver specific functionality. If this function pointer is set,
|
|
|
|
* l2_packet module is not used at all and the driver interface code is
|
|
|
|
* responsible for receiving and sending all EAPOL packets. The
|
|
|
|
* received EAPOL packets are sent to core code with EVENT_EAPOL_RX
|
|
|
|
* event. The driver interface is required to implement get_mac_addr()
|
|
|
|
* handler if send_eapol() is used.
|
|
|
|
*/
|
|
|
|
|
2019-12-26 02:25:24 -05:00
|
|
|
#define KEYENTRY_TABLE_MAP(key_entry_valid) ((key_entry_valid)%5)
|
2016-11-04 02:12:21 -04:00
|
|
|
|
2018-08-13 04:37:56 -04:00
|
|
|
void pp_michael_mic_failure(u16 isunicast);
|
|
|
|
|
2016-11-04 02:12:21 -04:00
|
|
|
void wpa_sm_set_state(enum wpa_states state);
|
|
|
|
|
2018-04-19 23:33:04 -04:00
|
|
|
char * dup_binstr(const void *src, size_t len);
|
|
|
|
|
2020-01-20 01:47:53 -05:00
|
|
|
void wpa_set_pmk(uint8_t *pmk, const u8 *pmkid, bool cache_pmksa);
|
2018-08-13 04:37:56 -04:00
|
|
|
|
|
|
|
int wpa_hook_init(void);
|
|
|
|
|
|
|
|
bool wpa_hook_deinit(void);
|
|
|
|
|
|
|
|
char * dup_binstr(const void *src, size_t len);
|
|
|
|
|
|
|
|
int wpa_michael_mic_failure(u16 isunicast);
|
|
|
|
|
2020-11-05 23:00:07 -05:00
|
|
|
wifi_cipher_type_t cipher_type_map_supp_to_public(unsigned cipher);
|
2019-11-12 01:05:08 -05:00
|
|
|
|
2020-11-05 23:00:07 -05:00
|
|
|
unsigned cipher_type_map_public_to_supp(wifi_cipher_type_t cipher);
|
2019-11-12 01:05:08 -05:00
|
|
|
|
2020-01-20 01:47:53 -05:00
|
|
|
void wpa_sta_clear_curr_pmksa(void);
|
|
|
|
|
2016-11-04 02:12:21 -04:00
|
|
|
#endif /* WPA_H */
|