wpa_auth_i.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. u8 *last_rx_eapol_key; /* starting from IEEE 802.1X header */
  66. size_t last_rx_eapol_key_len;
  67. unsigned int changed:1;
  68. unsigned int in_step_loop:1;
  69. unsigned int pending_deinit:1;
  70. unsigned int started:1;
  71. unsigned int mgmt_frame_prot:1;
  72. #ifdef CONFIG_IEEE80211R
  73. unsigned int ft_completed:1;
  74. unsigned int pmk_r1_name_valid:1;
  75. #endif /* CONFIG_IEEE80211R */
  76. u8 req_replay_counter[WPA_REPLAY_COUNTER_LEN];
  77. int req_replay_counter_used;
  78. u8 *wpa_ie;
  79. size_t wpa_ie_len;
  80. enum {
  81. WPA_VERSION_NO_WPA = 0 /* WPA not used */,
  82. WPA_VERSION_WPA = 1 /* WPA / IEEE 802.11i/D3.0 */,
  83. WPA_VERSION_WPA2 = 2 /* WPA2 / IEEE 802.11i */
  84. } wpa;
  85. int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
  86. int wpa_key_mgmt; /* the selected WPA_KEY_MGMT_* */
  87. struct rsn_pmksa_cache_entry *pmksa;
  88. u32 dot11RSNAStatsTKIPLocalMICFailures;
  89. u32 dot11RSNAStatsTKIPRemoteMICFailures;
  90. #ifdef CONFIG_IEEE80211R
  91. u8 xxkey[PMK_LEN]; /* PSK or the second 256 bits of MSK */
  92. size_t xxkey_len;
  93. u8 pmk_r1_name[WPA_PMK_NAME_LEN]; /* PMKR1Name derived from FT Auth
  94. * Request */
  95. u8 r0kh_id[FT_R0KH_ID_MAX_LEN]; /* R0KH-ID from FT Auth Request */
  96. size_t r0kh_id_len;
  97. #endif /* CONFIG_IEEE80211R */
  98. };
  99. /* per group key state machine data */
  100. struct wpa_group {
  101. struct wpa_group *next;
  102. int vlan_id;
  103. Boolean GInit;
  104. int GKeyDoneStations;
  105. Boolean GTKReKey;
  106. int GTK_len;
  107. int GN, GM;
  108. Boolean GTKAuthenticator;
  109. u8 Counter[WPA_NONCE_LEN];
  110. enum {
  111. WPA_GROUP_GTK_INIT = 0,
  112. WPA_GROUP_SETKEYS, WPA_GROUP_SETKEYSDONE
  113. } wpa_group_state;
  114. u8 GMK[WPA_GMK_LEN];
  115. u8 GTK[2][WPA_GTK_MAX_LEN];
  116. u8 GNonce[WPA_NONCE_LEN];
  117. Boolean changed;
  118. #ifdef CONFIG_IEEE80211W
  119. u8 IGTK[2][WPA_IGTK_LEN];
  120. int GN_igtk, GM_igtk;
  121. #endif /* CONFIG_IEEE80211W */
  122. };
  123. struct wpa_ft_pmk_cache;
  124. /* per authenticator data */
  125. struct wpa_authenticator {
  126. struct wpa_group *group;
  127. unsigned int dot11RSNAStatsTKIPRemoteMICFailures;
  128. u32 dot11RSNAAuthenticationSuiteSelected;
  129. u32 dot11RSNAPairwiseCipherSelected;
  130. u32 dot11RSNAGroupCipherSelected;
  131. u8 dot11RSNAPMKIDUsed[PMKID_LEN];
  132. u32 dot11RSNAAuthenticationSuiteRequested; /* FIX: update */
  133. u32 dot11RSNAPairwiseCipherRequested; /* FIX: update */
  134. u32 dot11RSNAGroupCipherRequested; /* FIX: update */
  135. unsigned int dot11RSNATKIPCounterMeasuresInvoked;
  136. unsigned int dot11RSNA4WayHandshakeFailures;
  137. struct wpa_stsl_negotiation *stsl_negotiations;
  138. struct wpa_auth_config conf;
  139. struct wpa_auth_callbacks cb;
  140. u8 *wpa_ie;
  141. size_t wpa_ie_len;
  142. u8 addr[ETH_ALEN];
  143. struct rsn_pmksa_cache *pmksa;
  144. struct wpa_ft_pmk_cache *ft_pmk_cache;
  145. };
  146. int wpa_write_rsn_ie(struct wpa_auth_config *conf, u8 *buf, size_t len,
  147. const u8 *pmkid);
  148. void wpa_auth_logger(struct wpa_authenticator *wpa_auth, const u8 *addr,
  149. logger_level level, const char *txt);
  150. void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
  151. logger_level level, const char *fmt, ...);
  152. void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
  153. struct wpa_state_machine *sm, int key_info,
  154. const u8 *key_rsc, const u8 *nonce,
  155. const u8 *kde, size_t kde_len,
  156. int keyidx, int encr, int force_version);
  157. int wpa_auth_for_each_sta(struct wpa_authenticator *wpa_auth,
  158. int (*cb)(struct wpa_state_machine *sm, void *ctx),
  159. void *cb_ctx);
  160. #ifdef CONFIG_PEERKEY
  161. int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
  162. struct wpa_stsl_negotiation *neg);
  163. void wpa_smk_error(struct wpa_authenticator *wpa_auth,
  164. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  165. void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
  166. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  167. void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
  168. struct wpa_state_machine *sm, struct wpa_eapol_key *key);
  169. #endif /* CONFIG_PEERKEY */
  170. #ifdef CONFIG_IEEE80211R
  171. int wpa_write_mdie(struct wpa_auth_config *conf, u8 *buf, size_t len);
  172. int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
  173. struct wpa_ptk *ptk);
  174. struct wpa_ft_pmk_cache * wpa_ft_pmk_cache_init(void);
  175. void wpa_ft_pmk_cache_deinit(struct wpa_ft_pmk_cache *cache);
  176. #endif /* CONFIG_IEEE80211R */
  177. #endif /* WPA_AUTH_I_H */