mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-06 15:15:15 +08:00
Merge branch 'feature/wpa_supplicant_sync_with_idf' into 'master'
Feature/wpa supplicant sync with idf See merge request sdk/ESP8266_RTOS_SDK!1431
This commit is contained in:
@ -434,6 +434,47 @@ typedef void (*esp_aes_decrypt_t)(void *ctx, const unsigned char *crypt, unsigne
|
||||
*/
|
||||
typedef void * (*esp_aes_decrypt_init_t)(const unsigned char *key, unsigned int len);
|
||||
|
||||
/**
|
||||
* @brief One-Key CBC MAC (OMAC1) hash with AES-128 for MIC computation
|
||||
*
|
||||
* @key: 128-bit key for the hash operation
|
||||
* @data: Data buffer for which a MIC is computed
|
||||
* @data_len: Length of data buffer in bytes
|
||||
* @mic: Buffer for MIC (128 bits, i.e., 16 bytes)
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
typedef int (*esp_omac1_aes_128_t)(const uint8_t *key, const uint8_t *data, size_t data_len,
|
||||
uint8_t *mic);
|
||||
|
||||
/**
|
||||
* @brief Decrypt data using CCMP (Counter Mode CBC-MAC Protocol OR
|
||||
* Counter Mode Cipher Block Chaining Message Authentication
|
||||
* Code Protocol) which is used in IEEE 802.11i RSN standard.
|
||||
* @tk: 128-bit Temporal Key for obtained during 4-way handshake
|
||||
* @hdr: Pointer to IEEE802.11 frame headeri needed for AAD
|
||||
* @data: Pointer to encrypted data buffer
|
||||
* @data_len: Encrypted data length in bytes
|
||||
* @decrypted_len: Length of decrypted data
|
||||
* Returns: Pointer to decrypted data on success, NULL on failure
|
||||
*/
|
||||
typedef uint8_t * (*esp_ccmp_decrypt_t)(const uint8_t *tk, const uint8_t *ieee80211_hdr,
|
||||
const uint8_t *data, size_t data_len, size_t *decrypted_len);
|
||||
|
||||
/**
|
||||
* @brief Encrypt data using CCMP (Counter Mode CBC-MAC Protocol OR
|
||||
* Counter Mode Cipher Block Chaining Message Authentication
|
||||
* Code Protocol) which is used in IEEE 802.11i RSN standard.
|
||||
* @tk: 128-bit Temporal Key for obtained during 4-way handshake
|
||||
* @frame: Pointer to IEEE802.11 frame including header
|
||||
* @len: Length of the frame including header
|
||||
* @hdrlen: Length of the header
|
||||
* @pn: Packet Number counter
|
||||
* @keyid: Key ID to be mentioned in CCMP Vector
|
||||
* @encrypted_len: Length of the encrypted frame including header
|
||||
*/
|
||||
typedef uint8_t * (*esp_ccmp_encrypt_t)(const uint8_t *tk, uint8_t *frame, size_t len, size_t hdrlen,
|
||||
uint8_t *pn, int keyid, size_t *encrypted_len);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize AES decryption
|
||||
*
|
||||
@ -718,6 +759,9 @@ typedef struct {
|
||||
esp_aes_decrypt_t aes_decrypt;
|
||||
esp_aes_decrypt_init_t aes_decrypt_init;
|
||||
esp_aes_decrypt_deinit_t aes_decrypt_deinit;
|
||||
esp_omac1_aes_128_t omac1_aes_128;
|
||||
esp_ccmp_decrypt_t ccmp_decrypt;
|
||||
esp_ccmp_encrypt_t ccmp_encrypt;
|
||||
}wpa_crypto_funcs_t;
|
||||
|
||||
/**
|
||||
|
@ -1,206 +0,0 @@
|
||||
// Hardware crypto support Copyright 2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ESP_WPA2_H
|
||||
#define ESP_WPA2_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs;
|
||||
|
||||
typedef struct {
|
||||
const wpa2_crypto_funcs_t *crypto_funcs;
|
||||
}esp_wpa2_config_t;
|
||||
|
||||
#define WPA2_CONFIG_INIT_DEFAULT() { \
|
||||
.crypto_funcs = &g_wifi_default_wpa2_crypto_funcs \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable wpa2 enterprise authentication.
|
||||
*
|
||||
* @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
|
||||
* @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed.
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_enable(const esp_wpa2_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Disable wpa2 enterprise authentication.
|
||||
*
|
||||
* @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
|
||||
* @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed.
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Set identity for PEAP/TTLS method.
|
||||
*
|
||||
* @attention The API only passes the parameter identity to the global pointer variable in wpa2 enterprise module.
|
||||
*
|
||||
* @param identity: point to address where stores the identity;
|
||||
* @param len: length of identity, limited to 1~127
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_identity(const unsigned char *identity, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear identity for PEAP/TTLS method.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_identity(void);
|
||||
|
||||
/**
|
||||
* @brief Set username for PEAP/TTLS method.
|
||||
*
|
||||
* @attention The API only passes the parameter username to the global pointer variable in wpa2 enterprise module.
|
||||
*
|
||||
* @param username: point to address where stores the username;
|
||||
* @param len: length of username, limited to 1~127
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0 or len >= 128)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_username(const unsigned char *username, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear username for PEAP/TTLS method.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_username(void);
|
||||
|
||||
/**
|
||||
* @brief Set password for PEAP/TTLS method..
|
||||
*
|
||||
* @attention The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
|
||||
*
|
||||
* @param password: point to address where stores the password;
|
||||
* @param len: length of password(len > 0)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_password(const unsigned char *password, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear password for PEAP/TTLS method..
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_password(void);
|
||||
|
||||
/**
|
||||
* @brief Set new password for MSCHAPv2 method..
|
||||
*
|
||||
* @attention 1. The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
|
||||
* @attention 2. The new password is used to substitute the old password when eap-mschapv2 failure request message with error code ERROR_PASSWD_EXPIRED is received.
|
||||
*
|
||||
* @param new_password: point to address where stores the password;
|
||||
* @param len: length of password
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_INVALID_ARG: fail(len <= 0)
|
||||
* - ESP_ERR_NO_MEM: fail(internal memory malloc fail)
|
||||
*/
|
||||
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(const unsigned char *new_password, int len);
|
||||
|
||||
/**
|
||||
* @brief Clear new password for MSCHAPv2 method..
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_new_password(void);
|
||||
|
||||
/**
|
||||
* @brief Set CA certificate for PEAP/TTLS method.
|
||||
*
|
||||
* @attention 1. The API only passes the parameter ca_cert to the global pointer variable in wpa2 enterprise module.
|
||||
* @attention 2. The ca_cert should be zero terminated.
|
||||
*
|
||||
* @param ca_cert: point to address where stores the CA certificate;
|
||||
* @param ca_cert_len: length of ca_cert
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(const unsigned char *ca_cert, int ca_cert_len);
|
||||
|
||||
/**
|
||||
* @brief Clear CA certificate for PEAP/TTLS method.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_ca_cert(void);
|
||||
|
||||
/**
|
||||
* @brief Set client certificate and key.
|
||||
*
|
||||
* @attention 1. The API only passes the parameter client_cert, private_key and private_key_passwd to the global pointer variable in wpa2 enterprise module.
|
||||
* @attention 2. The client_cert, private_key and private_key_passwd should be zero terminated.
|
||||
*
|
||||
* @param client_cert: point to address where stores the client certificate;
|
||||
* @param client_cert_len: length of client certificate;
|
||||
* @param private_key: point to address where stores the private key;
|
||||
* @param private_key_len: length of private key, limited to 1~2048;
|
||||
* @param private_key_password: point to address where stores the private key password;
|
||||
* @param private_key_password_len: length of private key password;
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(const unsigned char *client_cert, int client_cert_len, const unsigned char *private_key, int private_key_len, const unsigned char *private_key_passwd, int private_key_passwd_len);
|
||||
|
||||
/**
|
||||
* @brief Clear client certificate and key.
|
||||
*/
|
||||
void esp_wifi_sta_wpa2_ent_clear_cert_key(void);
|
||||
|
||||
/**
|
||||
* @brief Set wpa2 enterprise certs time check(disable or not).
|
||||
*
|
||||
* @param true: disable wpa2 enterprise certs time check
|
||||
* @param false: enable wpa2 enterprise certs time check
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_set_disable_time_check(bool disable);
|
||||
|
||||
/**
|
||||
* @brief Get wpa2 enterprise certs time check(disable or not).
|
||||
*
|
||||
* @param disable: store disable value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_wpa2_ent_get_disable_time_check(bool *disable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,144 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_WPS_H__
|
||||
#define __ESP_WPS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_crypto_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup WiFi_APIs WiFi Related APIs
|
||||
* @brief WiFi APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup WiFi_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup WPS_APIs WPS APIs
|
||||
* @brief ESP8266 WPS APIs
|
||||
*
|
||||
* WPS can only be used when ESP8266 station is enabled.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @addtogroup WPS_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ESP_ERR_WIFI_REGISTRAR (ESP_ERR_WIFI_BASE + 51) /*!< WPS registrar is not supported */
|
||||
#define ESP_ERR_WIFI_WPS_TYPE (ESP_ERR_WIFI_BASE + 52) /*!< WPS type error */
|
||||
#define ESP_ERR_WIFI_WPS_SM (ESP_ERR_WIFI_BASE + 53) /*!< WPS state machine is not initialized */
|
||||
|
||||
typedef enum wps_type {
|
||||
WPS_TYPE_DISABLE = 0,
|
||||
WPS_TYPE_PBC,
|
||||
WPS_TYPE_PIN,
|
||||
WPS_TYPE_MAX,
|
||||
} wps_type_t;
|
||||
|
||||
extern const wps_crypto_funcs_t g_wifi_default_wps_crypto_funcs;
|
||||
|
||||
#define WPS_MAX_MANUFACTURER_LEN 65
|
||||
#define WPS_MAX_MODEL_NUMBER_LEN 33
|
||||
#define WPS_MAX_MODEL_NAME_LEN 33
|
||||
#define WPS_MAX_DEVICE_NAME_LEN 33
|
||||
|
||||
typedef struct {
|
||||
char manufacturer[WPS_MAX_MANUFACTURER_LEN]; /*!< Manufacturer, null-terminated string. The default manufcturer is used if the string is empty */
|
||||
char model_number[WPS_MAX_MODEL_NUMBER_LEN]; /*!< Model number, null-terminated string. The default model number is used if the string is empty */
|
||||
char model_name[WPS_MAX_MODEL_NAME_LEN]; /*!< Model name, null-terminated string. The default model name is used if the string is empty */
|
||||
char device_name[WPS_MAX_DEVICE_NAME_LEN]; /*!< Device name, null-terminated string. The default device name is used if the string is empty */
|
||||
} wps_factory_information_t;
|
||||
|
||||
typedef struct {
|
||||
wps_type_t wps_type;
|
||||
const wps_crypto_funcs_t *crypto_funcs;
|
||||
wps_factory_information_t factory_info;
|
||||
} esp_wps_config_t;
|
||||
|
||||
#define WPS_CONFIG_INIT_DEFAULT(type) { \
|
||||
.wps_type = type, \
|
||||
.crypto_funcs = &g_wifi_default_wps_crypto_funcs, \
|
||||
.factory_info = { \
|
||||
.manufacturer = "ESPRESSIF", \
|
||||
.model_number = "ESP8266", \
|
||||
.model_name = "ESPRESSIF IOT", \
|
||||
.device_name = "ESP STATION", \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable Wi-Fi WPS function.
|
||||
*
|
||||
* @attention WPS can only be used when ESP8266 station is enabled.
|
||||
*
|
||||
* @param wps_type_t wps_type : WPS type, so far only WPS_TYPE_PBC and WPS_TYPE_PIN is supported
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
|
||||
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
||||
* - ESP_FAIL : wps initialization fails
|
||||
*/
|
||||
esp_err_t esp_wifi_wps_enable(const esp_wps_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Disable Wi-Fi WPS function and release resource it taken.
|
||||
*
|
||||
* @param null
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
||||
*/
|
||||
esp_err_t esp_wifi_wps_disable(void);
|
||||
|
||||
/**
|
||||
* @brief WPS starts to work.
|
||||
*
|
||||
* @attention WPS can only be used when ESP8266 station is enabled.
|
||||
*
|
||||
* @param timeout_ms : maximum blocking time before API return.
|
||||
* - 0 : non-blocking
|
||||
* - 1~120000 : blocking time (not supported in IDF v1.0)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : succeed
|
||||
* - ESP_ERR_WIFI_WPS_TYPE : wps type is invalid
|
||||
* - ESP_ERR_WIFI_WPS_MODE : wifi is not in station mode or sniffer mode is on
|
||||
* - ESP_ERR_WIFI_WPS_SM : wps state machine is not initialized
|
||||
* - ESP_FAIL : wps initialization fails
|
||||
*/
|
||||
esp_err_t esp_wifi_wps_start(int timeout_ms);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_WPS_H__ */
|
@ -174,6 +174,16 @@ void os_timer_arm(os_timer_t *ptimer, uint32_t msec, bool repeat_flag);
|
||||
*/
|
||||
void os_timer_disarm(os_timer_t *ptimer);
|
||||
|
||||
/* redefine esp-idf name to esp8266 */
|
||||
#define ets_delay_us os_delay_us
|
||||
#define ETSTimer os_timer_t
|
||||
#define ETSTimerFunc os_timer_func_t
|
||||
#define ets_timer_disarm os_timer_disarm
|
||||
#define ets_timer_setfn os_timer_setfn
|
||||
#define ets_timer_arm os_timer_arm
|
||||
|
||||
void ets_timer_done(os_timer_t *ptimer);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user