Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

wpa_auth_i.h 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * hostapd - IEEE 802.11i-2004 / WPA Authenticator: Internal definitions
  3. * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef WPA_AUTH_I_H
  15. #define WPA_AUTH_I_H
  16. /* max(dot11RSNAConfigGroupUpdateCount,dot11RSNAConfigPairwiseUpdateCount) */
  17. #define RSNA_MAX_EAPOL_RETRIES 4
  18. struct wpa_group;
  19. struct wpa_stsl_negotiation {
  20. struct wpa_stsl_negotiation *next;
  21. u8 initiator[ETH_ALEN];
  22. u8 peer[ETH_ALEN];
  23. };
  24. struct wpa_state_machine {
  25. struct wpa_authenticator *wpa_auth;
  26. struct wpa_group *group;
  27. u8 addr[ETH_ALEN];
  28. enum {
  29. WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
  30. WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
  31. WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
  32. WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
  33. WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
  34. } wpa_ptk_state;
  35. enum {
  36. WPA_PTK_GROUP_IDLE = 0,
  37. WPA_PTK_GROUP_REKEYNEGOTIATING,
  38. WPA_PTK_GROUP_REKEYESTABLISHED,
  39. WPA_PTK_GROUP_KEYERROR
  40. } wpa_ptk_group_state;
  41. Boolean Init;
  42. Boolean DeauthenticationRequest;
  43. Boolean AuthenticationRequest;
  44. Boolean ReAuthenticationRequest;
  45. Boolean Disconnect;
  46. int TimeoutCtr;
  47. int GTimeoutCtr;
  48. Boolean TimeoutEvt;
  49. Boolean EAPOLKeyReceived;
  50. Boolean EAPOLKeyPairwise;
  51. Boolean EAPOLKeyRequest;
  52. Boolean MICVerified;
  53. Boolean GUpdateStationKeys;
  54. u8 ANonce[WPA_NONCE_LEN];
  55. u8 SNonce[WPA_NONCE_LEN];
  56. u8 PMK[PMK_LEN];
  57. struct wpa_ptk PTK;
  58. Boolean PTK_valid;
  59. Boolean pairwise_set;
  60. int keycount;
  61. Boolean Pair;
  62. struct {
  63. u8 counter[WPA_REPLAY_COUNTER_LEN];
  64. Boolean valid;
  65. } key_replay[RSNA_MAX_EAPOL_RETRIES];
  66. Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
  67. Boolean PTKRequest; /* not in IEEE 802.11i state machine */
  68. Boolean has_GTK;
  69. Boolean PtkGroupInit; /* init request for PTK Group state machine */
  70. u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
  71. size_t last_rx_eapol_key_len;
  72. unsigned int changed:1;
  73. unsigned int in_step_loop:1;
  74. unsigned int pending_deinit:1;
  75. unsigned int started:1;
  76. unsigned int mgmt_frame_prot:1;
  77. #ifdef CONFIG_IEEE80211R
  78. unsigned int ft_completed:1;
  79. unsigned int pmk_r1_name_valid:1;
  80. #endif /* CONFIG_IEEE80211R */
  81. u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
  82. int req_replay_counter_used;
  83. u8 *wpa_ie;
  84. size_t wpa_ie_len;
  85. enum {
  86. WPA_VERSION_NO_WPA = 0 /* WPA not used */,
  87. WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
  88. WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
  89. } wpa;
  90. int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
  91. int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
  92. struct rsn_pmksa_cache_entry *pmksa;
  93. u32 dot11RSNAStatsTKIPLocalMICFailures;
  94. u32 dot11RSNAStatsTKIPRemoteMICFailures;
  95. #ifdef CONFIG_IEEE80211R
  96. u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
  97. size_t xxkey_len;
  98. u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
  99. * Request */
  100. u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
  101. size_t r0kh_id_len;
  102. u8 sup_pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name from EAPOL-Key
  103. * message 2/4 */
  104. u8 *assoc_resp_ftie;
  105. #endif /* CONFIG_IEEE80211R */
  106. int pending_1_of_4_timeout;
  107. };
  108. /* per group key state machine data */
  109. struct wpa_group {
  110. struct wpa_group *next;
  111. int vlan_id;
  112. Boolean GInit;
  113. int GKeyDoneStations;
  114. Boolean GTKReKey;
  115. int GTK_len;
  116. int GN, GM;
  117. Boolean GTKAuthenticator;
  118. u8 Counter[WPA_NONCE_LEN];
  119. enum {
  120. WPA_GROUP_GTK_INIT = 0,
  121. WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE
  122. } wpa_group_state;
  123. u8 GMK[WPA_GMK_LEN];
  124. u8 GTK[2][WPA_GTK_MAX_LEN];
  125. u8 GNonce[WPA_NONCE_LEN];
  126. Boolean changed;
  127. Boolean first_sta_seen;
  128. Boolean reject_4way_hs_for_entropy;
  129. #ifdef CONFIG_IEEE80211W
  130. u8 IGTK[2][WPA_IGTK_LEN];
  131. int GN_igtk, GM_igtk;
  132. #endif /* CONFIG_IEEE80211W */
  133. };
  134. struct wpa_ft_pmk_cache;
  135. /* per authenticator data */
  136. struct wpa_authenticator {
  137. struct wpa_group *group;
  138. unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
  139. u32 dot11RSNAAuthenticationSuiteSelected;
  140. u32 dot11RSNAPairwiseCipherSelected;
  141. u32 dot11RSNAGroupCipherSelected;
  142. u8 dot11RSNAPMKIDUsed[PMKID_LEN];
  143. u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
  144. u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
  145. u32 dot11RSNAGroupCipherRequested; /* FIX: update */
  146. unsigned int dot11RSNATKIPCounterMeasuresInvoked;
  147. unsigned int dot11RSNA4WayHandshakeFailures;
  148. struct wpa_stsl_negotiation *stsl_negotiations;
  149. struct wpa_auth_config conf;
  150. struct wpa_auth_callbacks cb;
  151. u8 *wpa_ie;
  152. size_t wpa_ie_len;
  153. u8 addr[ETH_ALEN];
  154. struct rsn_pmksa_cache *pmksa;
  155. struct wpa_ft_pmk_cache *ft_pmk_cache;
  156. };
  157. int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
  158. const u8 *pmkid);
  159. void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
  160. logger_level level, const char *txt);
  161. void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
  162. logger_level level, const char *fmt, ...);
  163. void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
  164. struct wpa_state_machine *sm, int key_info,
  165. const u8 *key_rsc, const u8 *nonce,
  166. const u8 *kde, size_t kde_len,
  167. int keyidx, int encr, int force_version);
  168. int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
  169. int (*cb)(struct wpa_state_machine *sm, void *ctx),
  170. void *cb_ctx);
  171. int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
  172. int (*cb)(struct wpa_authenticator *a, void *ctx),
  173. void *cb_ctx);
  174. #ifdef CONFIG_PEERKEY
  175. int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
  176. struct wpa_stsl_negotiation *neg);
  177. void wpa_smk_error(struct wpa_authenticator *wpa_auth,
  178. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  179. void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
  180. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  181. void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
  182. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  183. #endif /* CONFIG_PEERKEY */
  184. #ifdef CONFIG_IEEE80211R
  185. int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
  186. int wpa_write_ftie(struct wpa_auth_config *conf, const u8 *r0kh_id,
  187. size_t r0kh_id_len,
  188. const u8 *anonce, const u8 *snonce,
  189. u8 *buf, size_t len, const u8 *subelem,
  190. size_t subelem_len);
  191. int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
  192. struct wpa_ptk *ptk, size_t ptk_len);
  193. struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
  194. void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
  195. void wpa_ft_install_ptk(struct wpa_state_machine *sm);
  196. #endif /* CONFIG_IEEE80211R */
  197. #endif /* WPA_AUTH_I_H */