Merge branch 'bugfix/esp_supplicant_format' into 'master'

fix(wifi): update coding format of WiFi files

See merge request espressif/esp-idf!28079
pull/13651/head
Jiang Jiang Jian 2024-04-16 15:23:21 +08:00
commit 8f4f21580a
60 zmienionych plików z 3805 dodań i 3861 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
[codespell]
skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb
skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb,components/wpa_supplicant/*,components/esp_wifi/*
ignore-words-list = ser,dout,rsource,fram,inout,shs,ans,aci,unstall,unstalling,hart
write-changes = true

Wyświetl plik

@ -595,7 +595,6 @@ static void IRAM_ATTR esp_empty_wrapper(void)
}
static void esp_phy_enable_wrapper(void)
{
esp_phy_enable(PHY_MODEM_WIFI);

Wyświetl plik

@ -144,7 +144,6 @@ extern "C" {
#define MESH_ASSOC_FLAG_ROOTS_FOUND (0x20) /**< roots conflict is found, means that thre are at least two roots in the mesh network */
#define MESH_ASSOC_FLAG_ROOT_FIXED (0x40) /**< the root is fixed in the mesh network */
/**
* @brief Mesh PS (Power Save) duty cycle type
*/

Wyświetl plik

@ -15,7 +15,6 @@
*
*/
#ifndef __ESP_WIFI_INTERNAL_H__
#define __ESP_WIFI_INTERNAL_H__
@ -74,7 +73,6 @@ typedef enum {
#define WIFI_LOG_SUBMODULE_CONN (1<<2) /*logs related to connecting*/
#define WIFI_LOG_SUBMODULE_SCAN (1<<3) /*logs related to scanning*/
/**
* @brief Initialize Wi-Fi Driver
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
@ -215,7 +213,6 @@ esp_err_t esp_wifi_internal_wapi_deinit(void);
*/
esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free);
/**
* @brief The WiFi RX callback function
*
@ -539,7 +536,6 @@ void esp_wifi_power_domain_on(void);
*/
void esp_wifi_power_domain_off(void);
#if (CONFIG_FREERTOS_USE_TICKLESS_IDLE && SOC_PM_MODEM_RETENTION_BY_REGDMA)
/**
* @brief Get wifi mac sleep retention hardware context configuration and size

Wyświetl plik

@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
/* Notes about WiFi Programming
*
* WiFi programming model can be depicted as following picture:
@ -561,7 +560,6 @@ esp_err_t esp_wifi_scan_get_ap_record(wifi_ap_record_t *ap_record);
*/
esp_err_t esp_wifi_clear_ap_list(void);
/**
* @brief Get information of AP to which the device is associated with
*
@ -749,7 +747,6 @@ esp_err_t esp_wifi_set_country(const wifi_country_t *country);
*/
esp_err_t esp_wifi_get_country(wifi_country_t *country);
/**
* @brief Set MAC address of WiFi station, soft-AP or NAN interface.
*
@ -1115,7 +1112,6 @@ esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, b
*/
typedef void (* wifi_csi_cb_t)(void *ctx, wifi_csi_info_t *data);
/**
* @brief Register the RX callback function of CSI data.
*
@ -1194,7 +1190,6 @@ esp_err_t esp_wifi_set_ant_gpio(const wifi_ant_gpio_config_t *config) __attribut
*/
esp_err_t esp_wifi_get_ant_gpio(wifi_ant_gpio_config_t *config) __attribute__((deprecated("Please use esp_phy_get_ant_gpio instead")));
/**
* @brief Set antenna configuration
*

Wyświetl plik

@ -13,7 +13,6 @@
extern "C" {
#endif
#ifndef ESP_WIFI_MAX_CONN_NUM
// Number of maximum wifi connection may be undefined if we have no native wifi support on this target
// and at the same time there's no native interface injected by the wifi_remote component.

Wyświetl plik

@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_WIFI_CRYPTO_TYPES_H__
#define __ESP_WIFI_CRYPTO_TYPES_H__

Wyświetl plik

@ -15,7 +15,6 @@
extern "C" {
#endif
/**
* @brief Set up an individual TWT agreement (NegotiationType=0) or change TWT parameters of the existing TWT agreement
* - TWT Wake Interval = TWT Wake Interval Mantissa * (2 ^ TWT Wake Interval Exponent), unit: us

Wyświetl plik

@ -114,8 +114,7 @@ typedef enum {
/**
* @brief TWT setup config
*/
typedef struct
{
typedef struct {
wifi_twt_setup_cmds_t setup_cmd; /**< Indicates the type of TWT command */
uint16_t trigger : 1; /**< 1: a trigger-enabled TWT, 0: a non-trigger-enabled TWT */
uint16_t flow_type : 1; /**< 0: an announced TWT, 1: an unannounced TWT */

Wyświetl plik

@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_WIFI_TYPES_H__
#define __ESP_WIFI_TYPES_H__
@ -434,8 +433,7 @@ typedef enum {
/**
* @brief Operation Phymode
*/
typedef enum
{
typedef enum {
WIFI_PHY_MODE_LR, /**< PHY mode for Low Rate */
WIFI_PHY_MODE_11B, /**< PHY mode for 11b */
WIFI_PHY_MODE_11G, /**< PHY mode for 11g */
@ -472,7 +470,6 @@ typedef enum {
WIFI_PKT_MISC, /**< Other type, such as MIMO etc. 'buf' argument is wifi_promiscuous_pkt_t but the payload is zero length. */
} wifi_promiscuous_pkt_type_t;
#define WIFI_PROMIS_FILTER_MASK_ALL (0xFFFFFFFF) /**< filter all packets */
#define WIFI_PROMIS_FILTER_MASK_MGMT (1) /**< filter the packets with type of WIFI_PKT_MGMT */
#define WIFI_PROMIS_FILTER_MASK_CTRL (1<<1) /**< filter the packets with type of WIFI_PKT_CTRL */

Wyświetl plik

@ -105,7 +105,6 @@ typedef struct {
} wifi_csi_config_t;
#endif // !CONFIG_SOC_WIFI_HE_SUPPORT
/** @brief Payload passed to 'buf' parameter of promiscuous mode RX callback.
*/
typedef struct {

@ -1 +1 @@
Subproject commit 49c8e2d99d2dfc26e49b320327fb6df06dfc9722
Subproject commit 852cfcfa667356b2ae99052d6fbe5fdb587956eb

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -194,8 +194,7 @@ static void sc_ack_send_task(void *pvParameters)
goto _end;
}
}
}
else {
} else {
vTaskDelay((TickType_t)(100 / portTICK_PERIOD_MS));
}
}

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -298,7 +298,6 @@ esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif)
return disconnect_and_destroy(esp_netif);
}
//
// Object manipulation
//
@ -360,7 +359,6 @@ esp_err_t esp_netif_attach_wifi_nan(esp_netif_t *esp_netif)
}
#endif
//
// Default WiFi creation from user code
//

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -140,8 +140,7 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
wifi_rxcb_t rxcb = NULL;
esp_err_t ret;
switch (wifi_interface)
{
switch (wifi_interface) {
case WIFI_IF_STA:
rxcb = wifi_sta_receive;

Wyświetl plik

@ -43,7 +43,6 @@ void tearDown(void)
check_leak(before_free_32bit, after_free_32bit, "32BIT");
}
void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*
@ -24,7 +24,6 @@
#include "freertos/task.h"
#include "freertos/event_groups.h"
#ifndef TEST_SUFFIX_STR
#define TEST_SUFFIX_STR "_0000"
#endif
@ -34,7 +33,6 @@
#define TEST_DEFAULT_CHANNEL (6)
#define CONNECT_TIMEOUT_MS (8000)
#define GOT_IP_EVENT (1)
#define WIFI_DISCONNECT_EVENT (1<<1)
#define WIFI_STA_CONNECTED (1<<2)
@ -42,7 +40,6 @@
#define EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT 0x00000001
static const char* TAG = "test_wifi";
static uint32_t wifi_event_handler_flag;
static esp_netif_t* s_ap_netif = NULL;
@ -87,7 +84,6 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
return;
}
static void ip_event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{
@ -131,7 +127,6 @@ static esp_err_t event_deinit(void)
#define EMPH_STR(s) "****** "s" ******"
static void start_wifi_as_softap(void)
{
wifi_config_t w_config = {

Wyświetl plik

@ -38,7 +38,6 @@ void tearDown(void)
check_leak(before_free_32bit, after_free_32bit, "32BIT");
}
void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -34,7 +34,6 @@ TEST_CASE("wifi set country code", "[wifi_init]")
TEST_ESP_OK(esp_wifi_get_country(&country));
TEST_ASSERT(country.cc[0] == country_CN.cc[0] && country.cc[1] == country_CN.cc[1]);
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit"));
TEST_ESP_OK(esp_wifi_deinit());
@ -55,7 +54,6 @@ TEST_CASE("wifi set country code", "[wifi_init]")
TEST_ESP_OK(esp_wifi_get_country_code(&country_code_string[0]));
TEST_ASSERT(country_code_string[0] == country_code_string_CN[0] && country_code_string[1] == country_code_string_CN[1]);
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit"));
TEST_ESP_OK(esp_wifi_deinit());

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -15,7 +15,6 @@
#define EMPH_STR(s) "****** "s" ******"
static const char* TAG = "test_wifi_init";
static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)

Wyświetl plik

@ -83,8 +83,9 @@ static nan_ctx_t s_nan_ctx;
void esp_wifi_nan_get_ipv6_linklocal_from_mac(ip6_addr_t *ip6, uint8_t *mac_addr)
{
if (ip6 == NULL || mac_addr == NULL)
if (ip6 == NULL || mac_addr == NULL) {
return;
}
/* Link-local prefix. */
ip6->addr[0] = htonl(0xfe800000ul);
ip6->addr[1] = 0;

Wyświetl plik

@ -42,7 +42,6 @@ typedef struct {
bool fast_pac_format_binary; /**< Set to true for binary format PAC, false for ASCII format PAC */
} esp_eap_fast_config;
/**
* @brief Enable EAP authentication(WiFi Enterprise) for the station mode.
*
@ -61,7 +60,6 @@ typedef struct {
*/
esp_err_t esp_wifi_sta_enterprise_enable(void);
/**
* @brief Disable EAP authentication(WiFi Enterprise) for the station mode.
*

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

Wyświetl plik

@ -181,7 +181,6 @@ esp_err_t esp_wifi_ap_wps_disable(void);
*/
esp_err_t esp_wifi_ap_wps_start(const unsigned char *pin);
/**
* @}
*/

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -33,7 +33,6 @@ struct crypto_bignum *crypto_bignum_init(void)
return (struct crypto_bignum *)bn;
}
struct crypto_bignum *crypto_bignum_init_set(const u8 *buf, size_t len)
{
int ret = 0;
@ -50,7 +49,6 @@ cleanup:
return NULL;
}
struct crypto_bignum * crypto_bignum_init_uint(unsigned int val)
{
@ -65,14 +63,12 @@ struct crypto_bignum * crypto_bignum_init_uint(unsigned int val)
return (struct crypto_bignum *)bn;
}
void crypto_bignum_deinit(struct crypto_bignum *n, int clear)
{
mbedtls_mpi_free((mbedtls_mpi *)n);
os_free((mbedtls_mpi *)n);
}
int crypto_bignum_to_bin(const struct crypto_bignum *a,
u8 *buf, size_t buflen, size_t padlen)
{
@ -102,7 +98,6 @@ cleanup:
return ret;
}
int crypto_bignum_add(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -111,7 +106,6 @@ int crypto_bignum_add(const struct crypto_bignum *a,
-1 : 0;
}
int crypto_bignum_mod(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -119,7 +113,6 @@ int crypto_bignum_mod(const struct crypto_bignum *a,
return mbedtls_mpi_mod_mpi((mbedtls_mpi *) c, (const mbedtls_mpi *) a, (const mbedtls_mpi *) b) ? -1 : 0;
}
int crypto_bignum_exptmod(const struct crypto_bignum *a,
const struct crypto_bignum *b,
const struct crypto_bignum *c,
@ -129,7 +122,6 @@ int crypto_bignum_exptmod(const struct crypto_bignum *a,
}
int crypto_bignum_inverse(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -138,7 +130,6 @@ int crypto_bignum_inverse(const struct crypto_bignum *a,
(const mbedtls_mpi *) b) ? -1 : 0;
}
int crypto_bignum_sub(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -147,7 +138,6 @@ int crypto_bignum_sub(const struct crypto_bignum *a,
-1 : 0;
}
int crypto_bignum_div(const struct crypto_bignum *a,
const struct crypto_bignum *b,
struct crypto_bignum *c)
@ -156,7 +146,6 @@ int crypto_bignum_div(const struct crypto_bignum *a,
-1 : 0;
}
int crypto_bignum_mulmod(const struct crypto_bignum *a,
const struct crypto_bignum *b,
const struct crypto_bignum *c,
@ -183,7 +172,6 @@ int crypto_bignum_sqrmod(const struct crypto_bignum *a,
return res ? -1 : 0;
}
int crypto_bignum_rshift(const struct crypto_bignum *a, int n,
struct crypto_bignum *r)
{
@ -198,26 +186,22 @@ int crypto_bignum_rshift(const struct crypto_bignum *a, int n,
}
int crypto_bignum_cmp(const struct crypto_bignum *a,
const struct crypto_bignum *b)
{
return mbedtls_mpi_cmp_mpi((const mbedtls_mpi *) a, (const mbedtls_mpi *) b);
}
int crypto_bignum_bits(const struct crypto_bignum *a)
{
return mbedtls_mpi_bitlen((const mbedtls_mpi *) a);
}
int crypto_bignum_is_zero(const struct crypto_bignum *a)
{
return (mbedtls_mpi_cmp_int((const mbedtls_mpi *) a, 0) == 0);
}
int crypto_bignum_is_one(const struct crypto_bignum *a)
{
return (mbedtls_mpi_cmp_int((const mbedtls_mpi *) a, 1) == 0);
@ -300,11 +284,13 @@ int crypto_bignum_addmod(const struct crypto_bignum *a,
struct crypto_bignum *tmp = crypto_bignum_init();
int ret = -1;
if (mbedtls_mpi_add_mpi((mbedtls_mpi *) tmp, (const mbedtls_mpi *) a, (const mbedtls_mpi *) b) < 0)
if (mbedtls_mpi_add_mpi((mbedtls_mpi *) tmp, (const mbedtls_mpi *) a, (const mbedtls_mpi *) b) < 0) {
goto fail;
}
if (mbedtls_mpi_mod_mpi( (mbedtls_mpi *) d, (const mbedtls_mpi *) tmp, (const mbedtls_mpi *) c) < 0)
if (mbedtls_mpi_mod_mpi((mbedtls_mpi *) d, (const mbedtls_mpi *) tmp, (const mbedtls_mpi *) c) < 0) {
goto fail;
}
ret = 0;
fail:

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -78,7 +78,6 @@ struct crypto_ec *crypto_ec_init(int group)
return e;
}
void crypto_ec_deinit(struct crypto_ec *e)
{
if (e == NULL) {
@ -89,7 +88,6 @@ void crypto_ec_deinit(struct crypto_ec *e)
os_free(e);
}
struct crypto_ec_point *crypto_ec_point_init(struct crypto_ec *e)
{
mbedtls_ecp_point *pt;
@ -108,7 +106,6 @@ struct crypto_ec_point *crypto_ec_point_init(struct crypto_ec *e)
return (struct crypto_ec_point *) pt;
}
size_t crypto_ec_prime_len(struct crypto_ec *e)
{
return mbedtls_mpi_size(&e->group.P);
@ -119,7 +116,6 @@ size_t crypto_ec_order_len(struct crypto_ec *e)
return mbedtls_mpi_size(&e->group.N);
}
size_t crypto_ec_prime_len_bits(struct crypto_ec *e)
{
return mbedtls_mpi_bitlen(&e->group.P);
@ -149,19 +145,16 @@ const struct crypto_bignum *crypto_ec_get_prime(struct crypto_ec *e)
return (const struct crypto_bignum *) &e->group.P;
}
const struct crypto_bignum *crypto_ec_get_order(struct crypto_ec *e)
{
return (const struct crypto_bignum *) &e->group.N;
}
const struct crypto_bignum * crypto_ec_get_b(struct crypto_ec *e)
{
return (const struct crypto_bignum *) &e->group.B;
}
void crypto_ec_point_deinit(struct crypto_ec_point *p, int clear)
{
mbedtls_ecp_point_free((mbedtls_ecp_point *) p);
@ -244,7 +237,6 @@ cleanup:
return NULL;
}
int crypto_ec_point_add(struct crypto_ec *e, const struct crypto_ec_point *a,
const struct crypto_ec_point *b,
struct crypto_ec_point *c)
@ -262,7 +254,6 @@ cleanup:
return ret ? -1 : 0;
}
int crypto_ec_point_mul(struct crypto_ec *e, const struct crypto_ec_point *p,
const struct crypto_bignum *b,
struct crypto_ec_point *res)
@ -289,7 +280,6 @@ cleanup:
return ret ? -1 : 0;
}
/* Currently mbedtls does not have any function for inverse
* This function calculates inverse of a point.
* Set R = -P
@ -347,8 +337,9 @@ int crypto_ec_point_solve_y_coord(struct crypto_ec *e,
MBEDTLS_MPI_CHK(mbedtls_mpi_div_int(&temp, NULL, &temp, 4));
MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(y, y_sqr, &temp, &e->group.P, NULL));
if (y_bit != mbedtls_mpi_get_bit(y, 0))
if (y_bit != mbedtls_mpi_get_bit(y, 0)) {
MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(y, &e->group.P, y));
}
MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&((mbedtls_ecp_point*)p)->MBEDTLS_PRIVATE(X), (const mbedtls_mpi*) x));
MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&((mbedtls_ecp_point *)p)->MBEDTLS_PRIVATE(Z), 1));
@ -511,7 +502,6 @@ static struct crypto_key *crypto_alloc_key(void)
return (struct crypto_key *)key;
}
struct crypto_key * crypto_ec_set_pubkey_point(const struct crypto_ec_group *group,
const u8 *buf, size_t len)
{
@ -547,8 +537,9 @@ struct crypto_key * crypto_ec_set_pubkey_point(const struct crypto_ec_group *gro
}
/* Assign values */
if ((ret = mbedtls_pk_setup(key,
mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY) ) ) != 0 )
mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY))) != 0) {
goto fail;
}
mbedtls_ecp_copy(&mbedtls_pk_ec(*key)->MBEDTLS_PRIVATE(Q), point);
mbedtls_ecp_group_load(&mbedtls_pk_ec(*key)->MBEDTLS_PRIVATE(grp), ecp_grp->id);
@ -557,15 +548,16 @@ struct crypto_key * crypto_ec_set_pubkey_point(const struct crypto_ec_group *gro
crypto_ec_point_deinit((struct crypto_ec_point *)point, 0);
return pkey;
fail:
if (point)
if (point) {
crypto_ec_point_deinit((struct crypto_ec_point *)point, 0);
if (key)
}
if (key) {
mbedtls_pk_free(key);
}
pkey = NULL;
return pkey;
}
void crypto_ec_free_key(struct crypto_key *key)
{
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
@ -580,7 +572,6 @@ struct crypto_ec_point *crypto_ec_get_public_key(struct crypto_key *key)
return (struct crypto_ec_point *)&mbedtls_pk_ec(*pkey)->MBEDTLS_PRIVATE(Q);
}
int crypto_ec_get_priv_key_der(struct crypto_key *key, unsigned char **key_data, int *key_len)
{
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
@ -641,11 +632,13 @@ int crypto_ec_get_publickey_buf(struct crypto_key *key, u8 *key_buf, int len)
memset(buf, 0, sizeof(buf));
pk_len = mbedtls_pk_write_pubkey(&c, buf, pkey);
if (pk_len < 0)
if (pk_len < 0) {
return -1;
}
if (len == 0)
if (len == 0) {
return pk_len;
}
os_memcpy(key_buf, buf + MBEDTLS_MPI_MAX_SIZE + 10 - pk_len, pk_len);
@ -802,7 +795,6 @@ fail:
return ret;
}
int crypto_ecdsa_get_sign(unsigned char *hash,
const struct crypto_bignum *r, const struct crypto_bignum *s, struct crypto_key *csign, int hash_len)
{
@ -904,8 +896,9 @@ struct crypto_key * crypto_ec_gen_keypair(u16 ike_group)
}
if (mbedtls_pk_setup(kctx,
mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)) != 0 )
mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)) != 0) {
goto fail;
}
mbedtls_ecp_gen_key(MBEDTLS_ECP_DP_SECP256R1, mbedtls_pk_ec(*kctx), //get this from argument
crypto_rng_wrapper, NULL);
@ -930,8 +923,9 @@ static int pk_write_ec_param( unsigned char **p, unsigned char *start,
const char *oid;
size_t oid_len;
if( ( ret = mbedtls_oid_get_oid_by_ec_grp( ec->MBEDTLS_PRIVATE(grp).id, &oid, &oid_len ) ) != 0 )
if ((ret = mbedtls_oid_get_oid_by_ec_grp(ec->MBEDTLS_PRIVATE(grp).id, &oid, &oid_len)) != 0) {
return (ret);
}
MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_oid(p, start, oid, oid_len));
@ -947,13 +941,13 @@ static int pk_write_ec_pubkey_formatted( unsigned char **p, unsigned char *start
if ((ret = mbedtls_ecp_point_write_binary(&ec->MBEDTLS_PRIVATE(grp), &ec->MBEDTLS_PRIVATE(Q),
format,
&len, buf, sizeof( buf ) ) ) != 0 )
{
&len, buf, sizeof(buf))) != 0) {
return (ret);
}
if( *p < start || (size_t)( *p - start ) < len )
if (*p < start || (size_t)(*p - start) < len) {
return (MBEDTLS_ERR_ASN1_BUF_TOO_SMALL);
}
*p -= len;
memcpy(*p, buf, len);
@ -967,10 +961,11 @@ int mbedtls_pk_write_pubkey_formatted( unsigned char **p, unsigned char *start,
int ret;
size_t len = 0;
if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_ECKEY )
if (mbedtls_pk_get_type(key) == MBEDTLS_PK_ECKEY) {
MBEDTLS_ASN1_CHK_ADD(len, pk_write_ec_pubkey_formatted(p, start, mbedtls_pk_ec(*key), format));
else
} else {
return (MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE);
}
return ((int) len);
}
@ -982,15 +977,17 @@ int crypto_pk_write_formatted_pubkey_der(mbedtls_pk_context *key, unsigned char
size_t len = 0, par_len = 0, oid_len;
const char *oid;
if( size == 0 )
if (size == 0) {
return (MBEDTLS_ERR_ASN1_BUF_TOO_SMALL);
}
c = buf + size;
MBEDTLS_ASN1_CHK_ADD(len, mbedtls_pk_write_pubkey_formatted(&c, buf, key, format));
if( c - buf < 1 )
if (c - buf < 1) {
return (MBEDTLS_ERR_ASN1_BUF_TOO_SMALL);
}
/*
* SubjectPublicKeyInfo ::= SEQUENCE {
@ -1000,18 +997,15 @@ int crypto_pk_write_formatted_pubkey_der(mbedtls_pk_context *key, unsigned char
*--c = 0;
len += 1;
MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(&c, buf, len));
MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_tag(&c, buf, MBEDTLS_ASN1_BIT_STRING));
if ((ret = mbedtls_oid_get_oid_by_pk_alg(mbedtls_pk_get_type(key),
&oid, &oid_len ) ) != 0 )
{
&oid, &oid_len)) != 0) {
return (ret);
}
if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_ECKEY )
{
if (mbedtls_pk_get_type(key) == MBEDTLS_PK_ECKEY) {
MBEDTLS_ASN1_CHK_ADD(par_len, pk_write_ec_param(&c, buf, mbedtls_pk_ec(*key)));
}
@ -1029,8 +1023,9 @@ int crypto_ec_write_pub_key(struct crypto_key *key, unsigned char **key_buf)
{
unsigned char output_buf[1600] = {0};
int len = crypto_pk_write_formatted_pubkey_der((mbedtls_pk_context *)key, output_buf, 1600, 1);
if (len <= 0)
if (len <= 0) {
return 0;
}
*key_buf = os_malloc(len);
if (!*key_buf) {
@ -1200,7 +1195,6 @@ struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y,
goto cleanup;
}
mbedtls_pk_context *peer = (mbedtls_pk_context*)pkey;
/* Setup ECDH context from EC key */
@ -1243,7 +1237,6 @@ cleanup:
return sh_secret;
}
struct crypto_ec_key *crypto_ec_key_parse_pub(const u8 *der, size_t der_len)
{
int ret;
@ -1264,7 +1257,6 @@ struct crypto_ec_key *crypto_ec_key_parse_pub(const u8 *der, size_t der_len)
return (struct crypto_ec_key *)pkey;
}
void crypto_ec_key_deinit(struct crypto_ec_key *key)
{
mbedtls_pk_free((mbedtls_pk_context *)key);
@ -1307,5 +1299,4 @@ cleanup:
return ret;
}
#endif /* CONFIG_ECC */

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -52,10 +52,12 @@ int crypto_verify_cert(const u8 *cert_start, int certlen, const u8 *ca_cert_star
mbedtls_x509_crt *ca_cert = os_zalloc(sizeof(mbedtls_x509_crt));
if (!cert || !ca_cert) {
if (cert)
if (cert) {
os_free(cert);
if (ca_cert)
}
if (ca_cert) {
os_free(ca_cert);
}
wpa_printf(MSG_ERROR, "%s: memory allocation failed", __func__);
return -1;
}
@ -75,8 +77,9 @@ int crypto_verify_cert(const u8 *cert_start, int certlen, const u8 *ca_cert_star
ret = mbedtls_x509_crt_verify(cert, ca_cert, NULL, NULL, &flags, NULL, NULL);
/* Certification is failed, try to get some more info */
if (ret != 0)
if (ret != 0) {
crypto_dump_verify_info(flags);
}
cleanup:
mbedtls_x509_crt_free(cert);
@ -93,8 +96,9 @@ struct crypto_public_key * crypto_public_key_import(const u8 *key, size_t len)
int ret;
mbedtls_pk_context *pkey = os_zalloc(sizeof(*pkey));
if (!pkey)
if (!pkey) {
return NULL;
}
mbedtls_pk_init(pkey);
ret = mbedtls_pk_parse_public_key(pkey, key, len);
@ -114,8 +118,9 @@ struct crypto_private_key * crypto_private_key_import(const u8 *key,
{
int ret;
mbedtls_pk_context *pkey = os_zalloc(sizeof(mbedtls_pk_context));
if (!pkey)
if (!pkey) {
return NULL;
}
mbedtls_pk_init(pkey);
@ -190,10 +195,12 @@ int crypto_public_key_encrypt_pkcs1_v15(struct crypto_public_key *key,
mbedtls_ctr_drbg_context *ctr_drbg = os_zalloc(sizeof(*ctr_drbg));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy)
if (entropy) {
os_free(entropy);
if (ctr_drbg)
}
if (ctr_drbg) {
os_free(ctr_drbg);
}
wpa_printf(MSG_ERROR, "failed to allocate memory");
return -1;
}
@ -228,7 +235,6 @@ cleanup:
return ret;
}
int crypto_private_key_decrypt_pkcs1_v15(struct crypto_private_key *key,
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
@ -241,10 +247,12 @@ int crypto_private_key_decrypt_pkcs1_v15(struct crypto_private_key *key,
mbedtls_ctr_drbg_context *ctr_drbg = os_malloc(sizeof(*ctr_drbg));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy)
if (entropy) {
os_free(entropy);
if (ctr_drbg)
}
if (ctr_drbg) {
os_free(ctr_drbg);
}
return -1;
}
mbedtls_ctr_drbg_init(ctr_drbg);
@ -253,8 +261,9 @@ int crypto_private_key_decrypt_pkcs1_v15(struct crypto_private_key *key,
entropy, (const unsigned char *) pers,
strlen(pers));
if (ret < 0)
if (ret < 0) {
goto cleanup;
}
i = mbedtls_rsa_get_len(mbedtls_pk_rsa(*pkey));
ret = mbedtls_rsa_rsaes_pkcs1_v15_decrypt(mbedtls_pk_rsa(*pkey), mbedtls_ctr_drbg_random,
@ -271,7 +280,6 @@ cleanup:
return ret;
}
int crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
const u8 *in, size_t inlen,
u8 *out, size_t *outlen)
@ -283,10 +291,12 @@ int crypto_private_key_sign_pkcs1(struct crypto_private_key *key,
mbedtls_ctr_drbg_context *ctr_drbg = os_malloc(sizeof(*ctr_drbg));
if (!pkey || !entropy || !ctr_drbg) {
if (entropy)
if (entropy) {
os_free(entropy);
if (ctr_drbg)
}
if (ctr_drbg) {
os_free(ctr_drbg);
}
return -1;
}
mbedtls_ctr_drbg_init(ctr_drbg);
@ -311,23 +321,23 @@ cleanup:
return ret;
}
void crypto_public_key_free(struct crypto_public_key *key)
{
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
if (!pkey)
if (!pkey) {
return;
}
mbedtls_pk_free(pkey);
os_free(pkey);
}
void crypto_private_key_free(struct crypto_private_key *key)
{
mbedtls_pk_context *pkey = (mbedtls_pk_context *)key;
if (!pkey)
if (!pkey) {
return;
}
mbedtls_pk_free(pkey);
os_free(pkey);
@ -345,8 +355,9 @@ int crypto_public_key_decrypt_pkcs1(struct crypto_public_key *key,
return -1;
}
if (mbedtls_rsa_public(mbedtls_pk_rsa(*pkey), crypt, plain) < 0)
if (mbedtls_rsa_public(mbedtls_pk_rsa(*pkey), crypt, plain) < 0) {
return -1;
}
/*
* PKCS #1 v1.5, 8.1:
@ -375,8 +386,9 @@ int crypto_public_key_decrypt_pkcs1(struct crypto_public_key *key,
wpa_hexdump_key(MSG_DEBUG, "Signature EB", plain, len);
return -1;
}
while (pos < plain + len && *pos == 0xff)
while (pos < plain + len && *pos == 0xff) {
pos++;
}
if (pos - plain - 2 < 8) {
/* PKCS #1 v1.5, 8.1: At least eight octets long PS */

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -330,7 +330,6 @@ int hmac_sha384_vector(const u8 *key, size_t key_len, size_t num_elem,
len, mac);
}
int hmac_sha384(const u8 *key, size_t key_len, const u8 *data,
size_t data_len, u8 *mac)
{
@ -672,7 +671,6 @@ int aes_128_ctr_encrypt(const u8 *key, const u8 *nonce,
return aes_ctr_encrypt(key, 16, nonce, data, data_len);
}
#ifdef MBEDTLS_NIST_KW_C
int aes_wrap(const u8 *kek, size_t kek_len, int n, const u8 *plain, u8 *cipher)
{

Wyświetl plik

@ -46,15 +46,12 @@
psa_generic_status_to_mbedtls)
#endif /* CONFIG_TLSV13 */
#define TLS_RANDOM_LEN 32
#define TLS_HASH_MAX_SIZE 64
#define TLS_MASTER_SECRET_LEN 48
#define MAX_CIPHERSUITE 32
#define MAX_EXPORTER_CONTEXT_LEN 65535
/* Throw a compilation error if basic requirements in mbedtls are not enabled */
#if !defined(MBEDTLS_SSL_TLS_C)
#error "TLS not enabled in mbedtls config"
@ -126,8 +123,9 @@ static int tls_mbedtls_write(void *ctx, const unsigned char *buf, size_t len)
struct tls_connection *conn = (struct tls_connection *)ctx;
struct tls_data *data = &conn->tls_io_data;
if (wpabuf_resize(&data->out_data, len) < 0)
if (wpabuf_resize(&data->out_data, len) < 0) {
return 0;
}
wpabuf_put_data(data->out_data, buf, len);
@ -264,8 +262,7 @@ static uint16_t tls_sig_algs_for_suiteb[] = {
MBEDTLS_TLS_SIG_NONE
};
const mbedtls_x509_crt_profile suiteb_mbedtls_x509_crt_profile =
{
const mbedtls_x509_crt_profile suiteb_mbedtls_x509_crt_profile = {
#if defined(MBEDTLS_SHA512_C)
MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA384) |
MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA512) |
@ -370,8 +367,7 @@ static uint16_t tls_sig_algs_for_eap[] = {
MBEDTLS_TLS_SIG_NONE
};
const mbedtls_x509_crt_profile eap_mbedtls_x509_crt_profile =
{
const mbedtls_x509_crt_profile eap_mbedtls_x509_crt_profile = {
#if defined(MBEDTLS_SHA1_C)
MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA1) |
#endif
@ -405,8 +401,7 @@ static int tls_disable_key_usages(void *data, mbedtls_x509_crt *cert, int depth,
#endif /*CONFIG_ESP_WIFI_DISABLE_KEY_USAGE_CHECK*/
#ifdef CONFIG_SUITEB192
static const int suiteb_rsa_ciphersuite_preference[] =
{
static const int suiteb_rsa_ciphersuite_preference[] = {
#if defined(CONFIG_ESP_WIFI_EAP_TLS1_3)
MBEDTLS_TLS1_3_AES_256_GCM_SHA384,
#endif /* CONFIG_ESP_WIFI_EAP_TLS1_3 */
@ -419,8 +414,7 @@ static const int suiteb_rsa_ciphersuite_preference[] =
0
};
static const int suiteb_ecc_ciphersuite_preference[] =
{
static const int suiteb_ecc_ciphersuite_preference[] = {
#if defined(CONFIG_ESP_WIFI_EAP_TLS1_3)
MBEDTLS_TLS1_3_AES_256_GCM_SHA384,
#endif /* CONFIG_ESP_WIFI_EAP_TLS1_3 */
@ -431,8 +425,7 @@ static const int suiteb_ecc_ciphersuite_preference[] =
#endif
0
};
static const int suiteb_ciphersuite_preference[] =
{
static const int suiteb_ciphersuite_preference[] = {
#if defined(CONFIG_ESP_WIFI_EAP_TLS1_3)
MBEDTLS_TLS1_3_AES_256_GCM_SHA384,
#endif /* CONFIG_ESP_WIFI_EAP_TLS1_3 */
@ -484,8 +477,9 @@ static int set_client_config(const struct tls_connection_params *cfg, tls_contex
assert(tls != NULL);
#ifdef CONFIG_SUITEB192
if (cfg->flags & TLS_CONN_SUITEB)
if (cfg->flags & TLS_CONN_SUITEB) {
preset = MBEDTLS_SSL_PRESET_SUITEB;
}
#endif
ret = mbedtls_ssl_config_defaults(&tls->conf,
MBEDTLS_SSL_IS_CLIENT,
@ -670,7 +664,6 @@ struct tls_connection * tls_connection_init(void *tls_ctx)
return conn;
}
void tls_connection_deinit(void *tls_ctx, struct tls_connection *conn)
{
/* case: tls init failed */
@ -847,7 +840,6 @@ struct wpabuf * tls_connection_server_handshake(void *tls_ctx,
return NULL;
}
struct wpabuf * tls_connection_encrypt(void *tls_ctx,
struct tls_connection *conn,
const struct wpabuf *in_data)
@ -870,7 +862,6 @@ struct wpabuf * tls_connection_encrypt(void *tls_ctx,
return resp;
}
struct wpabuf *tls_connection_decrypt(void *tls_ctx,
struct tls_connection *conn,
const struct wpabuf *in_data)
@ -911,7 +902,6 @@ cleanup:
#undef MAX_PHASE2_BUFFER
}
int tls_connection_resumed(void *tls_ctx, struct tls_connection *conn)
{
if (conn && conn->tls && conn->tls->ssl.MBEDTLS_PRIVATE(handshake)) {
@ -972,7 +962,6 @@ int tls_get_cipher(void *tls_ctx, struct tls_connection *conn,
return 0;
}
int tls_connection_enable_workaround(void *tls_ctx,
struct tls_connection *conn)
{

Wyświetl plik

@ -123,8 +123,9 @@ static void btm_rrm_task(void *pvParameters)
bool task_del = false;
while (1) {
if (os_queue_recv(s_supplicant_evt_queue, &evt, OS_BLOCK) != TRUE)
if (os_queue_recv(s_supplicant_evt_queue, &evt, OS_BLOCK) != TRUE) {
continue;
}
/* event validation failed */
if (evt->id >= SIG_SUPPLICANT_MAX) {
@ -133,8 +134,7 @@ static void btm_rrm_task(void *pvParameters)
}
switch (evt->id) {
case SIG_SUPPLICANT_RX_ACTION:
{
case SIG_SUPPLICANT_RX_ACTION: {
struct ieee_mgmt_frame *frm = (struct ieee_mgmt_frame *)evt->data;
mgmt_rx_action(frm->payload, frm->len, frm->sender, frm->rssi, frm->channel);
os_free(frm);
@ -153,9 +153,10 @@ static void btm_rrm_task(void *pvParameters)
os_free(evt);
if (task_del)
if (task_del) {
break;
}
}
os_queue_delete(s_supplicant_evt_queue);
s_supplicant_evt_queue = NULL;
@ -170,8 +171,9 @@ static void clear_bssid_flag_and_channel(struct wpa_supplicant *wpa_s)
wifi_config_t *config;
/* Reset only if btm is enabled */
if (esp_wifi_is_btm_enabled_internal(WIFI_IF_STA) == false)
if (esp_wifi_is_btm_enabled_internal(WIFI_IF_STA) == false) {
return;
}
config = os_zalloc(sizeof(wifi_config_t));
@ -198,13 +200,16 @@ static void register_mgmt_frames(struct wpa_supplicant *wpa_s)
#ifdef CONFIG_IEEE80211KV
/* current supported features in supplicant: rrm and btm */
if (esp_wifi_is_rm_enabled_internal(WIFI_IF_STA))
if (esp_wifi_is_rm_enabled_internal(WIFI_IF_STA)) {
wpa_s->subtype = 1 << WLAN_ACTION_RADIO_MEASUREMENT;
if (esp_wifi_is_btm_enabled_internal(WIFI_IF_STA))
}
if (esp_wifi_is_btm_enabled_internal(WIFI_IF_STA)) {
wpa_s->subtype |= 1 << WLAN_ACTION_WNM;
}
if (wpa_s->subtype)
if (wpa_s->subtype) {
wpa_s->type |= 1 << WLAN_FC_STYPE_ACTION;
}
#endif /* CONFIG_IEEE80211KV */
#ifdef CONFIG_IEEE80211R
@ -517,8 +522,8 @@ int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb,
return wpas_rrm_send_neighbor_rep_request(wpa_s, &wpa_ssid, 0, 0, cb, cb_ctx);
}
void neighbor_report_recvd_cb(void *ctx, const uint8_t *report, size_t report_len) {
void neighbor_report_recvd_cb(void *ctx, const uint8_t *report, size_t report_len)
{
if (report == NULL) {
wpa_printf(MSG_DEBUG, "RRM: Notifying neighbor report - NONE");
esp_event_post(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP, NULL, 0, 0);
@ -811,7 +816,6 @@ static size_t add_mdie(uint8_t *bssid, uint8_t *ie, size_t len)
}
#endif /* CONFIG_IEEE80211R */
#ifdef CONFIG_IEEE80211R
int wpa_sm_update_ft_ies(struct wpa_sm *sm, const u8 *md,
const u8 *ies, size_t ies_len, bool auth_ie)
@ -855,8 +859,9 @@ int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
{
int ret = 0;
wifi_mgmt_frm_req_t *req = os_zalloc(sizeof(*req) + data_len);;
if (!req)
if (!req) {
return -1;
}
if (!wpa_s->current_bss) {
wpa_printf(MSG_ERROR, "STA not associated, return");

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

Wyświetl plik

@ -95,8 +95,9 @@ static void esp_dpp_call_cb(esp_supp_dpp_event_t evt, void *data)
static void esp_dpp_auth_conf_wait_timeout(void *eloop_ctx, void *timeout_ctx)
{
if (!s_dpp_ctx.dpp_auth || !s_dpp_ctx.dpp_auth->waiting_auth_conf)
if (!s_dpp_ctx.dpp_auth || !s_dpp_ctx.dpp_auth->waiting_auth_conf) {
return;
}
wpa_printf(MSG_DEBUG,
"DPP: Terminate authentication exchange due to Auth Confirm timeout");
@ -363,8 +364,9 @@ static esp_err_t esp_dpp_rx_peer_disc_resp(struct action_rx_param *rx_param)
if (res == DPP_STATUS_OK) {
entry = os_zalloc(sizeof(*entry));
if (!entry)
if (!entry) {
goto fail;
}
os_memcpy(entry->aa, rx_param->sa, ETH_ALEN);
os_memcpy(entry->pmkid, intro.pmkid, PMKID_LEN);
os_memcpy(entry->pmk, intro.pmk, intro.pmk_len);
@ -469,8 +471,9 @@ static esp_err_t esp_dpp_rx_action(struct action_rx_param *rx_param)
int ret = ESP_OK;
if (!rx_param)
if (!rx_param) {
return ESP_ERR_INVALID_ARG;
}
if (rx_param->action_frm->category == WLAN_ACTION_PUBLIC) {
struct ieee80211_public_action *public_action =

Wyświetl plik

@ -82,8 +82,7 @@ void *hostap_init(void)
pairwise_cipher = esp_wifi_ap_get_prof_pairwise_cipher_internal();
#ifdef CONFIG_IEEE80211W
if((auth_conf->wpa & WPA_PROTO_RSN) == WPA_PROTO_RSN)
{
if ((auth_conf->wpa & WPA_PROTO_RSN) == WPA_PROTO_RSN) {
esp_wifi_get_pmf_config_internal(&pmf_cfg, WIFI_IF_AP);
if (pmf_cfg.required) {
pairwise_cipher = WIFI_CIPHER_TYPE_CCMP;
@ -227,7 +226,6 @@ void hostapd_cleanup(struct hostapd_data *hapd)
}
bool hostap_deinit(void *data)
{
struct hostapd_data *hapd = (struct hostapd_data *)data;

Wyświetl plik

@ -186,7 +186,6 @@ static int wifi_ap_wps_enable_internal(const esp_wps_config_t *config)
return ESP_FAIL;
}
if (wps_set_type(config->wps_type) != ESP_OK) {
goto _err;
}
@ -247,7 +246,6 @@ static int wifi_ap_wps_disable_internal(void)
goto _err;
}
s_wps_enabled = false;
return ESP_OK;
@ -275,7 +273,6 @@ static int wifi_ap_wps_start_internal(const unsigned char *pin)
return ESP_ERR_WIFI_MODE;
}
if (!s_wps_enabled) {
wpa_printf(MSG_ERROR, "wps start: wps not enabled");
API_MUTEX_GIVE();

Wyświetl plik

@ -168,7 +168,8 @@ int esp_handle_beacon_probe(u8 type, u8 *frame, size_t len, u8 *sender,
return 0;
}
#ifdef CONFIG_WNM
void get_scan_channel_bitmap(struct wpa_supplicant *wpa_s, wifi_scan_config_t *params) {
void get_scan_channel_bitmap(struct wpa_supplicant *wpa_s, wifi_scan_config_t *params)
{
if (!wpa_s->wnm_num_neighbor_report) {
wpa_printf(MSG_DEBUG, "No Neighbor Report to gather scan channel list");
return;
@ -265,10 +266,12 @@ static int issue_scan(struct wpa_supplicant *wpa_s,
cleanup:
if (params) {
if (params->ssid)
if (params->ssid) {
os_free(params->ssid);
if (params->bssid)
}
if (params->bssid) {
os_free(params->bssid);
}
os_free(params);
}
@ -291,11 +294,13 @@ void wpa_scan_results_free(struct wpa_scan_results *res)
{
size_t i;
if (res == NULL)
if (res == NULL) {
return;
}
for (i = 0; i < res->num; i++)
for (i = 0; i < res->num; i++) {
os_free(res->res[i]);
}
os_free(res->res);
os_free(res);
}

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

Wyświetl plik

@ -17,7 +17,6 @@
#include "esp_hostap.h"
#include <inttypes.h>
static struct sae_pt *g_sae_pt;
static struct sae_data g_sae_data;
static struct wpabuf *g_sae_token = NULL;
@ -170,8 +169,9 @@ reuse_data:
static esp_err_t wpa3_build_sae_confirm(void)
{
if (g_sae_data.state != SAE_COMMITTED)
if (g_sae_data.state != SAE_COMMITTED) {
return ESP_FAIL;
}
if (g_sae_confirm) {
wpabuf_free(g_sae_confirm);
@ -224,14 +224,16 @@ static u8 *wpa3_build_sae_msg(u8 *bssid, u32 sae_msg_type, size_t *sae_msg_len)
*sae_msg_len = 0;
return NULL;
}
if (ESP_OK != wpa3_build_sae_commit(bssid, sae_msg_len))
if (ESP_OK != wpa3_build_sae_commit(bssid, sae_msg_len)) {
return NULL;
}
*sae_msg_len = wpabuf_len(g_sae_commit);
buf = wpabuf_mhead_u8(g_sae_commit);
break;
case SAE_MSG_CONFIRM:
if (ESP_OK != wpa3_build_sae_confirm())
if (ESP_OK != wpa3_build_sae_confirm()) {
return NULL;
}
*sae_msg_len = wpabuf_len(g_sae_confirm);
buf = wpabuf_mhead_u8(g_sae_confirm);
break;
@ -252,8 +254,9 @@ static int wpa3_parse_sae_commit(u8 *buf, u32 len, u16 status)
}
if (status == WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ) {
if (g_sae_token)
if (g_sae_token) {
wpabuf_free(g_sae_token);
}
if (g_sae_data.h2e) {
if ((buf[2] != WLAN_EID_EXTENSION) ||
(buf[3] == 0) ||

Wyświetl plik

@ -397,7 +397,6 @@ static bool hostap_sta_join(void **sta, u8 *bssid, u8 *wpa_ie, u8 wpa_ie_len,u8
process_old_sta:
#endif /* CONFIG_SAE */
#ifdef CONFIG_WPS_REGISTRAR
if (check_n_add_wps_sta(hapd, sta_info, wpa_ie, wpa_ie_len, pmf_enable, subtype) == 0) {
if (sta_info->eapol_sm) {

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

Wyświetl plik

@ -276,7 +276,6 @@ static inline int wps_sm_ether_send(struct wps_sm *sm, u16 proto,
return wpa_ether_send(sm, bssid, proto, data, data_len);
}
u8 *wps_sm_alloc_eapol(struct wps_sm *sm, u8 type,
const void *data, u16 data_len,
size_t *msg_len, void **data_pos)
@ -284,7 +283,6 @@ u8 *wps_sm_alloc_eapol(struct wps_sm *sm, u8 type,
return wpa_alloc_eapol(sm, type, data, data_len, msg_len, data_pos);
}
void wps_sm_free_eapol(u8 *buffer)
{
return wpa_free_eapol(buffer);
@ -463,7 +461,6 @@ int wps_send_eap_identity_rsp(u8 id)
goto _err;
}
wpabuf_put_data(eap_buf, sm->identity, sm->identity_len);
buf = wps_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAP_PACKET, wpabuf_head_u8(eap_buf), wpabuf_len(eap_buf), (size_t *)&len, NULL);
@ -710,8 +707,6 @@ _err:
return ret;
}
int wps_tx_start(void)
{
struct wps_sm *sm = gWpsSm;
@ -1021,7 +1016,7 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
wpa_printf(MSG_DEBUG, "error: receive eapol response frame!");
ret = 0;
break;
case EAP_CODE_REQUEST: {
case EAP_CODE_REQUEST:
eap_type = ((u8 *)ehdr)[sizeof(*ehdr)];
switch (eap_type) {
case EAP_TYPE_IDENTITY:
@ -1058,7 +1053,6 @@ int wps_sm_rx_eapol_internal(u8 *src_addr, u8 *buf, u32 len)
break;
}
break;
}
default:
break;
}
@ -1658,7 +1652,7 @@ int wifi_station_wps_start(void)
eloop_register_timeout(120, 0, wifi_station_wps_timeout, NULL, NULL);
switch (wps_get_status()) {
case WPS_STATUS_DISABLE: {
case WPS_STATUS_DISABLE:
sm->is_wps_scan = true;
wps_build_public_key(sm->wps, NULL);
@ -1672,7 +1666,6 @@ int wifi_station_wps_start(void)
sm->wps->dh_privkey = NULL;
wifi_wps_scan(NULL, NULL);
break;
}
case WPS_STATUS_SCANNING:
sm->scan_cnt = 0;
eloop_cancel_timeout(wifi_station_wps_timeout, NULL, NULL);

Wyświetl plik

@ -65,7 +65,6 @@ components_not_formatted_temporary:
- "/components/esp_phy/"
- "/components/esp_pm/"
- "/components/esp_rom/"
- "/components/esp_wifi/"
- "/components/esp-tls/"
- "/components/esptool_py/"
- "/components/fatfs/"
@ -95,7 +94,6 @@ components_not_formatted_temporary:
- "/components/vfs/"
- "/components/wear_levelling/"
- "/components/wifi_provisioning/"
- "/components/wpa_supplicant/"
- "/components/xtensa/"
- "/examples/bluetooth/"
- "/examples/build_system/"
@ -133,6 +131,8 @@ components_not_formatted_permanent:
- "/components/xtensa/include/xtensa/"
# FAT FS (upstream source code)
- "/components/fatfs/src/"
# wpa_supplicant upstream code
- "/components/wpa_supplicant/src/"
# Nginx HTTP parser (upstream source code)
- "/components/http_parser/"
# Argtable (upstream source code)