2016-11-24 07:41:44 -05:00
|
|
|
// 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.
|
|
|
|
|
2016-11-10 21:38:57 -05:00
|
|
|
#ifndef ESP_WPA2_H
|
|
|
|
#define ESP_WPA2_H
|
|
|
|
|
|
|
|
#include "esp_err.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2016-11-23 02:29:01 -05:00
|
|
|
* @brief Enable wpa2 enterprise authentication.
|
2016-11-10 21:38:57 -05:00
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @attention wpa2 enterprise authentication can only be used when ESP32 station is enabled.
|
|
|
|
* wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
|
2016-11-10 21:38:57 -05:00
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @return ESP_ERR_WIFI_OK: succeed.
|
|
|
|
* ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
|
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_enable(void);
|
2016-11-23 02:29:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disable wpa2 enterprise authentication.
|
|
|
|
*
|
|
|
|
* @attention wpa2 enterprise authentication can only be used when ESP32 station is enabled.
|
|
|
|
* wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
|
|
|
|
*
|
|
|
|
* @return ESP_ERR_WIFI_OK: succeed.
|
2016-11-10 21:38:57 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_disable(void);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set username for PEAP/TTLS method.
|
|
|
|
*
|
2016-11-24 22:03:33 -05:00
|
|
|
* @attention The API only passes the parameter username to the global pointer variable in wpa2 enterprise module.
|
|
|
|
*
|
2016-11-10 21:38:57 -05:00
|
|
|
* @param username: point to address where stores the username;
|
|
|
|
* len: length of username, limited to 1~127
|
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @return ESP_ERR_WIFI_OK: succeed
|
|
|
|
* ESP_ERR_WIFI_ARG: fail(len <= 0 or len >= 128)
|
|
|
|
* ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
|
2016-11-10 21:38:57 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_set_username(unsigned char *username, int len);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
2016-11-23 02:29:01 -05:00
|
|
|
/**
|
|
|
|
* @brief Clear username for PEAP/TTLS method.
|
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
void esp_wifi_sta_wpa2_ent_clear_username(void);
|
2016-11-23 02:29:01 -05:00
|
|
|
|
2016-11-10 21:38:57 -05:00
|
|
|
/**
|
|
|
|
* @brief Set password for PEAP/TTLS method..
|
|
|
|
*
|
2016-11-24 22:03:33 -05:00
|
|
|
* @attention The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
|
|
|
|
*
|
2016-11-10 21:38:57 -05:00
|
|
|
* @param password: point to address where stores the password;
|
2016-11-24 22:03:33 -05:00
|
|
|
* len: length of password(len > 0)
|
2016-11-10 21:38:57 -05:00
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @return ESP_ERR_WIFI_OK: succeed
|
|
|
|
* ESP_ERR_WIFI_ARG: fail(len <= 0)
|
|
|
|
* ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
|
2016-11-10 21:38:57 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_set_password(unsigned char *password, int len);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
|
|
|
/**
|
2016-11-23 02:29:01 -05:00
|
|
|
* @brief Clear password for PEAP/TTLS method..
|
2016-11-10 21:38:57 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
void esp_wifi_sta_wpa2_ent_clear_password(void);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
|
|
|
/**
|
2016-11-24 22:03:33 -05:00
|
|
|
* @brief Set new password for MSCHAPv2 method..
|
|
|
|
*
|
|
|
|
* @attention The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
|
|
|
|
* The new password is used to substitute the old password when eap-mschapv2 failure request message with error code ERROR_PASSWD_EXPIRED is received.
|
2016-11-10 21:38:57 -05:00
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @param password: point to address where stores the password;
|
|
|
|
* len: length of password
|
2016-11-10 21:38:57 -05:00
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @return ESP_ERR_WIFI_OK: succeed
|
|
|
|
* ESP_ERR_WIFI_ARG: fail(len <= 0)
|
|
|
|
* ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
|
2016-11-10 21:38:57 -05:00
|
|
|
*/
|
2016-11-23 02:29:01 -05:00
|
|
|
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(unsigned char *password, int len);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
|
|
|
/**
|
2016-11-24 22:03:33 -05:00
|
|
|
* @brief Clear new password for MSCHAPv2 method..
|
2016-11-10 21:38:57 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
void esp_wifi_sta_wpa2_ent_clear_new_password(void);
|
2016-11-23 02:29:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set CA certificate for PEAP/TTLS method.
|
|
|
|
*
|
2016-11-24 22:03:33 -05:00
|
|
|
* @attention The API only passes the parameter ca_cert to the global pointer variable in wpa2 enterprise module.
|
|
|
|
* The ca_cert should be zero terminated.
|
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @param ca_cert: point to address where stores the CA certificate;
|
|
|
|
* len: length of ca_cert
|
|
|
|
*
|
|
|
|
* @return ESP_ERR_WIFI_OK: succeed
|
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(unsigned char *ca_cert, int len);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clear CA certificate for PEAP/TTLS method.
|
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
void esp_wifi_sta_wpa2_ent_clear_ca_cert(void);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set client certificate and key.
|
|
|
|
*
|
2016-11-24 22:03:33 -05:00
|
|
|
* @attention The API only passes the parameter client_cert, private_key and private_key_passwd to the global pointer variable in wpa2 enterprise module.
|
|
|
|
* The client_cert, private_key and private_key_passwd should be zero terminated.
|
|
|
|
*
|
2016-11-10 21:38:57 -05:00
|
|
|
* @param client_cert: point to address where stores the client certificate;
|
|
|
|
* client_cert_len: length of client certificate;
|
|
|
|
* private_key: point to address where stores the private key;
|
2016-11-30 23:08:11 -05:00
|
|
|
* private_key_len: length of private key, limited to 1~2048;
|
2016-11-10 21:38:57 -05:00
|
|
|
* private_key_password: point to address where stores the private key password;
|
|
|
|
* private_key_password_len: length of private key password;
|
|
|
|
*
|
2016-11-23 02:29:01 -05:00
|
|
|
* @return ESP_ERR_WIFI_OK: succeed
|
2016-11-10 21:38:57 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_set_cert_key(unsigned char *client_cert, int client_cert_len, unsigned char *private_key, int private_key_len, unsigned char *private_key_passwd, int private_key_passwd_len);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clear client certificate and key.
|
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
void esp_wifi_sta_wpa2_ent_clear_cert_key(void);
|
2016-11-10 21:38:57 -05:00
|
|
|
|
2016-11-23 02:29:01 -05:00
|
|
|
/**
|
|
|
|
* @brief Set wpa2 enterprise certs time check(disable or not).
|
|
|
|
*
|
|
|
|
* @param true: disable wpa2 enterprise certs time check
|
|
|
|
* false: enable wpa2 enterprise certs time check
|
|
|
|
*
|
2016-11-24 22:03:33 -05:00
|
|
|
* @return ESP_OK: succeed
|
2016-11-23 02:29:01 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_set_disable_time_check(bool disable);
|
2016-11-23 02:29:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get wpa2 enterprise certs time check(disable or not).
|
|
|
|
*
|
|
|
|
* @param disable: store disable value
|
|
|
|
*
|
2016-11-24 22:03:33 -05:00
|
|
|
* @return ESP_OK: succeed
|
2016-11-23 02:29:01 -05:00
|
|
|
*/
|
2016-11-25 05:08:21 -05:00
|
|
|
esp_err_t esp_wifi_sta_wpa2_ent_get_disable_time_check(bool *disable);
|
2016-11-23 02:29:01 -05:00
|
|
|
|
2016-11-10 21:38:57 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|