wpa_auth_i.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. struct wpa_group;
  17. struct wpa_stsl_negotiation {
  18. struct wpa_stsl_negotiation *next;
  19. u8 initiator[ETH_ALEN];
  20. u8 peer[ETH_ALEN];
  21. };
  22. struct wpa_state_machine {
  23. struct wpa_authenticator *wpa_auth;
  24. struct wpa_group *group;
  25. u8 addr[ETH_ALEN];
  26. enum {
  27. WPA_PTK_INITIALIZE, WPA_PTK_DISCONNECT, WPA_PTK_DISCONNECTED,
  28. WPA_PTK_AUTHENTICATION, WPA_PTK_AUTHENTICATION2,
  29. WPA_PTK_INITPMK, WPA_PTK_INITPSK, WPA_PTK_PTKSTART,
  30. WPA_PTK_PTKCALCNEGOTIATING, WPA_PTK_PTKCALCNEGOTIATING2,
  31. WPA_PTK_PTKINITNEGOTIATING, WPA_PTK_PTKINITDONE
  32. } wpa_ptk_state;
  33. enum {
  34. WPA_PTK_GROUP_IDLE = 0,
  35. WPA_PTK_GROUP_REKEYNEGOTIATING,
  36. WPA_PTK_GROUP_REKEYESTABLISHED,
  37. WPA_PTK_GROUP_KEYERROR
  38. } wpa_ptk_group_state;
  39. Boolean Init;
  40. Boolean DeauthenticationRequest;
  41. Boolean AuthenticationRequest;
  42. Boolean ReAuthenticationRequest;
  43. Boolean Disconnect;
  44. int TimeoutCtr;
  45. int GTimeoutCtr;
  46. Boolean TimeoutEvt;
  47. Boolean EAPOLKeyReceived;
  48. Boolean EAPOLKeyPairwise;
  49. Boolean EAPOLKeyRequest;
  50. Boolean MICVerified;
  51. Boolean GUpdateStationKeys;
  52. u8 ANonce[WPA_NONCE_LEN];
  53. u8 SNonce[WPA_NONCE_LEN];
  54. u8 PMK[PMK_LEN];
  55. struct wpa_ptk PTK;
  56. Boolean PTK_valid;
  57. Boolean pairwise_set;
  58. int keycount;
  59. Boolean Pair;
  60. u8 key_replay_counter[WPA_REPLAY_COUNTER_LEN];
  61. Boolean key_replay_counter_valid;
  62. Boolean PInitAKeys; /* WPA only, not in IEEE 802.11i */
  63. Boolean PTKRequest; /* not in IEEE 802.11i state machine */
  64. Boolean has_GTK;
  65. Boolean PtkGroupInit; /* init request for PTK Group state machine */
  66. u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
  67. size_t last_rx_eapol_key_len;
  68. unsigned int changed:1;
  69. unsigned int in_step_loop:1;
  70. unsigned int pending_deinit:1;
  71. unsigned int started:1;
  72. unsigned int mgmt_frame_prot:1;
  73. #ifdef CONFIG_IEEE80211R
  74. unsigned int ft_completed:1;
  75. unsigned int pmk_r1_name_valid:1;
  76. #endif /* CONFIG_IEEE80211R */
  77. u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
  78. int req_replay_counter_used;
  79. u8 *wpa_ie;
  80. size_t wpa_ie_len;
  81. enum {
  82. WPA_VERSION_NO_WPA = 0 /* WPA not used */,
  83. WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
  84. WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
  85. } wpa;
  86. int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
  87. int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
  88. struct rsn_pmksa_cache_entry *pmksa;
  89. u32 dot11RSNAStatsTKIPLocalMICFailures;
  90. u32 dot11RSNAStatsTKIPRemoteMICFailures;
  91. #ifdef CONFIG_IEEE80211R
  92. u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
  93. size_t xxkey_len;
  94. u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
  95. * Request */
  96. u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
  97. size_t r0kh_id_len;
  98. #endif /* CONFIG_IEEE80211R */
  99. };
  100. /* per group key state machine data */
  101. struct wpa_group {
  102. struct wpa_group *next;
  103. int vlan_id;
  104. Boolean GInit;
  105. int GKeyDoneStations;
  106. Boolean GTKReKey;
  107. int GTK_len;
  108. int GN, GM;
  109. Boolean GTKAuthenticator;
  110. u8 Counter[WPA_NONCE_LEN];
  111. enum {
  112. WPA_GROUP_GTK_INIT = 0,
  113. WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE
  114. } wpa_group_state;
  115. u8 GMK[WPA_GMK_LEN];
  116. u8 GTK[2][WPA_GTK_MAX_LEN];
  117. u8 GNonce[WPA_NONCE_LEN];
  118. Boolean changed;
  119. #ifdef CONFIG_IEEE80211W
  120. u8 IGTK[2][WPA_IGTK_LEN];
  121. int GN_igtk, GM_igtk;
  122. #endif /* CONFIG_IEEE80211W */
  123. };
  124. struct wpa_ft_pmk_cache;
  125. /* per authenticator data */
  126. struct wpa_authenticator {
  127. struct wpa_group *group;
  128. unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
  129. u32 dot11RSNAAuthenticationSuiteSelected;
  130. u32 dot11RSNAPairwiseCipherSelected;
  131. u32 dot11RSNAGroupCipherSelected;
  132. u8 dot11RSNAPMKIDUsed[PMKID_LEN];
  133. u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
  134. u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
  135. u32 dot11RSNAGroupCipherRequested; /* FIX: update */
  136. unsigned int dot11RSNATKIPCounterMeasuresInvoked;
  137. unsigned int dot11RSNA4WayHandshakeFailures;
  138. struct wpa_stsl_negotiation *stsl_negotiations;
  139. struct wpa_auth_config conf;
  140. struct wpa_auth_callbacks cb;
  141. u8 *wpa_ie;
  142. size_t wpa_ie_len;
  143. u8 addr[ETH_ALEN];
  144. struct rsn_pmksa_cache *pmksa;
  145. struct wpa_ft_pmk_cache *ft_pmk_cache;
  146. };
  147. int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
  148. const u8 *pmkid);
  149. void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
  150. logger_level level, const char *txt);
  151. void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
  152. logger_level level, const char *fmt, ...);
  153. void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
  154. struct wpa_state_machine *sm, int key_info,
  155. const u8 *key_rsc, const u8 *nonce,
  156. const u8 *kde, size_t kde_len,
  157. int keyidx, int encr, int force_version);
  158. int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
  159. int (*cb)(struct wpa_state_machine *sm, void *ctx),
  160. void *cb_ctx);
  161. int wpa_auth_for_each_auth(struct wpa_authenticator *wpa_auth,
  162. int (*cb)(struct wpa_authenticator *a, void *ctx),
  163. void *cb_ctx);
  164. #ifdef CONFIG_PEERKEY
  165. int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
  166. struct wpa_stsl_negotiation *neg);
  167. void wpa_smk_error(struct wpa_authenticator *wpa_auth,
  168. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  169. void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
  170. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  171. void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
  172. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  173. #endif /* CONFIG_PEERKEY */
  174. #ifdef CONFIG_IEEE80211R
  175. int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
  176. int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
  177. struct wpa_ptk *ptk);
  178. struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
  179. void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
  180. #endif /* CONFIG_IEEE80211R */
  181. #endif /* WPA_AUTH_I_H */