esp_wpa2.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef ESP_WPA2_H
  14. #define ESP_WPA2_H
  15. #include "esp_err.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * @brief Enable wpa2 enterprise authentication.
  21. *
  22. * @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
  23. * @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
  24. *
  25. * @return
  26. * - ESP_ERR_WIFI_OK: succeed.
  27. * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
  28. */
  29. esp_err_t esp_wifi_sta_wpa2_ent_enable(void);
  30. /**
  31. * @brief Disable wpa2 enterprise authentication.
  32. *
  33. * @attention 1. wpa2 enterprise authentication can only be used when ESP32 station is enabled.
  34. * @attention 2. wpa2 enterprise authentication can only support TLS, PEAP-MSCHAPv2 and TTLS-MSCHAPv2 method.
  35. *
  36. * @return
  37. * - ESP_ERR_WIFI_OK: succeed.
  38. */
  39. esp_err_t esp_wifi_sta_wpa2_ent_disable(void);
  40. /**
  41. * @brief Set identity for PEAP/TTLS method.
  42. *
  43. * @attention The API only passes the parameter identity to the global pointer variable in wpa2 enterprise module.
  44. *
  45. * @param identity: point to address where stores the identity;
  46. * @param len: length of identity, limited to 1~127
  47. *
  48. * @return
  49. * - ESP_ERR_WIFI_OK: succeed
  50. * - ESP_ERR_WIFI_ARG: fail(len <= 0 or len >= 128)
  51. * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
  52. */
  53. esp_err_t esp_wifi_sta_wpa2_ent_set_identity(unsigned char *identity, int len);
  54. /**
  55. * @brief Clear identity for PEAP/TTLS method.
  56. */
  57. void esp_wifi_sta_wpa2_ent_clear_identity(void);
  58. /**
  59. * @brief Set username for PEAP/TTLS method.
  60. *
  61. * @attention The API only passes the parameter username to the global pointer variable in wpa2 enterprise module.
  62. *
  63. * @param username: point to address where stores the username;
  64. * @param len: length of username, limited to 1~127
  65. *
  66. * @return
  67. * - ESP_ERR_WIFI_OK: succeed
  68. * - ESP_ERR_WIFI_ARG: fail(len <= 0 or len >= 128)
  69. * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
  70. */
  71. esp_err_t esp_wifi_sta_wpa2_ent_set_username(unsigned char *username, int len);
  72. /**
  73. * @brief Clear username for PEAP/TTLS method.
  74. */
  75. void esp_wifi_sta_wpa2_ent_clear_username(void);
  76. /**
  77. * @brief Set password for PEAP/TTLS method..
  78. *
  79. * @attention The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
  80. *
  81. * @param password: point to address where stores the password;
  82. * @param len: length of password(len > 0)
  83. *
  84. * @return
  85. * - ESP_ERR_WIFI_OK: succeed
  86. * - ESP_ERR_WIFI_ARG: fail(len <= 0)
  87. * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
  88. */
  89. esp_err_t esp_wifi_sta_wpa2_ent_set_password(unsigned char *password, int len);
  90. /**
  91. * @brief Clear password for PEAP/TTLS method..
  92. */
  93. void esp_wifi_sta_wpa2_ent_clear_password(void);
  94. /**
  95. * @brief Set new password for MSCHAPv2 method..
  96. *
  97. * @attention 1. The API only passes the parameter password to the global pointer variable in wpa2 enterprise module.
  98. * @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.
  99. *
  100. * @param password: point to address where stores the password;
  101. * @param len: length of password
  102. *
  103. * @return
  104. * - ESP_ERR_WIFI_OK: succeed
  105. * - ESP_ERR_WIFI_ARG: fail(len <= 0)
  106. * - ESP_ERR_WIFI_NO_MEM: fail(internal memory malloc fail)
  107. */
  108. esp_err_t esp_wifi_sta_wpa2_ent_set_new_password(unsigned char *password, int len);
  109. /**
  110. * @brief Clear new password for MSCHAPv2 method..
  111. */
  112. void esp_wifi_sta_wpa2_ent_clear_new_password(void);
  113. /**
  114. * @brief Set CA certificate for PEAP/TTLS method.
  115. *
  116. * @attention 1. The API only passes the parameter ca_cert to the global pointer variable in wpa2 enterprise module.
  117. * @attention 2. The ca_cert should be zero terminated.
  118. *
  119. * @param ca_cert: point to address where stores the CA certificate;
  120. * @param len: length of ca_cert
  121. *
  122. * @return
  123. * - ESP_ERR_WIFI_OK: succeed
  124. */
  125. esp_err_t esp_wifi_sta_wpa2_ent_set_ca_cert(unsigned char *ca_cert, int len);
  126. /**
  127. * @brief Clear CA certificate for PEAP/TTLS method.
  128. */
  129. void esp_wifi_sta_wpa2_ent_clear_ca_cert(void);
  130. /**
  131. * @brief Set client certificate and key.
  132. *
  133. * @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.
  134. * @attention 2. The client_cert, private_key and private_key_passwd should be zero terminated.
  135. *
  136. * @param client_cert: point to address where stores the client certificate;
  137. * @param client_cert_len: length of client certificate;
  138. * @param private_key: point to address where stores the private key;
  139. * @param private_key_len: length of private key, limited to 1~2048;
  140. * @param private_key_password: point to address where stores the private key password;
  141. * @param private_key_password_len: length of private key password;
  142. *
  143. * @return
  144. * - ESP_ERR_WIFI_OK: succeed
  145. */
  146. 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);
  147. /**
  148. * @brief Clear client certificate and key.
  149. */
  150. void esp_wifi_sta_wpa2_ent_clear_cert_key(void);
  151. /**
  152. * @brief Set wpa2 enterprise certs time check(disable or not).
  153. *
  154. * @param true: disable wpa2 enterprise certs time check
  155. * @param false: enable wpa2 enterprise certs time check
  156. *
  157. * @return
  158. * - ESP_OK: succeed
  159. */
  160. esp_err_t esp_wifi_sta_wpa2_ent_set_disable_time_check(bool disable);
  161. /**
  162. * @brief Get wpa2 enterprise certs time check(disable or not).
  163. *
  164. * @param disable: store disable value
  165. *
  166. * @return
  167. * - ESP_OK: succeed
  168. */
  169. esp_err_t esp_wifi_sta_wpa2_ent_get_disable_time_check(bool *disable);
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif