pmksa_cache.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * wpa_supplicant - WPA2/RSN PMKSA cache functions
  3. * Copyright (c) 2003-2009, 2011-2012, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef PMKSA_CACHE_H
  9. #define PMKSA_CACHE_H
  10. /**
  11. * struct rsn_pmksa_cache_entry - PMKSA cache entry
  12. */
  13. struct rsn_pmksa_cache_entry {
  14. struct rsn_pmksa_cache_entry *next;
  15. u8 pmkid[PMKID_LEN];
  16. u8 pmk[PMK_LEN];
  17. size_t pmk_len;
  18. os_time_t expiration;
  19. int akmp; /* WPA_KEY_MGMT_* */
  20. u8 aa[ETH_ALEN];
  21. os_time_t reauth_time;
  22. /**
  23. * network_ctx - Network configuration context
  24. *
  25. * This field is only used to match PMKSA cache entries to a specific
  26. * network configuration (e.g., a specific SSID and security policy).
  27. * This can be a pointer to the configuration entry, but PMKSA caching
  28. * code does not dereference the value and this could be any kind of
  29. * identifier.
  30. */
  31. void *network_ctx;
  32. int opportunistic;
  33. };
  34. struct rsn_pmksa_cache;
  35. enum pmksa_free_reason {
  36. PMKSA_FREE,
  37. PMKSA_REPLACE,
  38. PMKSA_EXPIRE,
  39. };
  40. #if defined(IEEE8021X_EAPOL) && !defined(CONFIG_NO_WPA2)
  41. struct rsn_pmksa_cache *
  42. pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
  43. void *ctx, enum pmksa_free_reason reason),
  44. void *ctx, struct wpa_sm *sm);
  45. void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa);
  46. struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
  47. const u8 *aa, const u8 *pmkid,
  48. const void *network_ctx);
  49. int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len);
  50. struct rsn_pmksa_cache_entry *
  51. pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
  52. const u8 *aa, const u8 *spa, void *network_ctx, int akmp);
  53. struct rsn_pmksa_cache_entry * pmksa_cache_get_current(struct wpa_sm *sm);
  54. void pmksa_cache_clear_current(struct wpa_sm *sm);
  55. int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid,
  56. const u8 *bssid, void *network_ctx,
  57. int try_opportunistic);
  58. struct rsn_pmksa_cache_entry *
  59. pmksa_cache_get_opportunistic(struct rsn_pmksa_cache *pmksa,
  60. void *network_ctx, const u8 *aa);
  61. void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa, void *network_ctx,
  62. const u8 *pmk, size_t pmk_len);
  63. #else /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */
  64. static inline struct rsn_pmksa_cache *
  65. pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
  66. void *ctx, enum pmksa_free_reason reason),
  67. void *ctx, struct wpa_sm *sm)
  68. {
  69. return (void *) -1;
  70. }
  71. static inline void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
  72. {
  73. }
  74. static inline struct rsn_pmksa_cache_entry *
  75. pmksa_cache_get(struct rsn_pmksa_cache *pmksa, const u8 *aa, const u8 *pmkid,
  76. const void *network_ctx)
  77. {
  78. return NULL;
  79. }
  80. static inline struct rsn_pmksa_cache_entry *
  81. pmksa_cache_get_current(struct wpa_sm *sm)
  82. {
  83. return NULL;
  84. }
  85. static inline int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf,
  86. size_t len)
  87. {
  88. return -1;
  89. }
  90. static inline struct rsn_pmksa_cache_entry *
  91. pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
  92. const u8 *aa, const u8 *spa, void *network_ctx, int akmp)
  93. {
  94. return NULL;
  95. }
  96. static inline void pmksa_cache_clear_current(struct wpa_sm *sm)
  97. {
  98. }
  99. static inline int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid,
  100. const u8 *bssid,
  101. void *network_ctx,
  102. int try_opportunistic)
  103. {
  104. return -1;
  105. }
  106. static inline void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa,
  107. void *network_ctx,
  108. const u8 *pmk, size_t pmk_len)
  109. {
  110. }
  111. #endif /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */
  112. #endif /* PMKSA_CACHE_H */