peerkey.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * WPA Supplicant - PeerKey for Direct Link Setup (DLS)
  3. * Copyright (c) 2006-2008, 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 PEERKEY_H
  15. #define PEERKEY_H
  16. #define PEERKEY_MAX_IE_LEN 80
  17. struct wpa_peerkey {
  18. struct wpa_peerkey *next;
  19. int initiator; /* whether this end was initator for SMK handshake */
  20. u8 addr[ETH_ALEN]; /* other end MAC address */
  21. u8 inonce[WPA_NONCE_LEN]; /* Initiator Nonce */
  22. u8 pnonce[WPA_NONCE_LEN]; /* Peer Nonce */
  23. u8 rsnie_i[PEERKEY_MAX_IE_LEN]; /* Initiator RSN IE */
  24. size_t rsnie_i_len;
  25. u8 rsnie_p[PEERKEY_MAX_IE_LEN]; /* Peer RSN IE */
  26. size_t rsnie_p_len;
  27. u8 smk[PMK_LEN];
  28. int smk_complete;
  29. u8 smkid[PMKID_LEN];
  30. u32 lifetime;
  31. os_time_t expiration;
  32. int cipher; /* Selected cipher (WPA_CIPHER_*) */
  33. u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
  34. int replay_counter_set;
  35. int use_sha256; /* whether AKMP indicate SHA256-based derivations */
  36. struct wpa_ptk stk, tstk;
  37. int stk_set, tstk_set;
  38. };
  39. #ifdef CONFIG_PEERKEY
  40. int peerkey_verify_eapol_key_mic(struct wpa_sm *sm,
  41. struct wpa_peerkey *peerkey,
  42. struct wpa_eapol_key *key, u16 ver,
  43. const u8 *buf, size_t len);
  44. void peerkey_rx_eapol_4way(struct wpa_sm *sm, struct wpa_peerkey *peerkey,
  45. struct wpa_eapol_key *key, u16 key_info, u16 ver);
  46. void peerkey_rx_eapol_smk(struct wpa_sm *sm, const u8 *src_addr,
  47. struct wpa_eapol_key *key, size_t extra_len,
  48. u16 key_info, u16 ver);
  49. void peerkey_deinit(struct wpa_sm *sm);
  50. #else /* CONFIG_PEERKEY */
  51. static inline int
  52. peerkey_verify_eapol_key_mic(struct wpa_sm *sm,
  53. struct wpa_peerkey *peerkey,
  54. struct wpa_eapol_key *key, u16 ver,
  55. const u8 *buf, size_t len)
  56. {
  57. return -1;
  58. }
  59. static inline void
  60. peerkey_rx_eapol_4way(struct wpa_sm *sm, struct wpa_peerkey *peerkey,
  61. struct wpa_eapol_key *key, u16 key_info, u16 ver)
  62. {
  63. }
  64. static inline void
  65. peerkey_rx_eapol_smk(struct wpa_sm *sm, const u8 *src_addr,
  66. struct wpa_eapol_key *key, size_t extra_len,
  67. u16 key_info, u16 ver)
  68. {
  69. }
  70. static inline void peerkey_deinit(struct wpa_sm *sm)
  71. {
  72. }
  73. #endif /* CONFIG_PEERKEY */
  74. #endif /* PEERKEY_H */